Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8115743

StackedBarChart does not work with autoranging category axis

XMLWordPrintable

        BarChart and LineChart support autoranging axis, e.g. provide "new CategoryAxis()" to chart constructor. The same does not work with StackedBarChart. An attempt to do this will produce the following NPE:

        Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:399)
        at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
        at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
        at java.lang.Thread.run(Unknown Source)
        Caused by: java.lang.NullPointerException
        at java.util.ArrayList.addAll(Unknown Source)
        at javafx.scene.chart.StackedBarChart.updateAxisRange(StackedBarChart.java:360)
        at javafx.scene.chart.XYChart.layoutChartChildren(XYChart.java:619)
        at javafx.scene.chart.Chart$1.layoutChildren(Chart.java:81)
        at javafx.scene.Parent.layout(Parent.java:999)
        at javafx.scene.Parent.layout(Parent.java:1009)
        at javafx.scene.Parent.layout(Parent.java:1009)
        at javafx.scene.Scene.layoutDirtyRoots(Scene.java:492)
        at javafx.scene.Scene.doLayoutPass(Scene.java:465)
        at javafx.scene.Scene.preferredSize(Scene.java:1233)
        at javafx.scene.Scene.impl_initPeer(Scene.java:630)
        at javafx.stage.Window$10.invalidated(Window.java:701)
        at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:129)
        at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:163)
        at javafx.stage.Window.setShowing(Window.java:768)
        at javafx.stage.Window.show(Window.java:783)
        at javafx.stage.Stage.show(Stage.java:207)
        at mint.javafx.dashboard.chart.ReportTest.start(ReportTest.java:43)
        at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:315)
        at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:174)
        at com.sun.javafx.application.PlatformImpl$3.run(PlatformImpl.java:141)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
        at com.sun.glass.ui.win.WinApplication$2$1.run(WinApplication.java:62)
        ... 1 more

        Example code: simply use the stacked barchart example from ensemble, with

              CategoryAxis xAxis = new CategoryAxis();

        instead of

              CategoryAxis xAxis = CategoryAxisBuilder.create()
                  .categories(FXCollections.<String>observableArrayList(years)).build();

              psomashe Parvathi Somashekar (Inactive)
              wlehmann Werner Lehmann
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported: