XYSeries Size Limit
XYSeries Size Limit
Is there any quick method to limit the XYSeries data to the last x number?
Re: XYSeries Size Limit
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
Regards,
DG
Re: XYSeries Size Limit
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)
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)