我这里有时时生成的数据(每十分钟),需要画出直方图来,举例
9:40 最大距离100米,十分钟平均距离88米
9:50 最大距离110米,十分钟平均距离98米
按照时间轴画出,每十分钟2个指标在一起(不同颜色)表示出来。请问有什么控件或者方法做出么?
谢谢
9:40 最大距离100米,十分钟平均距离88米
9:50 最大距离110米,十分钟平均距离98米
按照时间轴画出,每十分钟2个指标在一起(不同颜色)表示出来。请问有什么控件或者方法做出么?
谢谢
http://topic.csdn.net/t/20020508/09/704485.html
下载地址:
http://www.ocx321.cn/soft/softdown.asp?softid=286将其拷贝到c:\windows\system32下面,注册:regsvr32 c:\windows\system32\graph32.ocx /u
Dim i As Integer
With Me
.Width = 7100
.Height = 5300
.ScaleMode = 1
.AutoRedraw = True
.DrawWidth = 2
'坐标
Scale (-v, .ScaleHeight)-(.ScaleWidth, -3 * v) '重画坐标
Line (0, 0)-(.ScaleWidth, 0), &H0& 'X
Line (-10, 0)-(0, -.ScaleHeight), &H0& 'Y
'时间刻度(Y)
For i = 1 To 14
Line (i * v, 50)-(i * v, -0), &H0&
Next
'距离刻度(Y)
For i = 1 To 10
Line (0, i * v)-(50, i * v), &H0&
Next
Timer1.Enabled = True
Timer1.Interval = 1000
Randomize
.DrawWidth = 2
End With
End SubPrivate Sub Timer1_Timer()
Dim i As Single
Dim r As Integer
Dim Color As Long
Dim k As Integer
Static cnt As Integer
Color = RGB(CInt(Rnd * 255) + 1, CInt(Rnd * 255) + 1, CInt(Rnd * 255) + 1)
r = Int(Rnd * 8) + 1
k = 50
Do While k < r * v
DoEvents
Line (cnt * v, k)-((cnt + 1) * v, k), Color
k = k + 10
Loop
cnt = cnt + 1
If cnt = 13 Then Timer1.Enabled = False
End Sub
如果看不明白,对照代码中的属性和方法,参照MSDN吧
也有现成的控件,如dlyme所说的MSchart
Option Explicit'定义 历史时间数
Dim htime() As String
Dim hdata1() As String
Dim hdata2() As StringPrivate Sub Command1_Click()
readfilemydrow
End SubPrivate Sub Form1_Load()
readfilemydrow
End SubPrivate Sub readfile()
'读取配置文件,按照历史资料读取全天资料
Open App.Path & "\1.txt" For Input As #nLine Input #n, t
While t = ""t1 = ""
t1 = t
'Line Input #n, t1
htime(i) = Trim(t1)
t2 = ""
Line Input #n, t2
hdata1(i) = Trim(t2)
t3 = ""
Line Input #n, t3
hdata2(i) = Trim(t3)
i = i + 1
Line Input #n, t
Wend
Close #n
ReDim htime(i - 1) As String
ReDim hdata1(i - 1) As String
ReDim hdata2(i - 1) As StringEnd Sub
'将读取的数据,利用控件画图
Private Sub mydraw()Dim arrdata(addtime, 2) ' addtime is howlongFor i = 0 To addtime - 1
arrdatime(i, 1) = hdata1(i)
arrdatime(i, 2) = hdata2(i)
Next i
MSChart1.ChartData = arrdataEnd Sub
Private Sub MSChart1_OLEStartDrag(Data As MSChart20Lib.DataObject, AllowedEffects As Long)End Sub
你在google中搜索MSCHART,看看有没有示例吧