Display Percentage/Dollar Sign in Range Axis values

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
ninitha
Posts: 51
Joined: Mon Aug 24, 2009 7:05 am
antibot: No, of course not.

Display Percentage/Dollar Sign in Range Axis values

Post by ninitha » Fri Oct 09, 2009 9:25 am

Is anyone aware of how to display the Range Axis labels as percentage(percentage next to the number it displays) ... I tried setNumberFormatOverride of Number Axis to NumberFormat.getPercentInstance()... But that was displaying some other percentage(0%,500%,1000%) instead of the values that were input...

Qohelet
Posts: 5
Joined: Thu Oct 08, 2009 9:57 am
antibot: No, of course not.

Re: Display Percentage/Dollar Sign in Range Axis values

Post by Qohelet » Fri Oct 09, 2009 1:33 pm

Did you try it by setting the range?

remiohead
Posts: 201
Joined: Fri Oct 02, 2009 3:53 pm
antibot: No, of course not.

Re: Display Percentage/Dollar Sign in Range Axis values

Post by remiohead » Fri Oct 09, 2009 4:21 pm

Try dividing your values by 100.

ninitha
Posts: 51
Joined: Mon Aug 24, 2009 7:05 am
antibot: No, of course not.

Re: Display Percentage/Dollar Sign in Range Axis values

Post by ninitha » Mon Oct 12, 2009 6:07 am

Thanks remiohead.... But how to display the dollar sign in the Range Axis??

remiohead
Posts: 201
Joined: Fri Oct 02, 2009 3:53 pm
antibot: No, of course not.

Re: Display Percentage/Dollar Sign in Range Axis values

Post by remiohead » Mon Oct 12, 2009 7:33 pm

Code: Select all

		NumberFormat nf = NumberFormat.getInstance();
		if(nf instanceof DecimalFormat) {
			((DecimalFormat)nf).applyPattern("$");
		}

ninitha
Posts: 51
Joined: Mon Aug 24, 2009 7:05 am
antibot: No, of course not.

Re: Display Percentage/Dollar Sign in Range Axis values

Post by ninitha » Tue Oct 13, 2009 7:27 am

waw...Thanks... It helped me... :D

One more question....How do I display the Range axis with double(type) values along with this dollar sign.... When i use NumberFormat.getInstance(), it creates only Integer value I guess... Also tried setting setMaximumFractionDigits to 2...But it dint work...

remiohead
Posts: 201
Joined: Fri Oct 02, 2009 3:53 pm
antibot: No, of course not.

Re: Display Percentage/Dollar Sign in Range Axis values

Post by remiohead » Tue Oct 13, 2009 1:28 pm

Almost had it. Use setMinimumFractionDigits(2) too.

ninitha
Posts: 51
Joined: Mon Aug 24, 2009 7:05 am
antibot: No, of course not.

Re: Display Percentage/Dollar Sign in Range Axis values

Post by ninitha » Wed Oct 14, 2009 1:05 pm

But that too dint work... :(

I did the below.

Code: Select all

NumberFormat nf = NumberFormat.getInstance();		
		  nf.setMaximumFractionDigits(2);
		  nf.setMinimumFractionDigits(2);
	      if(nf instanceof DecimalFormat) {
	         ((DecimalFormat)nf).applyPattern("$");
	      }
		rangeNumAxis.setNumberFormatOverride(nf); 

Locked