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 !
accessing ticklabels
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);
ex:
PercentFormat myFormatter = new PercentFormat();
NumberAxis axis = new NumberAxis();
axis.setNumberFormatOverride(myFormatter);
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
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%".
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
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

