I have this table tblHistory:
Date | Sales
08/02/2014 | 55
08/14/2014 | 60
...
I'm doing this, but it isn't working:
Activity.LoadLayout("Chart")
If FirstTime Then
End If
' Initialze the panel to display the lines chart
pnlLines.Initialize("pnlLines")
Activity.AddView(pnlLines, 10%x, 10%y, 80%x, 80%y)
' Initialize the line data
Dim LD As LineData
LD.Initialize
LD.Target = pnlLines
' Set the line colors
Charts.AddLineColor(LD, Colors.Red) 'First line color
' Add the items.
Dim i As Int
Dim Curs As Cursor
Curs = Main.SQL1.ExecQuery("SELECT date,sales FROM tblHistory")
For i = 0 To Curs.RowCount - 1
Curs.Position = i
Dim Sale0 As Double
Dim Sale1 As Float
Sale0 = Curs.GetDouble("sales") ' gets the sales value
Sale1 = Sale0 ' converts ouble to Float
Charts.AddLinePoint(LD, Curs.GetString("date"), Array As Float(Sale1), i Mod 90 = 0)
Next
I'm getting this error:
b4a.example.charts:_addlinepoint, [anywheresoftware.b4a.BA@b4de74a0, [Canvas=anywheresoftware.b4a.objects.drawable.CanvasWrapper@b4e0d5e8, Target=(BALayout): Left=32, Top=40, Width=256, Height=325, LinesColors=(ArrayList) [-65536]
, Points=(List) Not initialized, IsInitialized=true], 08/08/2014, [F@b4d08840, true]
Error occurred on line: 164 (charts)
java.lang.IllegalArgumentException: argument 4 should have type float, got float[]
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at b4a.example.chart.afterFirstLayout(chart.java:98)
at b4a.example.chart.access$100(chart.java:16)
at b4a.example.chart$WaitForLayout.run(chart.java:76)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
** Activity (chart) Resume **