NumberAxis alignment of ticks to multiples of tickUnit

Adam Granger adam at adamish.com
Wed Aug 20 06:38:16 UTC 2014


I've just been having fun with scrolling graphs in JavaFx. It seems that
when using Number axis without autoRanging graphs must always start with a
major tick, even if it is not a multiple of tickUnit.

For example a graph with xAxis range 4 to 24 and tickUnit 10. I would
expect major ticks at 10 and 20, however I see ticks at 4, 14 and 24 -
this feels weird. To me aligning tick marks to multiples makes sense and
should at least be a option, it's what you would have done in your Maths
when drawing graphs by hand.

 * my question:
http://stackoverflow.com/questions/25383566/scrolling-xychart-with-javafx/25397836
 * another one I found later:
http://stackoverflow.com/questions/13119597/javafx-2-x-how-to-move-line-grid-and-x-ticks-together

I "solved" this by subclassing ValueAxis - see my own answer on
stackoverflow link.

There is also a project called jfxutils which contains a class called
StableTickAxis which appears to do the same job along with duplicating a
lot of the functionality in NumberAxis.
https://github.com/gillius/jfxutils/blob/master/jfxutils/src/main/java/org/gillius/jfxutils/chart/StableTicksAxis.java

So my question to the group is, would you consider including this
functionality in the main NumberAxis class? - obviously making it
configurable and defaulting to current behaviour.

Regards,

Adam.






More information about the openjfx-dev mailing list