重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
方法一:Excel中就可以实现;
成都创新互联公司是一家集网站建设,晋城企业网站建设,晋城品牌网站建设,网站定制,晋城网站建设报价,网络营销,网络优化,晋城网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。
方法二:通过VB.net将数据写入到Excel中生成趋势图;
方法三:直接通过VB.net写出这种趋势图。
具体方法可以参考VB.net操作Excel方法:
可用代码:
For i = 0 To iRow - 1
pointXY(i) = "'这里你可以直接放上你的数据点值在X线上
"
pointYY(i) = "'这里你可以直接放上你的数据点值在Y线上
Next
Private Sub DrawRectangle()
Try
Dim oV2Bar As New Graphing.V3.Bar.BarChart()
Dim renderer As New Graphing.V3.Render
PictureBox1.Image = renderer.DrawChart(oV2Bar, Xline,Yline iRow, pointXY, pointYY)
End If
Catch ex As Exception
MsgBox(ex.Message)
Public Class BarChart : Inherits Base.BaseGraph
'This will hold the Bar pieces.
Public BarSliceCollection As New Bar.BarPieceCollection()
Private _Alignment As Base.b_BarTypes = Base.b_BarTypes.HorizontalLeft
Public Property Alignment() As Base.b_BarTypes
Get
Return _Alignment
End Get
Set(ByVal Value As Base.b_BarTypes)
_Alignment = Value
End Set
End Property
'Private _ChartType As Base.b_ChartType = Base.b_ChartType.Bar
Public Shadows ReadOnly Property ChartType() As Base.b_ChartType
Get
Return MyBase.ChartType
End Get
End Property
Sub New()
MyBase.new()
MyBase.ChartType = Base.b_ChartType.Bar
End Sub
Sub New(ByVal BarPieceCollection As BarPieceCollection)
MyBase.new()
MyBase.ChartType = Base.b_ChartType.Bar
BarSliceCollection = BarPieceCollection
End Sub
End Class
End Try
End Sub
。net 其实还是很好绘制图形的
你可以看下 Graphics 类
Dim d As New Bitmap(Me.Width, Me.Height) ‘一个图片吧
Dim g As Graphics = Graphics.FromImage(d)’绘制 准备在这个图片是进行
然后 就是你绘制的东西了
线 就是 g.DrawLine()
圆 弧度 就用 g.DrawArc(Pens.Black, New Rectangle(0, 0, 400, 200), 0, 360)
复杂的就是 g.DrawBezier()
等 如果你用的是 VS的 编译 上面都有详细的参数说明
Dim d As New Bitmap(Me.Width, Me.Height)
Dim g As Graphics = Graphics.FromImage(d)
g.DrawArc(Pens.Black, New Rectangle(0, 0, 200, 200), 0, 360)
g.DrawLine(Pens.Red, New Point(0, 0), New Point(200, 200))
g.DrawLines(Pens.Green, New Point() {New Point(0, 0), New Point(50, 40), New Point(50, 80), New Point(90, 70), New Point(100, 400)})
g.DrawBezier(Pens.Yellow, New Point(0, 100), New Point(0, 0), New Point(200, 0), New Point(200, 200))
g.Dispose()
Me.BackgroundImage = d
这个说起来有点小复杂,建议你找专门的文章学习。
比如:
Private Sub PictureBox2_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox2.Paint
Dim points As New List(Of Point)
points.Add(New Point(0, 0))
points.Add(New Point(1, 10))
points.Add(New Point(3, 15))
points.Add(New Point(14, 0))
points.Add(New Point(20, 60))
points.Add(New Point(40, 20))
points.Add(New Point(70, 50))
e.Graphics.DrawCurve(Pens.Red, points.ToArray)
End Sub
供参考,points可设为全局变量,那样add随便在哪增加,想要看见看上去动态的图,那就在新增完n个后,继续增加n+1个之时,放弃points中的第一个。
vb.net:先计算好坐标,再用GDI+里封装的drawline方法画出短线(模拟数据点),传来一个数据就画一条短线,最后看起来就像曲线了。
vb6:用pset()函数
可以把所有画的线都保存在一个列表中,画的时候全部画出即可。如下:
Public Class Form1
Class Line '直线类
Public Point1, Point2 As Point '成员,直线的两个端点
Sub New(p1 As Point, p2 As Point) '构造方法
Point1 = p1
Point2 = p2
End Sub
Public Sub Draw(g As Graphics) '绘制方法
g.DrawLine(Pens.Black, Point1, Point2)
End Sub
End Class
Private Lines As New List(Of Line) '列表用于保存所有画下的直线
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
BackColor = Color.White
DoubleBuffered = True '开启双缓冲可有效避免闪烁
End Sub
Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
Lines.Add(New Line(e.Location, e.Location)) '在直线列表中添加直线
End Sub
Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
If e.Button Windows.Forms.MouseButtons.Left Then Return '左键未按下
'鼠标拖动时改变列表最后一条直线(也即当前直线的第二个端点)
Lines(Lines.Count - 1).Point2 = e.Location
Refresh() '刷新窗体
End Sub
'在Form的Paint事件中绘制所有直线,每次Form1重绘时都会触发Paint事件
'PS: 也可以通过重写OnPaint方法来达到类似的效果
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias '开启抗锯齿
For Each l In Lines '遍历所有直线
l.Draw(e.Graphics) '调用绘制方法,传入的参数可以理解为画布
Next
End Sub
End Class
运行效果: