Public Class Form1
Dim x(10) As String, y(10) As Double '示º?例¤y中D显?示º?11条¬?数ºy据Y
Dim yy() As Double
Private Sub Button1_Click(ByValsender As System.Object,ByVal e AsSystem.EventArgs) HandlesButton1.Click
'按ã¡ä钮£¤单Ì£¤击¡Â事º?件t模¡ê拟a取¨?数ºy
yy = GetValue()
Dim i As Integer
For i =0 To yy.Length - 1
y(i) = yy(i)
Next
Chart1.Series(0).ChartType =DataVisualization.Charting.SeriesChartType.Line
Chart1.Series(0).Points.DataBindXY(x,y)
Chart1.Series(0).IsValueShownAsLabel = True
Chart1.Series(0).LabelForeColor = Color.Red
Chart1.ChartAreas(0).AxisX.Minimum = 0
Chart1.ChartAreas(0).AxisX.Maximum =yy.Length
Chart1.ChartAreas(0).AxisX.Interval = 1
End Sub
Private Sub Form1_Load(ByValsender As Object,ByVal e As EventArgs) HandlesMyBase.Load
Chart1.Dock = DockStyle.Fill
Button1.BringToFront()
Chart1.ChartAreas(0).AxisX.MajorGrid.Enabled = False
Chart1.ChartAreas(0).AxisY.MajorGrid.Enabled = False
End Sub
FunctionGetValue() As Array'这a是º?一°?个?模¡ê拟a取¨?数ºy的Ì?函¡¥数ºy
Dim a As Integer = 0
If yy Is Nothing Then
a = 0
Else
a = yy.Length
End If
If a =11 Then
Fori As Integer =0 To 9
yy(i) = yy(i + 1)
x(i) = x(i + 1)
Next
yy(10) = Math.Round(a* Rnd(100) * 1.0264, 2)
x(10) = Format(Now, "hh:mm:ss")
Else
ReDimPreserve yy(a)
yy(a) = Math.Round(a* Rnd(100) * 1.0264, 2)
x(a) = Format(Now, "hh:mm:ss")
End If
Returnyy
End Function
End Class