Hi all,
I need to get the number of ticks between the upper & lower ranges of an axis.
Lets say that my lower range is 0 & the upper range is 100.
And the values are shown in gaps of 5. So when I ask for the number of tick count, it should return 21 (including 0 & 100)
Is there a method which serves this purpose..?? [something like myAxis.getTickCount()..??]
I tried tick related methods mentioned in http://www.jfree.org/jfreechart/api/jav ... rAxis.html
and http://www.jfree.org/jfreechart/api/gjd ... eAxis.html but no luck.
Any help is greatly appreciated. Thanks in advance.
Regards,
Asela.
Number of ticks between upper & lower ranges...
Re: Number of ticks between upper & lower ranges...
needed the same.. found following solution, that works fine for me:
hope it works for you as well...
Code: Select all
public static int calculateVisibleTickCount(NumberAxis axis) {
double unit = axis.getTickUnit().getSize();
Range range = axis.getRange();
return (int) (Math.floor(range.getUpperBound() / unit) - Math.ceil(range.getLowerBound() / unit) + 1);
}
hope it works for you as well...