Set specific fixed range JFreechart

Im using JFreechart and i want to set a fixed range from 54 to 114 with tick units of 10, so i want to show in my range axis the values {43,64,74,...,114}. The thing is that i'm already using:

NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setTickUnit(new NumberTickUnit(10));
rangeAxis.setRangeWithMargins(54, 114);

The problem is that JFreeChart shows me a range with {60,70,80,90,100,110} and that's not what i want and it doesn't show me the bounds. Is there any way to get this done?

Upvotes: 0

Views: 568

Answers (1)

David Gilbert
David Gilbert

Reputation: 4477

The NumberAxis in JFreeChart always rounds to integer multiples of the tick size, and there isn't a way to change that via API calls. But you should be able to do it by subclassing NumberAxis and overriding the method calculateLowestVisibleTickValue() to return the lower bound on the axis (54 in your example). I didn't test this, so let me know if it doesn't work (I'm fairly sure it will though).

Upvotes: 1

Related Questions