age items in a Timed StackedXYAreaChart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
rcrerie
Posts: 2
Joined: Fri Jul 13, 2012 2:52 pm
antibot: No, of course not.

age items in a Timed StackedXYAreaChart

Post by rcrerie » Fri Jul 13, 2012 3:00 pm

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

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: age items in a Timed StackedXYAreaChart

Post by John Matthews » Sat Jul 14, 2012 2:42 pm

Have you tried clear()?

rcrerie
Posts: 2
Joined: Fri Jul 13, 2012 2:52 pm
antibot: No, of course not.

Re: age items in a Timed StackedXYAreaChart

Post by rcrerie » Mon Jul 16, 2012 4:00 pm

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.

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: age items in a Timed StackedXYAreaChart

Post by John Matthews » Tue Jul 17, 2012 3:33 pm

Have you tried remove() using a TimePeriod that includes the start and end for the specific series?

david.gilbert
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

Post by david.gilbert » Tue Jul 17, 2012 9:45 pm

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).
David Gilbert
JFreeChart Project Leader

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

Locked