Hi, i tryed to draw a graph with a different sets of values. They are selected from a spinner control. For the first and second selection (no matter what value is selected) everything works well, but when i try to chose another value, my app crashed. The code is:
What am I doing wrong? Ty!
B4X:
Sub CreateGraph(Tip As Int)
Dim p As Panel
p.Initialize("")
pnl2Lines.Initialize("pnl2Lines")
p.AddView(pnl2Lines, 0, 0, 600%x, 100%y - 200dip)
HView1.Panel.Initialize("controls")
HView1.Panel.AddView(p,0,0,600%x,100%y - 200dip)
Dim LD As LineData
LD.Initialize
LD.Target = pnl2Lines
Charts.AddLineColor(LD, Colors.Red) 'consum
Charts.AddLineColor(LD, Colors.Green) 'productie
Charts.AddLineColor(LD, Colors.Magenta) 'productie
For i = 0 To NrValori Step 1
If Tip = 0 Then
Charts.AddLineMultiplePoints(LD, Valori(i).DATA, Array As Float(Valori(i).CONSUM/1000, Valori(i).PRODUCTIE/1000, Valori(i).CARBUNI/1000), i Mod 30 = 0)
Else If Tip = 1 Then
Charts.AddLineMultiplePoints(LD, Valori(i).DATA, Array As Float(Valori(i).CONSUM/1000, Valori(i).PRODUCTIE/1000, Valori(i).GAZE/1000), i Mod 30 = 0)
Else If Tip = 2 Then
Charts.AddLineMultiplePoints(LD, Valori(i).DATA, Array As Float(Valori(i).CONSUM/1000, Valori(i).PRODUCTIE/1000, Valori(i).APE/1000), i Mod 30 = 0)
Else If Tip = 3 Then
Charts.AddLineMultiplePoints(LD, Valori(i).DATA, Array As Float(Valori(i).CONSUM/1000, Valori(i).PRODUCTIE/1000, Valori(i).NUCLEAR/1000), i Mod 30 = 0)
Else If Tip = 4 Then
Charts.AddLineMultiplePoints(LD, Valori(i).DATA, Array As Float(Valori(i).CONSUM/1000, Valori(i).PRODUCTIE/1000, Valori(i).EOLIAN/1000), i Mod 30 = 0)
End If
Next
Dim G As Graph
G.Initialize
G.Title = "Grafic Productie / Consum"
G.YAxis = "GW"
G.YStart = -1
G.YEnd = 10
G.YInterval = 1
G.AxisColor = Colors.Black
Charts.DrawLineChart(G, LD, Colors.White)
End Sub
Sub Combo_ItemClick (Position As Int, Value As Object)
CreateGraph(Position)
End Sub
What am I doing wrong? Ty!