aspose file tools*
The moose likes Other Open Source Projects and the fly likes Show Graph Labels as Percent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Show Graph Labels as Percent" Watch "Show Graph Labels as Percent" New topic
Author

Show Graph Labels as Percent

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1391
I have an XY line chart that I would like to display the series value labels(data points) as percent(75%, 45% etc.) I have everything working but the percent symbol.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Not sure what the issue is.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1391
David Newton wrote:Not sure what the issue is.


I think I have my problem narrowed down to the StandardXYItemLabelGenerator. I need help with the syntax of this method so it will format the labels to include a percent symbol.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm still not sure what the actual problem you're having is.

If it's a printf-style format string then the percent character would need to be escaped so it isn't treated as a formatter prefix.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1391
David Newton wrote:I'm still not sure what the actual problem you're having is.

If it's a printf-style format string then the percent character would need to be escaped so it isn't treated as a formatter prefix.


I simply want to display the data point value labels in a percent format(like 75% etc). I can get the data point value label to display as 75 but I would prefer to have the percent symbol displayed with it. Again, I think the answer is in the StandardXYItemLabelGenerator call which has a method to define number formating. I just do not have the knowledge on how to set up the syntax of this method to define a percentage format.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
It helps to know that this is about the JFreeChart library :-)

A look at the source code of the AbstractXYItemLabelGenerator class shows that the format string is used as the first parameter to a MessageFormat.format call, and that its default value is "{2}". The java.text.MessageFormat javadocs have much detail about how format strings are constructed, including -and that goes back to what David said- how to keep string literals in them.


Ping & DNS - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Show Graph Labels as Percent
 
Similar Threads
Calling a static method. Help!
ToolTip help
continue and lables
Could you make dynmically textfields, labels, and buttons
JTable - Renderer for JPanel