Percentage Axis

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Sanix
Posts: 9
Joined: Fri Dec 01, 2006 4:25 pm

Percentage Axis

Post by Sanix » Fri Dec 08, 2006 2:31 pm

I have StackedBarChart with some values. I want that the bars always reach the top but show percentage of their bar.

Like this:
Country A Water 1
Country A Earth 3
Country B Water 3
Country B Earth 6

Now it should show 2 bars, both same size, showing the relation between Water and Earth. It's difficult to explain. I have already this bar charts but with "normal" values.

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 » Fri Dec 08, 2006 3:06 pm

If you already have a regular stacked bar chart, then you can modify it like this:

Code: Select all

CategoryPlot plot = (CategoryPlot) chart.getPlot();
StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer();
renderer.setRenderAsPercentages(true);
David Gilbert
JFreeChart Project Leader

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

Sanix
Posts: 9
Joined: Fri Dec 01, 2006 4:25 pm

Post by Sanix » Thu Dec 21, 2006 2:53 pm

Thank you very much, it works.

Locked