Range Axis

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

Range Axis

Post by James » Wed Jan 22, 2003 4:30 pm

I created Vertical Bar Chart. There are 9 bars with range of 92.5 to 94.1. The problem is that there are only 2 RangeAxis appears. Is there anyway that I can add more RangeAxis like .5 interval?


// set the Axis
VerticalNumberAxis vnAxis1Monthly = (VerticalNumberAxis) chartPlotMonthly.getRangeAxis();
vnAxis1Monthly.setUpperMargin(.1);
vnAxis1Monthly.setAutoRangeIncludesZero(false);




// set the Range Axis Vaule to Integer.
NumberAxis rangeAxis = (NumberAxis) chartPlotMonthly.getRangeAxis();
TickUnits units = NumberAxis.createIntegerTickUnits();
rangeAxis.setStandardTickUnits(units);

David Gilbert

Re: Range Axis

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

Those last three lines in your code force the axis to use integers only, so you will only see "93" and "94" for your tick labels. Comment out that code, and you will see more tick marks and labels...

Regards,

Dave Gilbert

James

Re: Range Axis

Post by James » Wed Jan 22, 2003 4:41 pm

that what I thought. The reason I add the IntegerTickUnits is because sometime it display 4 or 5 decimal places. I don't mind one decimal place but how can I make the code to force to make 1 decimal places?

David Gilbert

Re: Range Axis

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

Use almost the same code, but instead of createIntegerTickUnits() insert some code that creates your own TickUnits collection.

You could probably copy the code in createStandardTickUnits(), and just delete all the tick sizes that are outside the range that you want to see.

Regards,

Dave Gilbert

Locked