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

LineChart axis does not show all its tick labels when it's manually ranged

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8u20
    • 8u20
    • javafx
    • Java 8u20 b11 Linux

      I have a chart that manually sets the bounds of its NumberAxis classes. This has been working fine until some change in 8u20. Now the y axis will often only render 2 of the 10 tick labels that it should.

      To reproduce run the provided test class and you will observe that the y axis does not show all of its tick labels. If you change the code to auto range by taking out the manual bounds in the constructor then all labels are shown.

      ****************************************** Test Class *******************************************************
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.chart.LineChart;
      import javafx.scene.chart.NumberAxis;
      import javafx.scene.chart.XYChart.Data;
      import javafx.scene.chart.XYChart.Series;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class ChartTest extends Application {

         @Override public void start(final Stage primaryStage) throws Exception {

            primaryStage.centerOnScreen();
            primaryStage.setHeight(350);
            primaryStage.setWidth(500);
            
            NumberAxis xAxis = new NumberAxis(3.5, 9.5, 1);
            NumberAxis yAxis = new NumberAxis(1.505, 1.653, (1.653 - 1.505) / 10d );
            
            LineChart<Number, Number> chart = new LineChart<>(xAxis, yAxis);
            Series<Number, Number> series = new Series<>();
            series.getData().add(new Data<Number, Number>(4, 1.515));
            series.getData().add(new Data<Number, Number>(9, 1.643));
            chart.getData().add( series );
            
            primaryStage.setScene( new Scene( new StackPane(chart)) );

            primaryStage.show();

         }

         public static void main(String[] args) throws Exception {
            launch(args);
         }

      }

            msladecek Martin Sládeček
            csmithjfx Charles Smith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: