Android Question Charts Library

Fillmore

Member
Licensed User
Longtime User
Hi,

I try to use the Johan Charts Library.



I have an error on this line : mrc1.setRadarData(2,8)



"Error occurred on line: 1993 (Main)
java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
at mpandroidchartwrapper.radarChartWrapper.setRadarData(radarChartWrapper.java:272)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:755)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:345)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:19)
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1677)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)"

I don't understand what is wrong...

If somebedy can help me..

Thanks a lot.

FM




B4X:
Sub affiche_stats()
    
    
    PnlStats.Visible=True
    PnlStats.BringToFront
    
    
    
    mrc1.ChartDescription = "Axes de travail"
    mrc1.ChartDescriptionColor = Colors.White
    mrc1.ChartDescriptionTextSize = 12
    
    '    RIGHT_OF_CHART, RIGHT_OF_CHART_CENTER, RIGHT_OF_CHART_INSIDE,
    '    LEFT_OF_CHART, LEFT_OF_CHART_CENTER, LEFT_OF_CHART_INSIDE,
    '    BELOW_CHART_LEFT, BELOW_CHART_RIGHT, BELOW_CHART_CENTER,

    '   CIRCLE, SQUARE, LINE

    mrc1.LegendShapeSize = 15.0
    mrc1.setTheLegendPositionAndForm("BELOW_CHART_CENTER","CIRCLE")
    mrc1.TheLegendColor = Colors.yellow
    mrc1.TheLegendTextSize = 10.0
    mrc1.LegendText = Array As String("jOUEUR 1", "jOUEUR 2")', "2013", "2014", "2015")


    mrc1.ValueTextColor = Colors.Black
    mrc1.ValueTextSize = 12.0


    '    mrc1.YaxisMinVal = -400          'commented it out so that the scale will be set automatically
'    mrc1.YaxisMaxVal = 1800           'commented it out so that the scale will be set automatically
    mrc1.YaxisTextSize = 10.0
    mrc1.YaxisTextColor = Colors.White
    
    mrc1.Chart_1_Data = Array As Float(ssp1,ssm1,srp1,srm1,srvp1,srvm1,smp1,smpv1)', -380.2, 345.0)
    mrc1.Chart_2_Data = Array As Float(ssp2,ssm2,srp2,srm2,srvp2,srvm2,smp2,smpv2)' 1010.8, 836.4)
    'mrc1.Chart_3_Data = Array As Float(836.4, 1010.8, 985.6, 676.5, 1100.0, 730.0, 960.0, 450.0, 750.0, 1200)
    'mrc1.Chart_4_Data = Array As Float(345.0, -380.2, -250.4, 849.7, 445.0, 600.5, -300.0, 50.0, 550.0, 1100.0)
    'mrc1.Chart_5_Data = Array As Float(1050.0, 850.0, 650.0, 1400.0, 760.8, -450.7, 934.9, 576.2, 896.4, -380.6)
    
    mrc1.XaxisTextColor = Colors.Cyan
    mrc1.XaxisTextSize = 12.0
    
    mrc1.ValueTextSize = 10.0
    mrc1.ValueTextColor = Colors.Yellow
    mrc1.DrawGraphValues = False
    
    '   Maximum 5 colors to be passed ==> must be at least equal to the number of data sets that are passed i.e maximum 5
    '   If you pass only for eg 2 data sets then at least 2 colors need to be passed
    '   If more that 2 colors are passed with for eg only 2 data sets then only the first 2 colors will be used in the color array
    mrc1.GraphLineColor = Array As Int(Colors.Green, Colors.Red)', Colors.Blue, Colors.Green, Colors.Cyan)
    mrc1.GraphLineWidth = 2.0
    mrc1.DrawFilled = True
    
    mrc1.WebConcentricColor = Colors.Green
    mrc1.WebRadialColor = Colors.Red
    mrc1.WebAlpha = 200
    mrc1.ConcentricLineWidth = 1.5
    mrc1.RadialLineWidth = 0.75
    mrc1.DrawWeb = True
    
    mrc1.XaxisLables = Array As String("Servir +", "Servir mieux", "Retourner +", "Retourner mieux", "Renvoyer +", "Renvoyer mieux", "Marquer +", "Marquer + vite")', "Distribution OH", "EBITDA")
    
    '   the number of charts to be drawn (maximum 5, in this case 3)
    '   the number of x-axis values per chart (in this case 10 = number of elements in the array passed to mrc1.XaxisLables)
    mrc1.setRadarData(2,8)
    
    
End Sub
 

Fillmore

Member
Licensed User
Longtime User
Thank you Peter,

It seems not to be the problem. (I tried it)

I have 2 charts and 8 axes. So SetRadarData is 2,8.
No ?
 
Upvote 0

ac9ts

Active Member
Licensed User
Longtime User
Arrays are Base 0. Length=2 would allow index 0 and 1.
 
Last edited:
Upvote 0

Fillmore

Member
Licensed User
Longtime User
Arrays are Base 0. Length=2 would allow index 0 and 1.

Yes I know that.

But 2 is the number of charts. I think it's the right method.

And set it to 1 will not increase the size of the array. I will stay out of bounds....

Thank you for your answer.

FM
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Must I install the Java Library ?
no. This is the source of the library. Written in java. If someone want to extends it he need this source....
 
Upvote 0

Fillmore

Member
Licensed User
Longtime User
Hi,

Ok, it works but I have to let all the charts "open" and just set the value to (2,8)

Like This :

B4X:
mrc1.ChartDescription = "Axes de travail"
    mrc1.ChartDescriptionColor = Colors.White
    mrc1.ChartDescriptionTextSize = 12
    
    '    RIGHT_OF_CHART, RIGHT_OF_CHART_CENTER, RIGHT_OF_CHART_INSIDE,
    '    LEFT_OF_CHART, LEFT_OF_CHART_CENTER, LEFT_OF_CHART_INSIDE,
    '    BELOW_CHART_LEFT, BELOW_CHART_RIGHT, BELOW_CHART_CENTER,

    '   CIRCLE, SQUARE, LINE

    mrc1.LegendShapeSize = 15.0
    mrc1.setTheLegendPositionAndForm("BELOW_CHART_CENTER","CIRCLE")
    mrc1.TheLegendColor = Colors.yellow
    mrc1.TheLegendTextSize = 10.0
    mrc1.LegendText = Array As String("jOUEUR 1", "jOUEUR 2", "2013", "2014", "2015")


    mrc1.ValueTextColor = Colors.Black
    mrc1.ValueTextSize = 12.0


    '    mrc1.YaxisMinVal = -400          'commented it out so that the scale will be set automatically
'    mrc1.YaxisMaxVal = 1800           'commented it out so that the scale will be set automatically
    mrc1.YaxisTextSize = 10.0
    mrc1.YaxisTextColor = Colors.White
    
    mrc1.Chart_1_Data = Array As Float(ssp1,ssm1,srp1,srm1,srvp1,srvm1,smp1,smpv1, -380.2, 345.0)
    mrc1.Chart_2_Data = Array As Float(ssp2,ssm2,srp2,srm2,srvp2,srvm2,smp2,smpv2, 1010.8, 836.4)
    mrc1.Chart_3_Data = Array As Float(836.4, 1010.8, 985.6, 676.5, 1100.0, 730.0, 960.0, 450.0, 750.0, 1200)
    mrc1.Chart_4_Data = Array As Float(345.0, -380.2, -250.4, 849.7, 445.0, 600.5, -300.0, 50.0, 550.0, 1100.0)
    mrc1.Chart_5_Data = Array As Float(1050.0, 850.0, 650.0, 1400.0, 760.8, -450.7, 934.9, 576.2, 896.4, -380.6)
    
    mrc1.XaxisTextColor = Colors.Cyan
    mrc1.XaxisTextSize = 12.0
    
    mrc1.ValueTextSize = 10.0
    mrc1.ValueTextColor = Colors.Yellow
    mrc1.DrawGraphValues = False
    
    '   Maximum 5 colors to be passed ==> must be at least equal to the number of data sets that are passed i.e maximum 5
    '   If you pass only for eg 2 data sets then at least 2 colors need to be passed
    '   If more that 2 colors are passed with for eg only 2 data sets then only the first 2 colors will be used in the color array
    mrc1.GraphLineColor = Array As Int(Colors.Green, Colors.Red)', Colors.Blue, Colors.Green, Colors.Cyan)
    mrc1.GraphLineWidth = 2.0
    mrc1.DrawFilled = True
    
    mrc1.WebConcentricColor = Colors.Green
    mrc1.WebRadialColor = Colors.Red
    mrc1.WebAlpha = 200
    mrc1.ConcentricLineWidth = 1.5
    mrc1.RadialLineWidth = 0.75
    mrc1.DrawWeb = True
    
    mrc1.XaxisLables = Array As String("Servir +", "Servir mieux", "Retourner +", "Retourner mieux", "Renvoyer +", "Renvoyer mieux", "Marquer +", "Marquer + vite", "Distribution OH", "EBITDA")
    
    '   the number of charts to be drawn (maximum 5, in this case 3)
    '   the number of x-axis values per chart (in this case 10 = number of elements in the array passed to mrc1.XaxisLables)
    mrc1.setRadarData(2,8)


And I don't show the 9 and 10 labels and the graph 3,4,5.
It's enough to make me happy !

Thank you Johan for your work.


Merry Christmass !

FM
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Hi,

I try to use the Johan Charts Library.



I have an error on this line : mrc1.setRadarData(2,8)



"Error occurred on line: 1993 (Main)
java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
at mpandroidchartwrapper.radarChartWrapper.setRadarData(radarChartWrapper.java:272)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:755)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:345)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:19)
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1677)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)"

I don't understand what is wrong...

If somebedy can help me..

Thanks a lot.

FM




B4X:
Sub affiche_stats()
   
   
    PnlStats.Visible=True
    PnlStats.BringToFront
   
   
   
    mrc1.ChartDescription = "Axes de travail"
    mrc1.ChartDescriptionColor = Colors.White
    mrc1.ChartDescriptionTextSize = 12
   
    '    RIGHT_OF_CHART, RIGHT_OF_CHART_CENTER, RIGHT_OF_CHART_INSIDE,
    '    LEFT_OF_CHART, LEFT_OF_CHART_CENTER, LEFT_OF_CHART_INSIDE,
    '    BELOW_CHART_LEFT, BELOW_CHART_RIGHT, BELOW_CHART_CENTER,

    '   CIRCLE, SQUARE, LINE

    mrc1.LegendShapeSize = 15.0
    mrc1.setTheLegendPositionAndForm("BELOW_CHART_CENTER","CIRCLE")
    mrc1.TheLegendColor = Colors.yellow
    mrc1.TheLegendTextSize = 10.0
    mrc1.LegendText = Array As String("jOUEUR 1", "jOUEUR 2")', "2013", "2014", "2015")


    mrc1.ValueTextColor = Colors.Black
    mrc1.ValueTextSize = 12.0


    '    mrc1.YaxisMinVal = -400          'commented it out so that the scale will be set automatically
'    mrc1.YaxisMaxVal = 1800           'commented it out so that the scale will be set automatically
    mrc1.YaxisTextSize = 10.0
    mrc1.YaxisTextColor = Colors.White
   
    mrc1.Chart_1_Data = Array As Float(ssp1,ssm1,srp1,srm1,srvp1,srvm1,smp1,smpv1)', -380.2, 345.0)
    mrc1.Chart_2_Data = Array As Float(ssp2,ssm2,srp2,srm2,srvp2,srvm2,smp2,smpv2)' 1010.8, 836.4)
    'mrc1.Chart_3_Data = Array As Float(836.4, 1010.8, 985.6, 676.5, 1100.0, 730.0, 960.0, 450.0, 750.0, 1200)
    'mrc1.Chart_4_Data = Array As Float(345.0, -380.2, -250.4, 849.7, 445.0, 600.5, -300.0, 50.0, 550.0, 1100.0)
    'mrc1.Chart_5_Data = Array As Float(1050.0, 850.0, 650.0, 1400.0, 760.8, -450.7, 934.9, 576.2, 896.4, -380.6)
   
    mrc1.XaxisTextColor = Colors.Cyan
    mrc1.XaxisTextSize = 12.0
   
    mrc1.ValueTextSize = 10.0
    mrc1.ValueTextColor = Colors.Yellow
    mrc1.DrawGraphValues = False
   
    '   Maximum 5 colors to be passed ==> must be at least equal to the number of data sets that are passed i.e maximum 5
    '   If you pass only for eg 2 data sets then at least 2 colors need to be passed
    '   If more that 2 colors are passed with for eg only 2 data sets then only the first 2 colors will be used in the color array
    mrc1.GraphLineColor = Array As Int(Colors.Green, Colors.Red)', Colors.Blue, Colors.Green, Colors.Cyan)
    mrc1.GraphLineWidth = 2.0
    mrc1.DrawFilled = True
   
    mrc1.WebConcentricColor = Colors.Green
    mrc1.WebRadialColor = Colors.Red
    mrc1.WebAlpha = 200
    mrc1.ConcentricLineWidth = 1.5
    mrc1.RadialLineWidth = 0.75
    mrc1.DrawWeb = True
   
    mrc1.XaxisLables = Array As String("Servir +", "Servir mieux", "Retourner +", "Retourner mieux", "Renvoyer +", "Renvoyer mieux", "Marquer +", "Marquer + vite")', "Distribution OH", "EBITDA")
   
    '   the number of charts to be drawn (maximum 5, in this case 3)
    '   the number of x-axis values per chart (in this case 10 = number of elements in the array passed to mrc1.XaxisLables)
    mrc1.setRadarData(2,8)
   
   
End Sub
See if V1.09 sorts out the issue that you have raised:

https://www.b4x.com/android/forum/t...y-files-in-post-322.58017/page-17#post-553896
 
Upvote 0
Top