vb.net走势线代码的简单介绍
vb绘制趋势图
方法一:Excel中就可以实现;
10年积累的网站设计、网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有乐山免费网站建设让你可以放心的选择与我们合作。
方法二:通过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
vb.net绘制曲线图
。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
跪求vb.net代码
新建窗口,添加picture控件
利用line()方法画线
line(开始x坐标,开始y坐标)-(结束x坐标,结束y坐标),线的颜色,画线的方式(默认为线,B为矩形无填充,BF为填充的矩形)
For i = 1 To 16
Picture1.Line (0, Picture1.Height / 2)-(i * (Picture1.Width / 16), 0), RGB(255, 0, 0)
Picture1.Line (0, Picture1.Height / 2)-(i * (Picture1.Width / 16), Picture1.Height), RGB(255, 0, 0)
Picture1.Line (Picture1.Width, Picture1.Height / 2)-(i * (Picture1.Width / 16), 0), RGB(0, 255, 0)
Picture1.Line (Picture1.Width, Picture1.Height / 2)-(i * (Picture1.Width / 16), Picture1.Height), RGB(0, 255, 0)
Next i
如果要在窗口上画也可以调用窗口的line方法即form.line()
vb.net 绘制实时温度曲线
这个要用GDI+画。要看你.net版本。
以下是VS2005中的一段代码。
Me.PictureBox1.Height = 450
Me.PictureBox1.Width = 880
Dim gr As Graphics '定义画布
Dim bp As New Bitmap(880, 450) '定义位图,并进行赋值
Dim p As New Pen(Color.Black) '定义画笔
p.Width = 2 '宽度2
p.DashStyle = Drawing2D.DashStyle.Solid '样式直线
PictureBox1.Image = bp
gr = Graphics.FromImage(PictureBox1.Image)
gr.FillRectangle(Brushes.White, New Rectangle(0, 0, PictureBox1.Width, PictureBox1.Height))
gr.DrawLine(p, a, b, a, .Height - b) '绘制纵坐标
gr.DrawLine(p, a, .Height - b, .Width - a, .Height - b) '绘制横坐标
vb.net 画线再画保留以前画得
可以把所有画的线都保存在一个列表中,画的时候全部画出即可。如下:
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
运行效果:
网站栏目:vb.net走势线代码的简单介绍
新闻来源:http://hbruida.cn/article/dsgjjio.html