Look at the attached movie.
I set Xaxis to be at the left, and Yaxis to be at the bottom, and got the confused chart. If it is not a permissed action, it must at least not to affect.
Code:
import java.util.Arrays;
import java.util.Comparator;
import java.util.Random;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Side;
import javafx.scene.Scene;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class JavaCharts extends Application {
public static void main(String[] args) {
launch(args);
}
NumberAxis axis1 = new NumberAxis(0, 100, 10);
NumberAxis axis2 = new NumberAxis(0, 100, 10);
LineChart testedLineChart = new LineChart(axis1, axis2);
VBox vb = new VBox();
@Override
public void start(Stage stage) throws Exception {
testedLineChart.setTitle("LineChart");
testedLineChart.setStyle("-fx-border-color: darkgray;");
ObservableList list = FXCollections.observableArrayList();
int max = 100;
int min = 30;
for (int i = 0; i < 30; i++) {
XYChart.Data newData = new XYChart.Data();
newData.setXValue(new Random().nextDouble() * (max - min) + min);
newData.setYValue(new Random().nextDouble() * (max - min) + min);
list.add(newData);
}
Object[] array = list.toArray();
Arrays.sort(array, new Comparator() {
@Override
public int compare(Object t, Object t1) {
return (int) Math.round(((Double) ((XYChart.Data) t).getXValue()) - ((Double) ((XYChart.Data) t1).getXValue()));
}
});
XYChart.Series serie = new XYChart.Series("serie", FXCollections.observableArrayList(array));
testedLineChart.getData().add(serie);
Pane pane = new Pane();
pane.setPrefSize(600, 600);
ComboBox cb1 = new ComboBox();
cb1.getItems().addAll(Side.values());
cb1.valueProperty().bindBidirectional(axis1.sideProperty());
ComboBox cb2 = new ComboBox();
cb2.getItems().addAll(Side.values());
cb2.valueProperty().bindBidirectional(axis2.sideProperty());
pane.setPrefSize(600, 600);
pane.getChildren().add(testedLineChart);
vb.getChildren().addAll(pane, new Label("X-axis"), cb1, new Label("Y-axis"), cb2);
Scene scene = new Scene(vb, 700, 700);
stage.setScene(scene);
stage.show();
}
}
I set Xaxis to be at the left, and Yaxis to be at the bottom, and got the confused chart. If it is not a permissed action, it must at least not to affect.
Code:
import java.util.Arrays;
import java.util.Comparator;
import java.util.Random;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Side;
import javafx.scene.Scene;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class JavaCharts extends Application {
public static void main(String[] args) {
launch(args);
}
NumberAxis axis1 = new NumberAxis(0, 100, 10);
NumberAxis axis2 = new NumberAxis(0, 100, 10);
LineChart testedLineChart = new LineChart(axis1, axis2);
VBox vb = new VBox();
@Override
public void start(Stage stage) throws Exception {
testedLineChart.setTitle("LineChart");
testedLineChart.setStyle("-fx-border-color: darkgray;");
ObservableList list = FXCollections.observableArrayList();
int max = 100;
int min = 30;
for (int i = 0; i < 30; i++) {
XYChart.Data newData = new XYChart.Data();
newData.setXValue(new Random().nextDouble() * (max - min) + min);
newData.setYValue(new Random().nextDouble() * (max - min) + min);
list.add(newData);
}
Object[] array = list.toArray();
Arrays.sort(array, new Comparator() {
@Override
public int compare(Object t, Object t1) {
return (int) Math.round(((Double) ((XYChart.Data) t).getXValue()) - ((Double) ((XYChart.Data) t1).getXValue()));
}
});
XYChart.Series serie = new XYChart.Series("serie", FXCollections.observableArrayList(array));
testedLineChart.getData().add(serie);
Pane pane = new Pane();
pane.setPrefSize(600, 600);
ComboBox cb1 = new ComboBox();
cb1.getItems().addAll(Side.values());
cb1.valueProperty().bindBidirectional(axis1.sideProperty());
ComboBox cb2 = new ComboBox();
cb2.getItems().addAll(Side.values());
cb2.valueProperty().bindBidirectional(axis2.sideProperty());
pane.setPrefSize(600, 600);
pane.getChildren().add(testedLineChart);
vb.getChildren().addAll(pane, new Label("X-axis"), cb1, new Label("Y-axis"), cb2);
Scene scene = new Scene(vb, 700, 700);
stage.setScene(scene);
stage.show();
}
}
- duplicates
-
JDK-8094338 BarChart doesn't render grid correctly when sides of the axis are changed
-
- Closed
-
-
JDK-8093313 [AreaChart] Putting the X axis on the left or right side causes chart to disappear
-
- Closed
-
- relates to
-
JDK-8096048 [Chart] xAxis and yAxis side properties no longer work in Ensemble8
-
- Resolved
-