After getting the demo running from this class. I would like to modify it to deal with realtime data. I have tried to modify the CreateLineChart2Data sub to plot one point and then with a timer, call this sub at a said interval but I keep on getting an error in the xChart class in line 1023 - Index out of bounds.
Is it at all possible just to plot one point and then another point later? Has anyone done this?
This is my effort to date:
Many thanks.
Is it at all possible just to plot one point and then another point later? Has anyone done this?
This is my effort to date:
B4X:
Sub InitYXChart
' set the line properties
YXChart1.ClearData
YXChart1.AddYXLine2("Speed", xui.Color_Red, 2dip, True, "CIRCLE", False, xui.Color_Red)
YXChart1.AddYXLine2("Direction", xui.Color_Green, 2dip, False, "SQUARE", True, xui.Color_Green)
YXChart1.XScaleTextOrientation = "VERTICAL"
YXChart1.ChartBackgroundColor = xui.Color_White
YXChart1.GridFrameColor = xui.Color_Black
YXChart1.GridColor = xui.Color_Gray
YXChart1.TitleTextColor = xui.Color_Black
YXChart1.ScaleTextColor = xui.Color_Black
YXChart1.DisplayValues = False
End Sub
Sub timer1_Tick
CreateYXChartData
End Sub
Private Sub CreateYXChartData
YXChart1.ClearData
'add the points
'Create dummy values
DateTime.TimeFormat = "HH:mm:ss"
Private ElapsedTime As String
ElapsedTime=DateTime.Time( DateTime.Now) 'time in seconds
Speed = Rnd(0, 6)
Direction = Rnd(0, 360)
'ptx = Array As Double(ElapsedTime, ElapsedTime)
'pty = Array As Double(Speed,Direction)
YXChart1.AddLineMultiplePoints( ElapsedTime, Array As Double(Speed,Direction), False)
YXChart1.DrawChart
End Sub
Many thanks.