set decimal value in my y axis

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
riadhhwajdii
Posts: 12
Joined: Tue Aug 25, 2009 9:12 am
antibot: No, of course not.

set decimal value in my y axis

Post by riadhhwajdii » Thu Sep 03, 2009 12:03 pm

hi,
my y axis show me value like 10.0000
how can i show in my y axis only decimal values(ex:10)

kha
Posts: 4
Joined: Tue Sep 08, 2009 7:56 am
antibot: No, of course not.

Re: set decimal value in my y axis

Post by kha » Tue Sep 08, 2009 4:29 pm

Hi

you should be able to achieve that by using a formatter:

1. Create a formatter
DecimalFormat format = (DecimalFormat)DecimalFormat.getNumberInstance(Locale.ENGLISH);
format.applyPattern("#,##0");

In case there could be decimals, for example 10.5 you should use:
format.applyPattern("#,##0.##");

2. Apply the formatter to your axis (assuming you have generated the plot already, you get the axis by plot.getRangeAxis() -> you might the cast it to NumberAxis for example - depending on your axis type though )
axis.setNumberFormatOverride(format);


k

Locked