B4J Question [SOLVED]xChart error...

rbghongade

Active Member
Licensed User
Longtime User
Dear Klaus,
Thank you for your hard work and sharing. I seem to have stumbled across a problem.(Maybe I missed something!)
In the code, I have initialized the YX chart and in the PLOT button sub the values are calculated and plotting is done. Now the problem is that in the init sub I am forced to plot at least a single point otherwise I get the following error:
Error log:
java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1020)
    at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:657)
    at java.util.ArrayList.get(ArrayList.java:433)
    at anywheresoftware.b4a.objects.collections.List.Get(List.java:105)
    at b4j.example.xchart._drawyxlines(xchart.java:3867)
    at b4j.example.xchart._drawchart(xchart.java:2330)
    at b4j.example.xchart$ResumableSub_Base_Resize.resume(xchart.java:768)
    at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1018)
    ... 7 more
I tried to plot a single point in init sub and then in PLOT sub, even if I use xChart1.ClearData or xChart1.ClearPoints the initial point is not cleared and I get the following:
plot.png

The complete code is attached in zip file.
Since I want a continuous plot I have to use DrawLine argument in xChart1.AddYXLine2() method.
Hope I am not bothering you too much!
PS: I am using B4J 8.10 and xChart v4.5 (but it still shows v4.40 in library list!)
 

Attachments

  • DIFFERENTIAL_AMPLIFIER.zip
    3.4 KB · Views: 213
Last edited:
Top