PiePlot3D not showing values anymore in labels

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
heijho01
Posts: 12
Joined: Thu Jul 17, 2003 2:16 pm

PiePlot3D not showing values anymore in labels

Post by heijho01 » Wed Mar 31, 2004 10:03 am

I updated my project from 0.9.16 to 0.9.17 and because of that I changed the following things (from - to):

Code: Select all

plot.setShowSeriesLabels(true);
plot.setSectionLabelType(plot.VALUE_AND_PERCENT_LABELS);

===============================================

plot.setLabelGenerator(new StandardPieItemLabelGenerator("dagen: ", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance()));
problem is that now the labels are showing + the the name "days: " but then no value is shown... What does cause this?

Many thanks

Jeroen

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 Mar 31, 2004 10:58 am

The StandardPieItemLabelGenerator class now uses a MessageFormat instance to create the labels. You need to insert '{0}' in your format string wherever you want the key to appear, '{1}' for the value and '{2}' for the percentage. So try something like this:

Code: Select all

plot.setLabelGenerator(new StandardPieItemLabelGenerator("dagen: {0} = {1} ({2})", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance())); 
David Gilbert
JFreeChart Project Leader

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

Guest

Post by Guest » Wed Mar 31, 2004 11:43 am

ok, I understand now ... guess I didn't read the NumberFormat documentation as good as I should.

Thanks

Jeroen

askex2056
Posts: 57
Joined: Tue Aug 05, 2003 3:16 pm
Location: Germany, Munich

Post by askex2056 » Wed Mar 31, 2004 12:15 pm

Jeroen,
the thing is that the StandardPieItemLabelGenerator uses a java.text.MessageFormat internally.
Its documentation is the one that could clarify what's happening :)
Regards,

Andreas Schroeder

askex2056
Posts: 57
Joined: Tue Aug 05, 2003 3:16 pm
Location: Germany, Munich

Post by askex2056 » Wed Mar 31, 2004 12:20 pm

One should also mention that {0} is the string representation of the pie section key, {1} is the absolute value for the pie section and {2} is the percent amout of the pie section. Should be in the javadocs... i'll add it.
Regards,

Andreas Schroeder

Locked