Scaling y-axis

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

Scaling y-axis

Post by Suprigya » Wed Oct 23, 2002 11:12 pm

Hi,

I had a question on y-Axis scaling. If I want to set my own scaling for yAxis, how can I set the scale step. I can set the max value and min val by

yAxis.setMaximumAxisValue( maxScale );
yAxis.setMinimumAxisValue( minScale );

But how to set the step between two points?

Thanks.

Dave Gilbert

Re: Scaling y-axis

Post by Dave Gilbert » Wed Oct 23, 2002 11:24 pm

By default, the tick size on a number axis (or a date axis) is selected automatically from a collection of 'standard' tick sizes. The algorithm tries to display as many ticks as possible without the labels overlapping.

The TickUnits class is used to store the collection of 'standard' sizes. There is a default collection, but you can create your own collection, and then call the setStandardTickUnits(...) method if you want full control over the auto-tick-unit-selection mechanism.

Or, you can just override the automatic selection and specify a NumberTickUnit that always applies - use the setTickUnit(...) method in the NumberAxis class, something along these lines:

XYPlot plot = myChart.getXYPlot();
NumberAxis axis = (NumberAxis) plot.getRangeAxis();
axis.setTickUnit(myTickUnit);

In this case, you need to select a tick unit size that won't cause the labels to overlap.

Regards,

DG.

Suprigya

Re: Scaling y-axis

Post by Suprigya » Thu Oct 24, 2002 12:25 am

Thanks, it worked.

I set the scale unit using
axis.setTickUnit(myTickUnit);

Locked