Hello!
I use TimeTableXYDataset as a dataset (x-axis values are Dates, and it should be stacked) and XYStepAreaRenderer.
Problem is I don't know how to render these series in stacked way.
As far I understand it, a XYPlot can have only one renderer per dataset.
So, I don't know how to use StackedXYAreaRenderer together with XYStepAreaRenderer...
Thanx
Stacked XYStepArea - is it possible?
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
There isn't a version of XYStepAreaRenderer that handles stacked values.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
There is...you need to take the XYStepAreaRenderer and modify it so that it can handle stacked values. Most of the renderers that exist in JFreeChart came about because someone wanted a way to draw data that wasn't already handled by JFreeChart.rade wrote:I realized that, but I believe there have to be a way to do this...
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
Hi,
I do exactly what you're asking about using a TimeTableXYDataset and XYStepAreaRenderer. If your data is sparse, you have to fill in all the values for each time point / data series. Then you just fake the stacking by adding up each of the previous series values at each time point; e.g.
1 2 3 (Series)
----------
1 2 1 (Values)
becomes
1 2 3 (Series)
----------
1 3 4 (Values)
Of course you could also subclass it to do the same thing but its pretty straightforward to just change the data.
I do exactly what you're asking about using a TimeTableXYDataset and XYStepAreaRenderer. If your data is sparse, you have to fill in all the values for each time point / data series. Then you just fake the stacking by adding up each of the previous series values at each time point; e.g.
1 2 3 (Series)
----------
1 2 1 (Values)
becomes
1 2 3 (Series)
----------
1 3 4 (Values)
Of course you could also subclass it to do the same thing but its pretty straightforward to just change the data.
This is exactly how I planned to do it...jleech wrote:If your data is sparse, you have to fill in all the values for each time point / data series.
It basically means that before actual graph rendering you must:
1. loop through all the data and get each distinct x-value
2. pre-calculate y-values for each x-value
And than you render the graph with XYStepAreaRenderer.
But it seems that this approach has two deficiencies:
- area for each step is rendered from the bottom (baseline), but only part of it that is above all the other areas is visible - this probably adds some overhead
- you actually modify the data instead of letting the renderer to do it's job (as david.gilbert proposed)
But nevertheless, it seems to be a faster solution than modifying the XYStepAreaRenderer...