accessing ticklabels

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
losganjas
Posts: 5
Joined: Thu May 06, 2004 2:31 pm

accessing ticklabels

Post by losganjas » Wed May 12, 2004 4:23 pm

hello jfreecharters !

as a newbie, I m trying to accessing the ticklabels in order to change them. Instead of only displaying numbers like 0, 5, 10, etc I m trying to have 0%, 5%, 10%, etc...is there any way to pass a string or something else to the ticklabels ?

does anyone have a clue ? thanx !

astenwick
Posts: 13
Joined: Tue Apr 13, 2004 8:03 pm
Location: Seattle

Post by astenwick » Wed May 12, 2004 5:50 pm

You can create your own NumberFormat class that appends a percentage sign to all numbers (NumberFormat is an abstract class). Then use NumberAxis and set the NumberFormatOverride with your new class.

ex:

PercentFormat myFormatter = new PercentFormat();
NumberAxis axis = new NumberAxis();
axis.setNumberFormatOverride(myFormatter);

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Wed May 12, 2004 10:53 pm

You can use this method from the standard Java libraries to get a percent formatter:

http://java.sun.com/j2se/1.4.2/docs/api ... ntInstance()

...or create an instance of DecimalFormat with a format string something like "0.00%".
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked