Not show decimals on x-axis?

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

Not show decimals on x-axis?

Post by Neil Aggarwal » Sat Mar 30, 2002 4:13 am

Hello:

Take a look at this chart:
http://dsl.jammconsulting.com/burnrated ... rtTest.jsp

It has decimals on the x axis, which I dont want to show.
Is there a way to tell the axis to only show whole digits?

I looked into using the NumberTickUnit class, but then I have
to give it an increment as well as a format.

I want the axis to auto calculate, but I want to control the formatting
of the display only.

I tried to go into NumberTickUnit and add my own setFormatter method,
but that did nothing.

Thanks,
Neil.

David Gilbert

Re: Not show decimals on x-axis?

Post by David Gilbert » Sat Mar 30, 2002 8:11 am

Hi Neil,

There is a static method in the TickUnits class called createIntegerTickUnits(). This returns a collection of tick units formatted for displaying integers. So if you have a reference to a NumberAxis you can do this:

TickUnits integerTicks = TickUnits.createIntegerTickUnits();
myNumberAxis.setStandardTickUnits(integerTicks);

You can also create your own TickUnits collection and set this for the axis, if you want more control over the tick sizes that the auto tick unit mechanism uses.

Regards,

DG.

Neil Aggarwal

Re: Not show decimals on x-axis?

Post by Neil Aggarwal » Mon Apr 01, 2002 10:28 pm

David:

As always, many thanks for your help.

Neil.

Locked