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

JavaFX Area Chart not rendering properly negative values

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8u45
    • javafx
    • x86
    • windows_8

      FULL PRODUCT VERSION :
      java version "1.8.0_45"
      Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.3.9600]

      A DESCRIPTION OF THE PROBLEM :

      Example "Adding negative value" (Fig 33-7) in the docs:

      https://docs.oracle.com/javase/8/javafx/user-interface-tutorial/area-chart.htm#CIHICDIB

      does not render as shown.
      The area is always filled from the bottom of the chart to the line, which is not intended behaviour for the negative values (see the March series).

      Further description (with screenshots) can be found here:

      http://stackoverflow.com/questions/30185035/how-to-add-negative-values-to-javafx-area-chart?noredirect=1#comment48478554_30185035


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use the source code from the official docs (33-7):
      https://docs.oracle.com/javase/8/javafx/user-interface-tutorial/area-chart.htm#CIHICDIB

      and compare the generated chart with the one there.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I was expecting to get the documented chart.
      ACTUAL -
      Different chart, bad negative values rendering (March series)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.chart.AreaChart;
      import javafx.scene.chart.NumberAxis;
      import javafx.scene.chart.XYChart;
      import javafx.stage.Stage;
       
       
      public class AreaChartSample extends Application {
       
          @Override public void start(Stage stage) {
              stage.setTitle("Area Chart Sample");
              final NumberAxis xAxis = new NumberAxis(1, 31, 1);
              xAxis.setMinorTickCount(0);
              final NumberAxis yAxis = new NumberAxis(-5, 27, 5);
              yAxis.setMinorTickLength(yAxis.getTickLength());
              yAxis.setForceZeroInRange(false);
              
              final AreaChart<Number,Number> ac =
                  new AreaChart<Number,Number>(xAxis,yAxis);
              ac.setTitle("Temperature Monitoring (in Degrees C)");
       
              XYChart.Series seriesApril= new XYChart.Series();
              seriesApril.setName("April");
              seriesApril.getData().add(new XYChart.Data(0, 4));
              seriesApril.getData().add(new XYChart.Data(3, 10));
              seriesApril.getData().add(new XYChart.Data(6, 15));
              seriesApril.getData().add(new XYChart.Data(9, 8));
              seriesApril.getData().add(new XYChart.Data(12, 5));
              seriesApril.getData().add(new XYChart.Data(15, 18));
              seriesApril.getData().add(new XYChart.Data(18, 15));
              seriesApril.getData().add(new XYChart.Data(21, 13));
              seriesApril.getData().add(new XYChart.Data(24, 19));
              seriesApril.getData().add(new XYChart.Data(27, 21));
              seriesApril.getData().add(new XYChart.Data(30, 21));
              
              XYChart.Series seriesMay = new XYChart.Series();
              seriesMay.setName("May");
              seriesMay.getData().add(new XYChart.Data(0, 20));
              seriesMay.getData().add(new XYChart.Data(3, 15));
              seriesMay.getData().add(new XYChart.Data(6, 13));
              seriesMay.getData().add(new XYChart.Data(9, 12));
              seriesMay.getData().add(new XYChart.Data(12, 14));
              seriesMay.getData().add(new XYChart.Data(15, 18));
              seriesMay.getData().add(new XYChart.Data(18, 25));
              seriesMay.getData().add(new XYChart.Data(21, 25));
              seriesMay.getData().add(new XYChart.Data(24, 23));
              seriesMay.getData().add(new XYChart.Data(27, 26));
              seriesMay.getData().add(new XYChart.Data(31, 26));
              
              XYChart.Series seriesMarch = new XYChart.Series();
              seriesMarch.setName("March");
              seriesMarch.getData().add(new XYChart.Data(0, -2));
              seriesMarch.getData().add(new XYChart.Data(3, -4));
              seriesMarch.getData().add(new XYChart.Data(6, 0));
              seriesMarch.getData().add(new XYChart.Data(9, 5));
              seriesMarch.getData().add(new XYChart.Data(12, -4));
              seriesMarch.getData().add(new XYChart.Data(15, 6));
              seriesMarch.getData().add(new XYChart.Data(18, 8));
              seriesMarch.getData().add(new XYChart.Data(21, 14));
              seriesMarch.getData().add(new XYChart.Data(24, 4));
              seriesMarch.getData().add(new XYChart.Data(27, 6));
              seriesMarch.getData().add(new XYChart.Data(31, 6));
              
              
              Scene scene = new Scene(ac,800,600);
              ac.getData().addAll(seriesMarch, seriesApril, seriesMay);
              stage.setScene(scene);
              stage.show();
          }
       
          public static void main(String[] args) {
              launch(args);
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      none that I could find

            jgiles Jonathan Giles
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: