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);
}
}
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);
}
}
- duplicates
-
JDK-8092698 ValueAxis::invalidateRange uses Double.MIN_VALUE instead of -Double.MAX_VALUE
- Closed