B4J Question [Solved] jCharts with OpenJDK 11 - can't display negative values on Stacked Bar Chart

Discussion in 'B4J Questions' started by Chris2, May 30, 2019.

  1. Chris2

    Chris2 Member Licensed User

    I can't get the Stacked Bar Charts of jCharts to display negative values when running with java 11 (OpenJDK 11). It works OK under Java 8.

    To test it I've gone back to the original examples posted by Informatix (Charts2 from https://www.b4x.com/android/forum/threads/jcharts.71975/).

    I changed a couple of the values in the XYSeries to be negative;
    Dim Series2 As XYSeries
    Array As XYSeries(Series1, Series2))
    and ran it first with with the javac.exe in Tools>Configure Paths set to Java 8, then to openJDK 11. The screen shots attached show the output, with Java 8 showing the negative values correctly (right image) but Open Java 11 missing them off (left image).

    Am I missing something here, or could this be an issue in the jCharts library or OpenJFX itself?
    jCharts-StackedBar-OpenJDK11.png jCharts-StackedBar-Java8.png
    Last edited: May 30, 2019
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. Chris2

    Chris2 Member Licensed User

    Hi Erel
    Yes it does, you can set AutoRanging false and manually set the lower bound of the yaxis.
    I'd already seen that stackoverflow page and have had a play with setting AutoRanging to false & manually setting the upper & lower bounds, but it makes no difference to this issue.

    Interestingly, even with Open Java 11, the standard bar chart (not stacked), and the line chart will display negative numbers correctly. It seems to be an issue with the Stacked Bar Chart only.
  4. Chris2

    Chris2 Member Licensed User

    The chart yaxis seems to autoscale itself OK, it just doesn't draw the bars.
  5. Chris2

    Chris2 Member Licensed User

    After digging around I've found this - https://github.com/javafxports/openjdk-jfx/issues/477, which seems to suggest that someone else has spotted the same issue and reported it as a bug in open javafx.
    I'm wondering if I can use in-line Java to correct the issue with the corrected code in that post
    // ok
    String, Number> barChart2 = new StackedBarChart<String, Number>(xAxis, yAxis){
          @Override protected void seriesChanged(ListChangeListener.Change<? extends Series> c) {
    I am a bit out of my depth here though and don't know Java at all.
    Should I be able use in-line java to correct this issue? If so, can someone please suggest how?

    I've looked at the in-line java examples in the forums but can't figure it out. At present I've got
    #If JAVA
           import javafx.scene.chart.StackedBarChart;
          @Override protected void seriesChanged(ListChangeListener.Change<? extends Series> c) ;
    #End If
    with the following in the sub that builds the chart
    Dim jo As JavaObject = Me
    But I get the following error when compiling;
    Compiling generated Java code. Error
    B4J line: 282
    End Sub
    src\b4j\example\main.java:759: error: package ListChangeListener does not exist
    @override protected void seriesChanged(ListChangeListener.Change<? extends Series> c); //{}
    1 error
  6. Informatix

    Informatix Expert Licensed User

    It's easy to do the changes on my side so here's the fix. I can't test it so please report whether the problem is solved.

    Attached Files:

    Jorge M A, Chris2 and inakigarm like this.
  7. Chris2

    Chris2 Member Licensed User

    Yes, the StackedBarChart is OK now with negative values using OpenJava11 or Java 8...
    SBC-Java8.png SBC-OpenJava11.png
    Informatix likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice