问题
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?
回答1:
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
回答2:
Use a CategoryAxis instead of a NumberAxis (or follow the tickLabelFormatter solution in Sergey's answer).
来源:https://stackoverflow.com/questions/19399667/is-it-possible-to-change-the-values-of-a-numberaxis-in-javafx-2-0