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

LineChart - Setting forceZeroInRangeProperty of NumberAxis to false doesn't work for negative values

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8u20
    • 8, 8u20
    • javafx
    • None
    • Windows 7, jdk 8 (build 117), Ef(x)clipse 4.2.2

      For a NumberAxis in a LineChart, calling: forceZeroInRangeProperty().set(false) doesn' t work when all the values on the Axis are negative. The zero line is still displayed, forcing the chart to be pushed down, so the chart details are not shown.

      A test application to demonstrate the problem:

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.chart.LineChart;
      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("Line Chart - negative Y Axis");
              final NumberAxis xAxis = new NumberAxis(1, 31, 1);
              final NumberAxis yAxis = new NumberAxis();
              final LineChart<Number,Number> ac =
                  new LineChart<Number,Number>(xAxis,yAxis);
              ac.setTitle("Test : Line chart - Zero line is shown ");
              
              yAxis.forceZeroInRangeProperty().set(false);
       
              XYChart.Series<Number, Number> seriesTest= new XYChart.Series<Number,Number>();
              seriesTest.getData().add(new XYChart.Data<Number,Number>(1, -1400));
              seriesTest.getData().add(new XYChart.Data<Number,Number>(3, -1410));
              seriesTest.getData().add(new XYChart.Data<Number,Number>(6, -1415));
              seriesTest.getData().add(new XYChart.Data<Number,Number>(9, -1478));
              seriesTest.getData().add(new XYChart.Data<Number,Number>(12, -1405));
              seriesTest.getData().add(new XYChart.Data<Number,Number>(15, -1438));
              seriesTest.getData().add(new XYChart.Data<Number,Number>(18, -1415));
              seriesTest.getData().add(new XYChart.Data<Number,Number>(21, -1413));
              seriesTest.getData().add(new XYChart.Data<Number,Number>(24, -1449));
              seriesTest.getData().add(new XYChart.Data<Number,Number>(27, -1421));
              seriesTest.getData().add(new XYChart.Data<Number,Number>(30, -1422));
              
              
              Scene scene = new Scene(ac,800,600);
              ac.getData().add(seriesTest);
              stage.setScene(scene);
              stage.show();
          }
       
          public static void main(String[] args) {
              launch(args);
          }

      }

            msladecek Martin Sládeček
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: