XYSeries Size Limit

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

XYSeries Size Limit

Post by David Mellar » Thu Nov 07, 2002 2:41 am

Is there any quick method to limit the XYSeries data to the last x number?

Dave Gilbert

Re: XYSeries Size Limit

Post by Dave Gilbert » Fri Nov 08, 2002 12:32 am

Not yet. There is a setMaximumItemCount(...) method in the BasicTimeSeries class, and I need to port something similar across to the XYSeries class. If you are in a hurry, then take a look at the way it is done in BasicTimeSeries...

Regards,

DG

David Mellar

Re: XYSeries Size Limit

Post by David Mellar » Fri Nov 08, 2002 12:22 pm

Thanks. I tried the following:

int maxChartSize = 100;
if (seriesAverage.getItemCount() >= maxChartSize) {
seriesAverage.delete(0,0);
}

And it works, but I occationally get the following exception:
I tried hunting down the problem, but no luck. Any advice?

java.lang.IndexOutOfBoundsException: Index: 99, Size: 99

at java.util.ArrayList.RangeCheck(Unknown Source)

at java.util.ArrayList.get(Unknown Source)

at com.jrefinery.data.XYSeries.getDataPair(Unknown Source)

at com.jrefinery.data.XYSeriesCollection.getXValue(Unknown Source)

at com.jrefinery.chart.StandardXYItemRenderer.drawItem(Unknown Source)

at com.jrefinery.chart.XYPlot.render(Unknown Source)

at com.jrefinery.chart.XYPlot.draw(Unknown Source)

at com.jrefinery.chart.JFreeChart.draw(Unknown Source)

at com.jrefinery.chart.ChartPanel.paintComponent(Unknown Source)

at javax.swing.JComponent.paint(Unknown Source)

at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source)

at javax.swing.JComponent.paintDoubleBuffered(Unknown Source)

at javax.swing.JComponent._paintImmediately(Unknown Source)

at javax.swing.JComponent.paintImmediately(Unknown Source)

at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)

at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)

at java.awt.event.InvocationEvent.dispatch(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Locked