Divisions on Axes

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Molly

Divisions on Axes

Post by Molly » Tue Jan 21, 2003 8:31 pm

Hi,

how do I control the number of divisions on either axis.

For eg. I have an axis ranging from 0-300. I want only 3 major divisions.
for e.g 0,100,200,300

The default chart comes up with 0,25,50 etc..,

Do i have play with the 'ticks' to acheive this??

Thanks,
Molly.

David Gilbert

Re: Divisions on Axes

Post by David Gilbert » Wed Jan 22, 2003 4:54 pm

Hi Molly,

You need to set a tick unit with size = 100, something like this:

XYPlot plot = myChart.getXYPlot();
NumberAxis axis = (NumberAxis) plot.getRangeAxis();
axis.setTickUnit(new NumberTickUnit(100.0));

Regards,

Dave Gilbert

Molly

Re: Divisions on Axes

Post by Molly » Thu Jan 30, 2003 8:07 pm

Thanks, Dave. The constructor for the NumberTickUnit also takes the format.

axis.setTickUnit(new NumberTickUnit(100.0,new DecimalFormat("###.#"));

Thanks,
Molly.

Locked