Tuesday, September 23, 2008

to change the scale on range axis

I tried to look for a method which directly manipulates the scale on the x-axis but i couldn't find in the ValueAxis class,Number Axis class, Axis class and Category Axis class. Even then i tried different methods but everything went into vain.

Finally i observed tick units. So, when i gave a try with the tick units (number tick units) it worked.
So, i used this method to change the scale on the range axis i.e. I needed only 3 points on the range axis according to the data entered.


final NumberAxis rangeaxis = (NumberAxis) plot.getRangeAxis();

NumberTickUnit tick = new NumberTickUnit(rangeaxis.getUpperBound()/2);
rangeaxis.setTickUnit(tick);



First i entered a reasonable value related to the data in the dataset. But, i wanted a method which calculates the value and places it in the method to re-scale range axis. So, i went through the NumberAxis, Axis, ValueAxis and CategoryAxis methods. But i couldn't find any.

While i know that the method which i am looking for is going to give me an upperbound and i know the method syntax, i was not sure whether it would work with NumberAxis object. I gave it a try and it worked well.

No comments: