So after viewing this forum I found my answer as to how to create a stacked area chart which is based off of a time series. I am using a TimeTableXYDataset as my data set and creating my chart using ChartFactory.createStackedXYAreaChart(). Before finding this in the forum I tried to create a chart by hand using multiple TimeSeries and a TimeSeriesCollection. Obviously this did work. However one of the benefits of using a timeSeriesCollection was that I could age out my items. I cannot find a way to age out my chart using the TimeTableXYDataset . I basically want to see the first and last time points in the chart and if the times are over an hour remove the first points UNTIL there is an hour or less between the first time point and the last. I don't care about the series in the time points I want ALL plots at a point in time to be removed.
Also while I am at it is there an easy way to completely remove all points from a particular series in a TimeTableXYDataset. Again i can't find an easy way to do this via the API.
Roger
age items in a Timed StackedXYAreaChart
-
- Posts: 513
- Joined: Wed Sep 12, 2007 3:18 pm
Re: age items in a Timed StackedXYAreaChart
Have you tried clear()?
Re: age items in a Timed StackedXYAreaChart
That clears ALL points. In my 2 situations I want to
1.) remove points which have aged past a certain time
and
2.) remove ALL points from a specific series and leave the rest.
1.) remove points which have aged past a certain time
and
2.) remove ALL points from a specific series and leave the rest.
-
- Posts: 513
- Joined: Wed Sep 12, 2007 3:18 pm
Re: age items in a Timed StackedXYAreaChart
Have you tried remove() using a TimePeriod that includes the start and end for the specific series?
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: age items in a Timed StackedXYAreaChart
First of all, neither of these requirements is address by JFreeChart out-of-the-box. But, at least the second one should not be hard to implement because the data structure underlying TimeTableXYDataset is DefaultKeyedValues2D which already implements a removeRow(Comparable) method, which would remove one series from the data. So you would just have to add a removeSeries(Comparable) method to the TimeTableXYDataset class, and pass that on to the underlying data object.
The aging would be a little harder to implement, because you'd have to handle the aging on each and every addition to the dataset...but again the underlying data structure (DefaultKeyedValues2D) has a method to remove an entire column (each column represents the observations for one TimePeriod, slicing across the multiple series/rows) so once you calculate which TimePeriods need expiring, the underlying data structure makes it relatively easy to delete the entries.
If you code this, and write a set of JUnit tests to "prove" that it works, I'd be happy to get this incorporated in a future release (ideally the "aging" would be roughly consistent with the TimeSeriesCollection approach).
The aging would be a little harder to implement, because you'd have to handle the aging on each and every addition to the dataset...but again the underlying data structure (DefaultKeyedValues2D) has a method to remove an entire column (each column represents the observations for one TimePeriod, slicing across the multiple series/rows) so once you calculate which TimePeriods need expiring, the underlying data structure makes it relatively easy to delete the entries.
If you code this, and write a set of JUnit tests to "prove" that it works, I'd be happy to get this incorporated in a future release (ideally the "aging" would be roughly consistent with the TimeSeriesCollection approach).
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