Is it possible to change the Values of a NumberAxi

2019-08-31 06:52发布

I'm not sure if this is even possible. But basically I want to change the values of a NumberAxis in JavaFX to Strings.

final NumberAxis xAxis = new NumberAxis(0, 40, 1);

So what I now want to change is the numbers 0 - 40 to any String.

Another Question is. I have added Regions to my Chart so it displays 'Bars' on specific values. Whenever I change the 'Startvalue' of my xAxis to any higher than '0', the Bars randomly disappear. Why is that?

2条回答
小情绪 Triste *
2楼-- · 2019-08-31 07:05

You can provide your own values using setTickLabelFormatter method. See http://docs.oracle.com/javafx/2/api/javafx/scene/chart/ValueAxis.html#setTickLabelFormatter(javafx.util.StringConverter)

P.S.: please ask 2nd question separately and provide code sample

查看更多
Fickle 薄情
3楼-- · 2019-08-31 07:26

Use a CategoryAxis instead of a NumberAxis (or follow the tickLabelFormatter solution in Sergey's answer).

查看更多
登录 后发表回答