十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
在 series 集合编辑器 里找到杂项 customproperties 里的 pointwidth 设置
成都创新互联公司于2013年成立,是专业互联网技术服务公司,拥有项目成都网站设计、成都网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元太和做网站,已为上家服务,为太和各地企业和个人服务,联系电话:028-86922220
引用microsoft chart control6.0(sp4)
添加mxchart空件
mxchart空件可以实现各种图形,什么饼,柱,三角,线,都可以。而且可以是立体的。
chart控件和timer控件,用timer控件触发chart控件中系列数据的更新。
'新建一个标准exe工程,画一个command1,一个label,其index属性设为0然后将代码粘贴
Private Sub Command1_Click()
Static Ts As Integer
Ts = Ts + 1
x = InputBox("请输入柱状图高度(1-19):")
If Val(x) 20 Or Val(x) = 0 Then
Ts = Ts - 1
MsgBox "请输入0-19范围的数"
Exit Sub
End If
Set newobj = Me.Controls.Add("vb.shape", "shape" Ts)
With newobj
.Shape = 0
.FillStyle = 5
.Left = 1 + 2 * Ts
.Top = 42 - x * 2
.Height = x * 2
.Width = 1
End With
newobj.Visible = True
End Sub
Private Sub Form_Load()
Me.Height = 9000
Me.Width = 19000
Me.AutoRedraw = True
Show
Me.ScaleHeight = 44 '将窗体的高设定为44份
Me.ScaleWidth = 50 '将窗体的宽设定为50份
'Me.Line.BorderColor = H0
Me.Line (2, 2)-(2, 42), H0 '画出纵坐标
Me.Line (2, 42)-(48, 42), H0 '画出横坐标
Me.Line (48, 42)-(47.5, 41.5), H0 '画出横坐标上的箭头
Me.Line (48, 42)-(47.5, 42.5), H0
Me.Line (2, 2)-(1.75, 3), H0 '画出纵坐标上的箭头
Me.Line (2, 2)-(2.25, 3), H0
Label1(0).Width = 20 '写出坐标原点
Label1(0).Height = 20
Label1(0).AutoSize = ture
Label1(0).BackStyle = 0
Label1(0).FontItalic = True
Label1(0).FontBold = True
Label1(0).FontSize = 10
Label1(0).ForeColor = HFF
Label1(0).Caption = 0
Label1(0).Left = 1.5
Label1(0).Top = 42.5
Label1(0).Visible = True
For i = 1 To 45
Load Label1(i) '用数组的方法动态添加控件(横坐标示数)
Label1(i).Width = 40
Label1(i).Height = 20
Label1(i).AutoSize = ture
Label1(i).BackStyle = 0
Label1(i).FontItalic = True
Label1(i).FontBold = True
Label1(i).FontSize = 10
Label1(i).ForeColor = HFF
Label1(i).Caption = i
Label1(i).Left = 1.5 + i
Label1(i).Top = 42.5
Label1(i).Visible = True
'动态添加控件(横坐标上的间隔线)
Set newobj = Me.Controls.Add("vb.line", "Line" i)
With newobj
.BorderStyle = 3
.X1 = i + 2
.X2 = i + 2
.Y1 = 41.8
.Y2 = 42.2
End With
newobj.Visible = True
Next i
For i = 46 To 70
Load Label1(i)
Label1(i).Width = 40
Label1(i).Height = 20
Label1(i).AutoSize = ture
Label1(i).BackStyle = 0
Label1(i).FontItalic = True
Label1(i).FontBold = True
Label1(i).FontSize = 10
Label1(i).ForeColor = HFF
Label1(i).Caption = i - 45
Label1(i).Left = 1
Label1(i).Top = (66 - i) * 2
If Val(Label1(i).Caption) 20 Then Label1(i).Visible = True
Set newobj = Me.Controls.Add("vb.line", "Line" i)
With newobj
.X1 = 1.9
.X2 = 2.1
.Y1 = 2 * (i - 44)
.Y2 = 2 * (i - 44)
'.BorderStyle = 3
End With
newobj.Visible = True
Next i
End Sub
三个办法,你自己选择吧。
1、用图形,自己画。不要以为这个是胡扯,实际上任何一个图形控件都是通过GUI这么画出来的。你自己写代码画没有想象中那么难。我曾经自己写了一个控件,实现任务管理器里面CPU占用率显示的那个效果,代码也不过百多行,比大多数人想的都要容易。
2、用 Microsoft Chart Controls。mschart绝大多数机器上都有,能提供基本的图形显示。操作比较简单,相应的功能也比较简单。但最常见的折线图、饼图、柱状图都是有的。
3、使用第三方控件。推荐 TeeChart,不过正版的要收费。你能在网上找到破解的老版本。功能强大,画面漂亮、图形种类繁多,有动态操作功能。什么坐标啊,顶点标签啊,图例啊等等全都有。
给个以前做的柱状图工程及代码:
Option Explicit
Dim i As Long
Dim record_jmm(10) As Single
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub Form_Load()
For i = 0 To 30
Line (350, 3960 + i * 141)-(450, 3960 + i * 141), vbRed
Line (1920 + 350, 3960 + i * 141)-(1920 + 450, 3960 + i * 141), vbRed
Line (1920 * 2 + 350, 3960 + i * 141)-(1920 * 2 + 450, 3960 + i * 141), vbRed
Line (1920 * 3 + 350, 3960 + i * 141)-(1920 * 3 + 450, 3960 + i * 141), vbRed
Line (1920 * 4 + 350, 3960 + i * 141)-(1920 * 4 + 450, 3960 + i * 141), vbRed
Next
For i = 0 To 40
Line (1920 * 5 + 450, 3960 + i * 105)-(1920 * 5 + 550, 3960 + i * 105), vbRed
Next
For i = 0 To 4
Line (1920 * 5 + 450, 3960 + i * 1050)-(1920 * 5 + 650, 3960 + i * 1050), vbRed
Next
For i = 0 To 4
Line (350 + 1920 * i, 3960)-(350 + 1920 * i, 3960 + 4235), vbRed
Me.CurrentX = 20 + i * 1920
Me.ForeColor = vbRed
Me.CurrentY = 3880
Print "150"
Me.CurrentX = 20 + i * 1920
Me.CurrentY = 3880 + 705
Print "100"
Me.CurrentX = 20 + i * 1920
Me.CurrentY = 3880 + 705 * 2
Print " 50"
Me.CurrentX = 20 + i * 1920
Me.CurrentY = 3880 + 705 * 3
Print " 0"
Me.CurrentX = 20 + i * 1920
Me.CurrentY = 3880 + 705 * 4
Print "-50"
Me.CurrentX = 10 + i * 1920
Me.CurrentY = 3880 + 705 * 5
Print "-100"
Me.CurrentX = 10 + i * 1920
Me.CurrentY = 3880 + 705 * 6
Print "-150"
Next
Me.CurrentX = 20 + 5 * 1920
Me.ForeColor = vbYellow
Me.CurrentY = 3880
Print "10000"
Me.CurrentX = 20 + 5 * 1920
Me.CurrentY = 3880 + 1059
Print " 1000"
Me.CurrentX = 20 + 5 * 1920
Me.CurrentY = 3880 + 1059 * 2
Print " 100"
Me.CurrentX = 20 + 5 * 1920
Me.CurrentY = 3880 + 1059 * 3
Print " 10"
Me.CurrentX = 20 + 5 * 1920
Me.CurrentY = 3880 + 1059 * 4
Print " 1"
End Sub
Private Sub Timer1_Timer()
For i = 0 To 5
PitBangtu(i).Cls
Next i
PitBangtu(0).Line (0, 2117.5 - record_jmm(3) * 42.35 / 3)-(1095, 4235), vbRed, BF
PitBangtu(1).Line (0, 2117.5 - record_jmm(4) * 42.35 / 3)-(1095, 4235), vbRed, BF
PitBangtu(2).Line (0, 2117.5 - record_jmm(5) * 42.35 / 3)-(1095, 4235), vbRed, BF
PitBangtu(3).Line (0, 2117.5 - record_jmm(6) * 42.35 / 3)-(1095, 4235), vbRed, BF
PitBangtu(4).Line (0, 2117.5 - record_jmm(0) * 42.35 / 3)-(1095, 4235), vbRed, BF
'PitBangtu(0).Line (0, 2117.5 - 150 * 42.35 / 3)-(1095, 4235), vbRed, BF
If Val(record_jmm(10)) 10000 And Val(record_jmm(10)) = 1000 Then
PitBangtu(5).Line (0, 0 + (10000 - record_jmm(10)) * 0.1174)-(1095, 4235), vbRed, BF
ElseIf Val(record_jmm(10)) 1000 And Val(record_jmm(10)) = 100 Then
PitBangtu(5).Line (0, 1058.75 + (1000 - record_jmm(10)) * 1.1744)-(1095, 4235), vbRed, BF
ElseIf Val(record_jmm(10)) 100 And Val(record_jmm(10)) = 10 Then
PitBangtu(5).Line (0, 2117.5 + (100 - record_jmm(10)) * 11.744)-(1095, 4235), vbRed, BF
ElseIf Val(record_jmm(10)) 10 And Val(record_jmm(10)) = 1 Then
PitBangtu(5).Line (0, 3176.25 + (10 - record_jmm(10)) * 117.444)-(1095, 4235), vbRed, BF
End If
End Sub