Dear David and Fellow JfreeCharters,
I am reading in a file of data points to a vector which takes about 0.3 seconds no matter the file size, but when i plot the points it takes a long time to display.
I plot these points by adding them to a series in a loop ie
for (i<0;i<numpoints;i++){
(get time and rawoffset back from vector)
this.series.add(time, rawoffset);
}
where the series is an XY series->XYSeriesCollection->JFreeChart->ChartPanel.
It takes a long time to add the data to the plot which also seems to be exponential eg 2 sec for 3246 points,8 sec 6462, 93 sec for 18980 points.
i am worried that after each point is plotted a repaint is being done which may explain the exponential time for more points.
So basically I am after some tips on how to reduce the time taken to plot.
I have tried a swingWorker thread which seemed to take forever to complete loading al the data. I don't mind if the app locks up for a few seconds while the data loads.
Q1 is there any better way to add the data to the plot that could reduce time?
Q2 I haven't used a buffered image before but could this reduce time by writing all the points to the image then displaying the image ?
Any other suggestions would be helpful
Cheers
Rob
BTW1 JFreeChart really kicks
BTW2The time taken to get the data back from the vector is v small as when the series.add.. is commented out it is very quick.
How could I reduce time taken to plot by adding points to a
Re: How could I reduce time taken to plot by adding points t
I think I have answered part of my own question by not establishng a link between the series and the chart
I was:
this.series = new XYSeries("Raw");
dataset = new XYSeriesCollection(series);
JFreeChart chart = ChartFactory.createScatterPlot("BTS Models", "Time", "Offset",dataset, true);
and then in my loop i was adding each point series.add(point..)
I think this added the point redraw the chart which added more time each data point there was
If I now do
this.series = new XYSeries("Raw");
this.series2 = new XYSeries("Raw");
dataset = new XYSeriesCollection(series);
JFreeChart chart = ChartFactory.createScatterPlot("BTS Models", "Time", "Offset", dataset, true);
I then add my data points to the series2 then add the series2 to series
dataset.addSeries(series2);
the only problem is that there is a legend reference to series as well as series 2.
The other option I could do was not call
JFreeChart chart = ChartFactory.createScatterPlot("BTS Models", "Time", "Offset", dataset, true);
until i was had read the data and was ready to plot but i wanted the empty chart to be on the screen when the app loaded.
Any ideas???
I was:
this.series = new XYSeries("Raw");
dataset = new XYSeriesCollection(series);
JFreeChart chart = ChartFactory.createScatterPlot("BTS Models", "Time", "Offset",dataset, true);
and then in my loop i was adding each point series.add(point..)
I think this added the point redraw the chart which added more time each data point there was
If I now do
this.series = new XYSeries("Raw");
this.series2 = new XYSeries("Raw");
dataset = new XYSeriesCollection(series);
JFreeChart chart = ChartFactory.createScatterPlot("BTS Models", "Time", "Offset", dataset, true);
I then add my data points to the series2 then add the series2 to series
dataset.addSeries(series2);
the only problem is that there is a legend reference to series as well as series 2.
The other option I could do was not call
JFreeChart chart = ChartFactory.createScatterPlot("BTS Models", "Time", "Offset", dataset, true);
until i was had read the data and was ready to plot but i wanted the empty chart to be on the screen when the app loaded.
Any ideas???
Re: How could I reduce time taken to plot by adding points t
Instead of adding a new series to the existing dataset, you could create a new dataset, populate it (it's not connected to the chart yet) and then replace the existing dataset by calling the setDataset(...) method in the plot.
Regards,
DG.
Regards,
DG.