Is it possible to change the Values of a NumberAxis in JavaFX 2.0?

半腔热情 提交于 2019-12-11 22:22:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!