Android Question mpchart setLineData index error

ShadTech

Member
Licensed User
B4X:
    mlc1.XaxisLables= selarrs("minutes_tabletmp"," ifnull(  time_column || ' - (' || CAST(ifnull(tsval, 0) AS REAL)  || ')',0)", "    op="&wrr(B4XPages.MainPage.mainqry)&"   ORDER BY time_column" )
    mlc1.YaxisLeftMaxVal = MyMax(selarrs("minutes_tabletmp","max(ifnull(tsval,0)) sm",wrs ))+3''45000
    Select     B4XPages.MainPage.pgPage4.chts.Length
        Case 1
            mlc1.Chart_1_Data = selarrdbl("minutes_tabletmp"," ifnull(tsval,0)  sm",  "   op="&wrr(B4XPages.MainPage.pgPage4.chts(0))&"        ORDER BY time_column" )
        Case 2
            mlc1.Chart_1_Data = selarrdbl("minutes_tabletmp"," ifnull(tsval,0)  sm",  "   op="&wrr(B4XPages.MainPage.pgPage4.chts(0))&"        ORDER BY time_column" )
            mlc1.Chart_2_Data = selarrdbl("minutes_tabletmp"," ifnull(tsval,0)  sm",  "    op="&wrr(B4XPages.MainPage.pgPage4.chts(1))&"        ORDER BY time_column" )
        Case 3
            mlc1.Chart_1_Data = selarrdbl("minutes_tabletmp"," ifnull(tsval,0)  sm",  "   op="&wrr(B4XPages.MainPage.pgPage4.chts(0))&"        ORDER BY time_column" )
            mlc1.Chart_2_Data = selarrdbl("minutes_tabletmp"," ifnull(tsval,0)  sm",  "    op="&wrr(B4XPages.MainPage.pgPage4.chts(1))&"        ORDER BY time_column" )
            mlc1.Chart_3_Data = selarrdbl("minutes_tabletmp"," ifnull(tsval,0)  sm",  "    op="&wrr(B4XPages.MainPage.pgPage4.chts(2))&"        ORDER BY time_column" )
           
    End Select
 
    LogColor(B4XPages.MainPage.pgPage4.chts.Length,Colors.Red)

    mlc1.setLineData(B4XPages.MainPage.pgPage4.chts.Length,selarrs("minutes_tabletmp"," ifnull(  time_column || ' - (' || CAST(ifnull(tsval, 0) AS REAL)  || ')',0)", "    op="&wrr(B4XPages.MainPage.mainqry)&"   ORDER BY time_column" ).Length)
in that code i got error in setLineData
charts i want to display are 2

the variable B4XPages.MainPage.pgPage4.chts.Length equals=2
when i have index error in setLineData
Note: the index error is in the first paramater of setLineData "numberOfCharts",
not in the second one "NumberOfEntirePerchart"
SELECT distinct ifnull( time_column || ' - (' || CAST(ifnull(tsval, 0) AS REAL) || ')',0) FROM minutes_tabletmp WHERE op=0 ORDER BY time_column
SELECT distinct max(ifnull(tsval,0)) sm FROM minutes_tabletmp WHERE time_column between '202501110000' and '202501112359'
Select ifnull(tsval,0) sm FROM minutes_tabletmp WHERE op=0 ORDER BY time_column
Select ifnull(tsval,0) sm FROM minutes_tabletmp WHERE op=1 ORDER BY time_column
2
SELECT distinct ifnull( time_column || ' - (' || CAST(ifnull(tsval, 0) AS REAL) || ')',0) FROM minutes_tabletmp WHERE op=0 ORDER BY time_column
chart_draw_graph_8 (java line: 581)
java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
at mpandroidchartwrapper.multiLineChartWrapper.setLineData(multiLineChartWrapper.java:772)
at com.BATT.chart._draw_graph_8(chart.java:581)
at com.BATT.chart._activity_create(chart.java:372)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
at com.BATT.chart.afterFirstLayout(chart.java:105)
at com.BATT.chart.access$000(chart.java:17)
at com.BATT.chart$WaitForLayout.run(chart.java:83)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
*** Service (starter) Create ***
** Service (starter) Start **
 
Last edited:
Top