Tick units/X Axis

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

Tick units/X Axis

Post by Anup K » Wed Oct 09, 2002 11:47 pm

I want to change one value on the X-Axis of a graph from an integer to String.

I have ...

xAxis1.setRange(20.0, 200.0);
xAxis1.setTickMarksVisible(true);

Instead of X-Axis showing 20, 40, 60, 80..... it should be 20, 40, "zero degree", 80 etc.

I am not sure whether trying out with Tick units is the right method. I tried

NumberAxis rangeAxis = (NumberAxis)plot1.getRangeAxis();
rangeAxis.setStandardTickUnits(TickUnits.createIntegerTickUnits());

but then it allows only a createIntegerTickUnits() rather than create your own integer+string tick units.

Can anyone suggest a way out?

Dave Gilbert

Re: Tick units/X Axis

Post by Dave Gilbert » Thu Oct 10, 2002 9:36 am

The tick labels are generated numerically, so what you are trying to do isn't straightforward. But one possibility would be to subclass the HorizontalNumberAxis class and override the refreshTicks method...after the collection of ticks is populated, you could write some code to replace certain values.

Regards,

DG

Locked