admin管理员组文章数量:1391925
I'm trying to implement a chart in JavaFX. It should:
- Initially have a linear X axis,
- When a button is pressed, change the axis to a logarithmic X axis
The problem is that LineChart does not have a setAxis method. Another problem is that my architecture is designed in such a way that I can't simply redraw the LineChart.
I tried to simply recalculate the X-axis values. But in this case the ticks are positioned incorrectly and the chart collapses horizontally.
Then I implemented my own LogarithmicAxis class, which inherits from ValueAxis<Number>. It works correctly, and if I create a lineChart like this:
NumberAxis yAxis = new NumberAxis();
LogarithmicAxis xAxis = new LogarithmicAxis();
LineChart<Number, Number> lineChart = new LineChart<>(xAxis, yAxis);
I get what I need. But I can't change the axis dynamically
My view code consists of methods like
public Region build() {
GridPane gridPane = new GridPane();
ColumnConstraints col1 = new ColumnConstraints();
gridPane.getColumnConstraints().addAll(col1);
gridPane.add(createSettingsBox(), 0, 0, 0, 0);
return gridPane;
}
private Node createSettingsBox() {
VBox settingsBox = new VBox(10);
settingsBox.getChildren().add(createButton());
return settingsBox;
}
So I get the view. But how can I reach the chart and redraw it if it has a high nesting level?
本文标签: javadynamically change xAxis in LineChart JavaFXStack Overflow
版权声明:本文标题:java - dynamically change xAxis in LineChart JavaFX - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744699146a2620459.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论