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

[Charts] Support "missing value": It's not possible to add data points with no value ('null') to a LineChart



    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 7u7
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:
    • Environment:

      Windows7 & 8, eclipse 4.3.1 RCP with SWT, Java JDK 8


      In statistical data environment where you use line charts to display timeseries it is quite usual that timeseries contain 'empty' values for a specific timestamp.This is called a missing value and may not be changed to the value 0.0, because otherwise one could not distinguish between a real double value 0.0 and a missing value.
      However it is not possible to use a LineChart for that purpose. See following simple code snippet:
        VBox root = new VBox();
        CategoryAxis xAxis = new CategoryAxis();
        NumberAxis yAxis = new NumberAxis();
        XYChart.Series<String, Double> values = new XYChart.Series<String, Double>();
        values.getData().add(new Data<String, Double>("2000-01-01", 13.2));
        values.getData().add(new Data<String, Double>("2000-01-02", null));
        values.getData().add(new Data<String, Double>("2000-01-03", 14.1));
        values.getData().add(new Data<String, Double>("2000-01-04", 11.6));
        values.getData().add(new Data<String, Double>("2000-01-05", 0.0));
        values.getData().add(new Data<String, Double>("2000-01-06", 9.82));
        XYChart.Series<String, Double> series = values;
        LineChart lineChart = new LineChart(xAxis, yAxis);
        Scene scene = new Scene(root);

      At initialization time a NPE is thrown because in the method ValueAxis.invalidateRange() an unchecked attempt is made to access the value:
        ValueAxis class, Line 443: dataValue.doubleValue()
      Unfortunately there seems to be no way to circumvent this issue.

      You might argue that's not a bug, but a feature request. We don't agree. Everybody dealing with real world timeseries data will sooner or later stumble over this issue and get stuck. At least for us who wanted to migrate some of our JFreeChart charts to JavaFX LineChart, it was a show stopper.




            Unassigned Unassigned
            duke J. Duke (Inactive)
            0 Vote for this issue
            2 Start watching this issue