gpt4 book ai didi

javafx-2 - JavaFX XYChart 对数图

转载 作者:行者123 更新时间:2023-12-01 02:34:39 26 4
gpt4 key购买 nike

我有一个 XYChart 将数据绘制为 Y 轴上的线性步长,我想绘制为对数或半对数 Y 刻度,如何更改我的以下代码?

public class BaseXYChart extends Application {

@Override
public void start(Stage stage) {
stage.setTitle("Linear plot");

final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis(1, 22, 0.5);

yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis){
@Override
public String toString(Number object){
return String.format("%7.2f", object);
}
});
final LineChart<String, Number>lineChart = new LineChart<String, Number>(xAxis, yAxis);

lineChart.setCreateSymbols(false);
lineChart.setAlternativeRowFillVisible(false);

XYChart.Series series1 = new XYChart.Series();

series1.getData().add(new XYChart.Data("Jan", 1));
series1.getData().add(new XYChart.Data("Feb", 1.5));
series1.getData().add(new XYChart.Data("Mar", 2));
series1.getData().add(new XYChart.Data("Apr", 2.5));
series1.getData().add(new XYChart.Data("May", 3));
series1.getData().add(new XYChart.Data("Jun", 4));
series1.getData().add(new XYChart.Data("Jul", 6));
series1.getData().add(new XYChart.Data("Aug", 9));
series1.getData().add(new XYChart.Data("Sep", 12));
series1.getData().add(new XYChart.Data("Oct", 15));
series1.getData().add(new XYChart.Data("Nov", 20));
series1.getData().add(new XYChart.Data("Dec", 22));

BorderPane pane = new BorderPane();
pane.setCenter(lineChart);
Scene scene = new Scene(pane, 800, 600);
lineChart.getData().addAll(series1);

stage.setScene(scene);

stage.show();
}

public static void main(String[] args) {
launch(args);
}

}

谢谢大家

最佳答案

我认为在 JavaFX Vanilla 中这是不可能的。但是你可以看看这里:http://blog.dooapp.com/2013/06/logarithmic-scale-strikes-back-in.html

关于javafx-2 - JavaFX XYChart 对数图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10751894/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com