createMovingAverage using TimeTableXYDataset

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
mavin
Posts: 1
Joined: Wed Jan 06, 2016 6:32 pm
antibot: No, of course not.

createMovingAverage using TimeTableXYDataset

Post by mavin » Wed Jan 06, 2016 6:45 pm

I attempted to create a moving average dataset using the MovingAverage.createMovingAverage function

MovingAverage.createMovingAverage(dataset, " - 3 Year Moving Average", 3, 3);

where the source dataset is a TimeTableXYDataset (nothing special, a nine year span with values in the thousands). It always returned the exact same dataset as the source. Stepping into the code it looks like the calculations rely on the X value to be an index but in this case it is the long representation of a TimePeriod. I don't understand exactly why it fails but when it attempts to iterate through the offset x values to average it only takes the first value and therefore the average is of one value.

Has anyone used a TimeTableXYDataset to create a moving average dataset? I didn't generate the source dataset so it is possible this is the problem but it renders the chart as expected.

Using JFreeChart 1.0.19

UPDATE: Using a TimeSeriesCollection instead of TimeTableXYDataset seems to resolve this issue.

Locked