sizing TimeTableXYDataset

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
uncle4
Posts: 1
Joined: Tue Jul 21, 2015 6:19 pm
antibot: No, of course not.

sizing TimeTableXYDataset

Post by uncle4 » Tue Jul 21, 2015 6:59 pm

I've seen similar questions asked before, but haven't seen a proper solution.

I'm trying to keep the size of my dataset down so Autoranging works better.

Each quantum I add a new point to N series in the dataset. I then
try the following:

Code: Select all

for (ser=0;ser < dataset.getSeriesCount(); ser++) {
   if (dataset.getItemCount() > 62) {
      TimePeriod tp = dataset.getTimePeriod(0);
      String serKey = (String) dataset.getSeriesKey(ser);
      dataset.remove(tp, serKey);
}
I eventually get:

Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 63, Size: 63
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at org.jfree.data.DefaultKeyedValues2D.getRowKey(DefaultKeyedValues2D.java:174)
at org.jfree.data.time.TimeTableXYDataset.getXValue(TimeTableXYDataset.java:376)
at org.jfree.chart.renderer.xy.StackedXYAreaRenderer2.drawItem(StackedXYAreaRenderer2.java:231)
at org.jfree.chart.plot.XYPlot.render(XYPlot.java:3782)
at org.jfree.chart.plot.XYPlot.draw(XYPlot.java:3342)
at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1242)
at org.jfree.chart.ChartPanel.paintComponent(ChartPanel.java:1629)
at javax.swing.JComponent.paint(JComponent.java:1056)
<snip>

I'm sure it's from the 'remove' call: I can comment out that line and the
program runs for hours. Trying to catch 'Exception' doesn't seem to
catch the IndexOutOfBoundsException

Any thoughts of what I may be doing wrong?

-U4-

Locked