1,451
社区成员
发帖
与我相关
我的任务
分享
Dim temp As Integer '横轴时间长度
Dim STime As Variant '实时时间
Dim shuju_shishi As Integer
Dim shuju_zuidi As Integer
Dim shuju_guonei As Integer
Dim shuju_guoji As Integer
Dim shuju(3) As Integer
Dim n As Integer, i As Integer, j As Integer, k As Integer
Private Sub Form_Load()
STime = Now
temp = 300
shuju_shishi = 700 + 100 * Rnd() '数据赋值(模拟的数值,不是现场数据)
shuju_zuidi = 650
shuju_guonei = 700
shuju_guoji = 400
shuju(0) = shuju_shishi '赋值给数据数组
shuju(1) = shuju_zuidi
shuju(2) = shuju_guonei
shuju(3) = shuju_guoji
Text1.Text = shuju_shishi '文本显示实时数据
Text2.Text = shuju_zuidi
Text3.Text = shuju_guonei
Text4.Text = shuju_guoji
For i = 0 To 3
With TChart1.Series(i)
.XValues.DateTime = True
End With
Next i
With TChart1.Axis.Bottom
.Labels.DateTimeFormat = "yy-mm-dd HH:mm:ss" '日期类型的格式
.Automatic = False
.Maximum = DateAdd("s", temp, Now)
.Minimum = Now
End With
For k = 0 To 3 '画图
With TChart1.Series(k)
.AddXY Now, shuju(k), "", clTeeColor
End With
Next k
End Sub
Private Sub Timer1_Timer()
shuju_shishi = 700 + 100 * Rnd() '数据赋值(模拟的数值,不是现场数据)
shuju_zuidi = 650
shuju_guonei = 700
shuju_guoji = 400
shuju(0) = shuju_shishi '赋值给数据数组
shuju(1) = shuju_zuidi
shuju(2) = shuju_guonei
shuju(3) = shuju_guoji
Text1.Text = shuju_shishi '文本显示实时数据
Text2.Text = shuju_zuidi
Text3.Text = shuju_guonei
Text4.Text = shuju_guoji
If n = 0 Then
With TChart1.Axis.Bottom
.Labels.DateTimeFormat = "yy-mm-dd HH:mm:ss" '日期类型的格式
.Automatic = False
.Maximum = DateAdd("s", temp, STime)
.Minimum = STime
End With
End If
n = n + 1
If n > (temp / (Timer1.Interval / 1000)) Then '当超过控件的显示时间段后,重新换一页
STime = Now
With TChart1.Axis.Bottom
.Automatic = False
.Maximum = STime
.Minimum = DateAdd("s", -temp, STime)
End With
n = temp + 1 '防止n超过整型所能表示的最大值
End If
For k = 0 To 3 '画图
With TChart1.Series(k)
.AddXY Now, shuju(k), "", clTeeColor
End With
Next k
End Sub