如何用VB建立坐标系并画出一系列折线图
在窗体中显示一个外观合适的坐标系,X.Y轴为固定长度,X轴表示时间(秒),Y轴表示工位,(工位数和时间均为可改变的数值),XY轴都有刻度,刻度的分法为:Y轴固定长度/工位数=Y轴刻度个数,X轴固定长度/(时间/60)=X轴刻度个数,每一分钟一个刻度, 刻度旁有标注,坐标内有网格线(按工位数及时间来画网格线),可设置成可选项,需要时显示,不需要时隐藏。有标题的标注功能。然后根据数据来画折线,如数据格式:
工位 时间
0 0
1 1
2 10
3 30
4 60
......
如下图:
就是不知从哪下手为好,请和位老师来帮忙解决,谢谢! 请来信:WINGFAI_RUANDC@126.COM
[解决办法]
自己参考下面的代码
Option ExplicitPrivate Sub PrintText(ByVal X As Single, ByVal Y As Single, ByVal Text As String) Picture1.CurrentX = X Picture1.CurrentY = Y Picture1.Print TextEnd SubPrivate Sub Command1_Click() Picture1.Cls Picture1.Scale (-200, 10)-(500, -2) Picture1.Line (0, 0)-(400, 10), , B PrintText 0, -1, "0" PrintText 60, -1, "60" PrintText -150, 1, "1:L/UL" PrintText -150, 2, "2:RINSE" Picture1.Line (0, 1)-(50, 4) Picture1.Line (50, 3.9)-(55, 4), vbRed, BF Picture1.Line (55, 4)-(60, 5) Picture1.Line (60, 5)-(65, 5.1), vbGreen, BFEnd SubPrivate Sub Form_Load() Picture1.BackColor = vbWhite Picture1.ForeColor = vbBlack Picture1.AutoRedraw = TrueEnd Sub
[解决办法]
Private Sub Form_Load()Form1.ShowForm1.Height = 7860Form1.Width = 10530Form1.AutoRedraw = TrueForm1.BackColor = vbBlueForm1.ForeColor = vbWhiteForm1.Scale (-120, -9.5)-(470, 1.5)Form1.DrawWidth = 1Line (0, -8)-(0, 0), vbWhite '左边框Line (350, -8)-(350, 0), vbWhite '右边框Line (0, -8)-(350, -8), vbWhite '上边框Line (0, 0)-(350, 0), vbWhite '下边框Form1.FontSize = 18CurrentX = -30CurrentY = -9Print "Y=工位"CurrentY = -8CurrentX = -110Print "8:CU4"CurrentY = -7CurrentX = -110Print "7:CU3"CurrentY = -6CurrentX = -110Print "6:CU2"CurrentY = -5CurrentX = -110Print "5:CU1"CurrentY = -4CurrentX = -110Print "4:A-DIP"CurrentY = -3CurrentX = -110Print "3:RINSE"CurrentY = -2CurrentX = -110Print "2:RINSE"CurrentY = -1CurrentX = -110Print "1:L/UL"For I = -8 To 0Line (-9, I)-(0, I + 0.15), QBColor(11), BFLine (-9, I)-(0, I + 0.15), , BNextFor I = 0 To 350 Step 60Line (I, 0)-(I + 6, 0.25), QBColor(11), BFLine (I, 0)-(I + 6, 0.25), , BNextFor I = 0 To 5CurrentY = 0.2CurrentX = I * 60 - 20Print I * 60CurrentY = 0.2CurrentX = 3508Print "X=时间(S)"NextLine (362, -5)-(372, -4.8), QBColor(10), BFLine (362, -5)-(372, -4.8), vbWhite, BCurrentY = -5.2CurrentX = 385Print ":提升"Line (362, -4)-(372, -3.8), QBColor(12), BFLine (362, -4)-(372, -3.8), vbWhite, BCurrentY = -4.2CurrentX = 385Print ":放下"CurrentY = -3CurrentX = 360Print "周期T=32"Line (0, -1)-(10, -1)Line (10, -1)-(40, -4)Line (40, -4)-(60, -4)Line (0, -1.2)-(10, -1), QBColor(10), BFLine (0, -1.2)-(10, -1), vbWhite, BEnd Sub