drawline 那位大侠能给个画串口的曲线的例子,x轴是时间,y轴是串口值,谢谢!! __________________________________________________________________________ Net(C#)纯GDI+绘制实时动态曲线图 http://hi.baidu.com/zhihongf/blog/item/f96cfa1fe561550a314e1571.html __________________________________________________________________________ 你哪有没有用vb做的,c#我看的不是很明白,我的邮箱是feiyu_868@163.com __________________________________________________________________________ 我用vb做过。我看看怎么给你。 __________________________________________________________________________ Public Function MakeLinePic(ByVal hostip As String,ByVal yourname As String,ByVal yourpassword As String,ByVal station As String,ByVal element As String,ByVal ObservTimes As String,ByVal sizea As Integer,ByVal XAddNum As Integer,ByVal YAddNum As Integer,ByVal k As Integer,ByVal element1 As String,ByVal ObservTimes1 As String,ByVal buchang As Integer) As Bitmap 画坐标曲线的
方法 Dim mybitmap As Bitmap Dim myds As DataSet Dim maxnum,minnum As Single Dim a,a1,a2,i,j,b,b1,b2 As Integer If k = 0 Then myds = read
sqldb1S1E(hostip,yourname,yourpassword,station,element,ObservTimes,ObservTimes1) ElseIf k = 1 Then myds = read
sqldb2E(hostip,element1,ObservTimes) ElseIf k = 2 Then myds = read
sqldbsum(hostip,ObservTimes1) End If maxnum = Ceil(maxvaule(myds,1)) minnum = Floor(minvaule(myds,1)) a = (maxnum - minnum) / buchang a1 = 420 / a a2 = 420 / (maxnum - minnum) mybitmap = New Bitmap(550,530) Dim ag As Graphics ag = Graphics.FromImage(mybitmap) ag.Clear(Color.White) For i = 0 To a DrawMapXY(mybitmap,New Pen(Color.Gray),18,438 - i * a1,500,438 - i * a1) DrawWord1(mybitmap,1,438 - i * a1 - 3,minnum + i * buchang) Next i j = ObservTimes1 - ObservTimes b = 500 / myds.Tables(0).Rows.Count For i = 0 To myds.Tables(0).Rows.Count - 1 DrawMapXY(mybitmap,i * b + 18,438) DrawWord1(mybitmap,i * b + 15,445,i) Next i For i = 0 To myds.Tables(0).Rows.Count - 2 DrawMapXY(mybitmap,New Pen(Color.Blue),(420 - a2 * (myds.Tables(0).Rows(i)(1) - minnum) + 18),(i + 1) * b + 18,(420 - a2 * (myds.Tables(0).Rows(i + 1)(1) - minnum) + 18)) DrawEllipseXY2(mybitmap,myds.Tables(0).Rows(i)(1),New SolidBrush(Color.Red)) Next i DrawEllipseXY2(mybitmap,New SolidBrush(Color.Red)) Return mybitmap End Function __________________________________________________________________________ Private Function DrawWord(ByRef WordImage As Bitmap,ByVal x As Integer,ByVal y As Integer,ByVal strWord As String) 写字 Dim g As Graphics = Graphics.FromImage(WordImage) g.DrawString(strWord,New Font( Courier New,8),New SolidBrush(Color.Black),x + Size + 2,y - 2) End Function Private Function DrawWord1(ByRef WordImage As Bitmap,x,y) End Function Private Function DrawMapXY(ByRef imageTemp As Bitmap,ByVal DrawPen As Pen,ByVal XNum As Integer,ByVal YNum As Integer,ByVal X1Num As Integer,ByVal Y1Num As Integer) 指定坐标两点画线 Dim g As Graphics = Graphics.FromImage(imageTemp) g.DrawLine(DrawPen,New PointF(XNum + Size / 2,YNum + Size / 2),New PointF(X1Num + Size / 2,Y1Num + Size / 2)) End Function __________________________________________________________________________ 谢谢你zjxgold(稻草人),我看了你的程序,但是我还是有些不懂,我可以拿来做参考。在我的编译器里面后两行中的”/“不能通过。 我的问题是: 1如何把X轴初始化为以时间为基础: 2用DRAWLINE(PEN,X1,Y1,X2,Y2)做曲线,我看网上好多是以vb6.0为例子,但是在2005中却没有 3初始化PICTURE的坐标系,是其成为以中轴线为基础画曲线 4我的想法从串口BUFFER内取出值后给y1,y2以循环的
方法赋值。 非常感谢你们的帮助! __________________________________________________________________________ 学习 __________________________________________________________________________ http://hi.baidu.com/zhihongf/blog/item/f96cfa1fe561550a314e1571.html __________________________________________________________________________ 结贴散分! __________________________________________________________________________
原文链接:https://www.f2er.com/vb/263716.html