I am writing a program where I use the XYPlot and the axis have a fixed width. (Both axis are numerical) I am dynamically adding a lot of data to several graphs. The problem is that because the whole graph repaints each time I add a data item, the updating of the graphs are slow. I have tried to modify the code so that only the lines for the data items added get drawn every time. I have managed to do this sucessfully however there is some complications Because I had to make quite a lot of changes to the code I ended up breaking some of the other features.
What I am doing is, I made a flag in JFreeChartpanel that indicates whether the chart has changed only due to new data that was added, or there are other changes. I then wrote an extra drawUpdate method in JFreeChart and JFreeChartPlot that only draws the newly added points. I also added a list to the plot that remembers the last data items that were drawn.
I was just wondering if I am missing something obvious, or there is a better way to do it.
Repaints when adding data
Re: Repaints when adding data
Partial redrawing raises lots of issues that I decided to avoid by simply redrawing the chart every time. For this reason, JFreeChart will never be ideal for charts that require updating many times per second.
In some circumstances, partial redraws will probably work OK (like when the axis ranges don't change), but in general it won't.
Regards,
DG.
In some circumstances, partial redraws will probably work OK (like when the axis ranges don't change), but in general it won't.
Regards,
DG.