Details
Description
Run sample program. Chart starts out in auto ranging mode. Click the '1-5' button. The y axis changes to show custom parameters. Click the 'auto' button. The y axis doesn't draw itself correctly. The range should go back to 0 - 5.5 but instead it is 0 - 5.0. The chart itself is correct but the axis is drawn incorrectly. If you resize the window, the axis is then redrawn correctly.
Sample program:
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class ChartTest extends Application {
public void start(Stage primaryStage) throws Exception {
ObservableList<XYChart.Data<Number, Number>> data = FXCollections.observableArrayList();
data.add(new XYChart.Data<>(1, 1));
data.add(new XYChart.Data<>(2, 2));
data.add(new XYChart.Data<>(3, 3));
data.add(new XYChart.Data<>(4, 4));
data.add(new XYChart.Data<>(5, 5));
ObservableList<XYChart.Series<Number, Number>> series = FXCollections.observableArrayList();
series.add(new XYChart.Series<>("One", data));
NumberAxis xAxis = new NumberAxis("X", 0, 10, 1);
NumberAxis yAxis = new NumberAxis("Y", 0, 10, 1);
xAxis.setAutoRanging(true);
yAxis.setAutoRanging(true);
LineChart chart = new LineChart<>(xAxis, yAxis, series);
Button autoButton = new Button("Auto");
Button customButton = new Button("1-5");
HBox buttonBox = new HBox(10, autoButton, customButton);
BorderPane bp = new BorderPane(chart);
bp.setTop(buttonBox);
autoButton.setOnAction(e -> yAxis.setAutoRanging(true));
customButton.setOnAction(e -> {
yAxis.setAutoRanging(false);
yAxis.setLowerBound(0);
yAxis.setUpperBound(5);
yAxis.setTickUnit(1);
yAxis.setMinorTickCount(5);
});
Scene scene = new Scene(bp);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Sample program:
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class ChartTest extends Application {
public void start(Stage primaryStage) throws Exception {
ObservableList<XYChart.Data<Number, Number>> data = FXCollections.observableArrayList();
data.add(new XYChart.Data<>(1, 1));
data.add(new XYChart.Data<>(2, 2));
data.add(new XYChart.Data<>(3, 3));
data.add(new XYChart.Data<>(4, 4));
data.add(new XYChart.Data<>(5, 5));
ObservableList<XYChart.Series<Number, Number>> series = FXCollections.observableArrayList();
series.add(new XYChart.Series<>("One", data));
NumberAxis xAxis = new NumberAxis("X", 0, 10, 1);
NumberAxis yAxis = new NumberAxis("Y", 0, 10, 1);
xAxis.setAutoRanging(true);
yAxis.setAutoRanging(true);
LineChart chart = new LineChart<>(xAxis, yAxis, series);
Button autoButton = new Button("Auto");
Button customButton = new Button("1-5");
HBox buttonBox = new HBox(10, autoButton, customButton);
BorderPane bp = new BorderPane(chart);
bp.setTop(buttonBox);
autoButton.setOnAction(e -> yAxis.setAutoRanging(true));
customButton.setOnAction(e -> {
yAxis.setAutoRanging(false);
yAxis.setLowerBound(0);
yAxis.setUpperBound(5);
yAxis.setTickUnit(1);
yAxis.setMinorTickCount(5);
});
Scene scene = new Scene(bp);
primaryStage.setScene(scene);
primaryStage.show();
}
}