Dataset with sums - Renderer with percentages?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
rpitting
Posts: 3
Joined: Mon Oct 22, 2007 2:49 pm

Dataset with sums - Renderer with percentages?

Post by rpitting » Tue Oct 23, 2007 11:19 am

I am analyzing the the results of anual surveys.

My DefaultCategoryDataset contains the answers as rows, and the years as columns.

Each field in the table contains the absolute values (sums), i. e. the number of persons who selected this answer.

So in my case, "66" doesn't mean "66%" (as usually imposed by JFreeChart), but "66 people of all the participants".

My questions: the Vertical BarChart displaying the results should automatically convert the sums from the data to percentages in the display.

As I still want to keep track of the absolute values, I would like to have them shown in the tooltip of each chart segment.

How do I achieve my goals?

Thank you in advance,


Reiner

dtopolsek
Posts: 8
Joined: Wed Oct 10, 2007 10:46 am
Contact:

Post by dtopolsek » Tue Oct 23, 2007 12:34 pm

i think there's valueToPercent(args) method. and if you want to keep value as a tooltip, well keep the value in separate variable and setTooltip(value) if there's such method :)

hope it helps

rpitting
Posts: 3
Joined: Mon Oct 22, 2007 2:49 pm

Post by rpitting » Tue Oct 23, 2007 2:42 pm

dtopolsek wrote:hope it helps
Unfortunately not: I could not find the method you mention.

Any other guesses?

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 Oct 24, 2007 10:46 pm

Create a StandardCategoryItemLabelGenerator with a "{3}" in the format string...this will be replaced by the percentage.
David Gilbert
JFreeChart Project Leader

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

Locked