0

我需要 JavaFx BarChart 中的对数 y 轴。我尝试使用 valueAxis 的这个实现。该代码似乎是正确的,它在 lineChart 中作为 x 轴工作。但是它不适用于条形图,图中根本没有条形。valueAxis 应该适用于任何类型的图表,所以我认为 BarChart 是问题所在。但我找不到错误。

这是我的代码,我如何测试图表:

LogarithmicAxis yAxis = new LogarithmicAxis();
yAxis.setMinorTickVisible(true);
yAxis.setVisible(true);
yAxis.setLabel("label");

chart = new BarChart<String, Number>(xAxis, yAxis);
chart.setAnimated(false);

Series<String, Number> aSeries = new Series<String, Number>();
aSeries.getData().add(new XYChart.Data("test1", Math.log(90)));
aSeries.getData().add(new XYChart.Data("test2", Math.log(100)));

answer = FXCollections.observableArrayList();
answer.addAll(aSeries);
chart.getData().addAll(answer);

chartFxPanel.setScene(new Scene(chart));
chart.layout();
4

0 回答 0