Best way to display percentages on a pie chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
pelski
Posts: 16
Joined: Thu Feb 23, 2006 2:02 am

Best way to display percentages on a pie chart

Post by pelski » Mon Mar 13, 2006 4:04 am

Hi,

What would the best way to display to the percentages, as well as the values of segments in a Pie Chart be?
I have a lot of data, and do not nescessarily want to to iterate twice
over the dataset to calculate these percentages. I am sure Pie Chart
calculates this already to draw each segment.

Cheers,
Nick.

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 » Mon Mar 13, 2006 12:15 pm

Something like:

Code: Select all

plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {1} ({2})"));
David Gilbert
JFreeChart Project Leader

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

pelski
Posts: 16
Joined: Thu Feb 23, 2006 2:02 am

Post by pelski » Mon Mar 13, 2006 11:48 pm

thanks, that is perfect.

Locked