'***** move LD and G to Globals, where they will retain their values between Sub calls *****
Sub Globals
...
Dim LD As LineData
Dim G As Graph
'***** split GraphDraw into two separate Subs *****
Sub GraphInit
Dim LD As LineData
LD.Initialize
LD.Target = PanelChart
Charts.AddLineColor(LD, Colors.Red) 'First line color
Charts.AddLineColor(LD, Colors.Blue) 'Second line color
Dim G As Graph
G.Initialize
G.Title = "2 Lines Chart)"
G.XAxis = "Degrees"
G.YAxis = "Values"
G.YStart = 0
G.YEnd = 1000
G.YInterval = 100
G.AxisColor = Colors.Black
End Sub
Sub GraphAdd
'In this case we are adding an array of two values. One for each line.
'Make sure to create an array for each point. You cannot reuse a single array for all points.
Charts.AddLineMultiplePoints(LD, i, Array As Float(Val, Val1), i Mod 90 = 0)
Charts.DrawLineChart(G, LD, Colors.White)
End Sub
'***** call GraphInit when the Activity is started *****
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
GraphInit
Timer1.Initialize("Timer1",1000)
'***** call GraphAdd each timer tick *****
Sub TImer1_Tick
Val = Rnd(200,1000)
Val1 = Rnd(200,1000)
LabelValue.Text = "Random Value : " & Val
i = i + 1
GraphAdd
End Sub