Times and Stacked Bars

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

Times and Stacked Bars

Post by Cory Watson » Fri Nov 29, 2002 6:14 pm

The TimeSeries chart is perfect for my use, but I can't maked any 'stacked' charts with it. Is there a way to do this without losing the time-based X axis. I'm assuming that a the TimeSeries chart actually takes the time into consideration when it plots points, rather than just drawing them equidistantly... ;)

David Gilbert

Re: Times and Stacked Bars

Post by David Gilbert » Fri Nov 29, 2002 6:31 pm

Hi Cory,

There are no renderers for 'stacked' charts with the XYPlot class yet. It will be slightly trickier to implement these for XYPlot compared to CategoryPlot...for the latter class, you can always be sure that every category is represented in every series. But XYDataset is different, each series can have an independent set of x-values (and even a different number of x-values), so working out how to stack data items is not easy.

Regards,

DG

Cory Watson

Re: Times and Stacked Bars

Post by Cory Watson » Fri Nov 29, 2002 6:36 pm

Ok. Well, that throws a bit of a wrench in my plans :)

Perhaps I'm going about this the wrong way, as I'm sure that each of my series will have a value in each 'category'.

For now, to explain my problem, lets say I'm graphing a host's CPU activity. I'll have 3 series, and a 'category' for each time a reading was taken. I've not used a CategoryDataset because my data is time based, so I went to the Time classes ;)

Is there a different way I should be approaching this problem?

David Gilbert

Re: Times and Stacked Bars

Post by David Gilbert » Fri Nov 29, 2002 6:50 pm

I don't like using categories for time values, you lose information that way (and, from what you said, it looks like you think the same).

What you need to have is a 'restricted' XYDataset, one where you can guarantee that the x-values for all series are the same. You could write a renderer that assumes this, and throws an exception if it gets an invalid x-value. With that assumption, the stacked renderer could follow a similar approach to the ones that have been implemented for the CategoryPlot class.

Regards,

DG

Locked