-
Bug
-
Resolution: Fixed
-
P4
-
8u20
-
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);
}
}
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);
}
}
- duplicates
-
JDK-8092997 [XYChart] when labels rotated, free space is estimated icorrectly, when decision about label hiding is done.
- Closed
- relates to
-
JDK-8093803 [Axis] provide better default choice for fractional part of numbers
- Resolved
-
JDK-8163486 NumberAxis: inaccurate rendering of ticks when tick unit is low
- Resolved