Stacked but not summed bar charts

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
chuck clark

Stacked but not summed bar charts

Post by chuck clark » Wed Jan 08, 2003 1:36 am

First let me say how very impressed I am with JFreeChart. I used it for an application a month or two ago and now I've been asked to improve upon it so it brings me to this question:

I want bar chart with the series stacked but I don't want their values to be summed on the y-axis.

For instance, I have a series of 100, 98, 95. This creates a chart with the first bar going from 0-100, the second from 100-198 and the third from 198-293. In effect it is summing the values.

Really I want to have three bars going from 0-100, 0-98 and 0-95. What I'm trying to accomplish is the first number is the total number of data points. The second and third are datapoints that meet certain criteria. So in effect a point belongs to at least one set but could be a member of all three sets.

I think this could be hacked by doing some funky manipulation of the y-axis. But I'm guessing the correct way would be to create my own VerticalBarRenderer? Any thoughts or ideas?

chuck

chuck clark

Re: Stacked but not summed bar charts

Post by chuck clark » Wed Jan 08, 2003 6:01 pm

I've been putting some more thought into the chart I'm creating and I've realised I'm looking to create a chart that operates like a pie chart but renders like a stacked bar chart.

I'm looking to represent the response times for 20 different services in my system and 20 pie charts is a bit overwhelming. I know that I will have at most three slices so rendering 20 bars with three slices will convey the information in a much more compact fashion which I think should also be easier to comprehend.

I just thought the additional detail might help clarify what I was asking. Has anyone created charts similar to this?

cheers,
chuck

David Gilbert

Re: Stacked but not summed bar charts

Post by David Gilbert » Thu Jan 09, 2003 7:23 am

Hi Chuck,

I've seen stacked bar charts where the units are percentages, so all the bars show 100% for the total. That's probably what I'd use to display the information you described.

The only way to do that in JFreeChart now is to convert your dataset to percentages before handing it to the chart. A better way would be to develop a new renderer that does the conversion automatically - there is no such renderer in JFreeChart now, but it will be added at some point before we reach the magic version 1.0.0.

Regards,

Dave Gilbert

chuck clark

Re: Stacked but not summed bar charts

Post by chuck clark » Thu Jan 09, 2003 8:49 pm

Great! Thanks for the response Dave. I had just about come to that conclusion on my own. I'm looking into writing the renderer that will do this automatically. Once I've got it I'll forward it on to you...

cheers,
chuck

Locked