XChart icon indicating copy to clipboard operation
XChart copied to clipboard

Repainting a specified series to improve repaint performance

Open RNuWM opened this issue 7 years ago • 2 comments

I have a fairly complex chart scheme that includes interactive mouse support. One feature is a mouse follower icon that follows XY series data as a separate XY series composed of a single data point. The pseudocode to update this single data point series is:

chart.updateXYSeries(seriesName, xVal, yVal, null);
chartPanel.revalidate();
chartPanel.repaint();

Being a single point, the update is, in principle, extremely lightweight. However, the entire chart is repainted which can be very significant work if a lot of data is displayed in the other series. This repaint time is very noticeable in something interactive like mouse feedback.

For comparison, this maintains good mouse interaction regardless of the background data size.

Is there a change in approach I can use to improve my performance with the existing XChart library? Is there some way to repaint specific series? I believe the answer is no, but I may be missing something.

If not, maybe we can enhance XCharts with some sort of layering system in its rendering logic. I’m essentially trying to update a layer that’s on top of a static backing image.

RNuWM avatar Jun 08 '18 16:06 RNuWM

I really don't know if that is possible with Java Swing. There would need to be some way to define layers like you said. Can Swing do that?

timmolter avatar Jun 12 '18 07:06 timmolter

I am far from a Swing expert but it's likely that using a JLayeredPane could accomplish independently rendered layers that visually combine for the completed chart.

I think JPanel's (maybe some sort of modified XChartPanel) could be stacked in the JLayeredPane with the non-base layers having there background opacity turn off (transparent).

Obviously, trying something like this would be a large and invasive undertaking.

RNuWM avatar Jun 13 '18 22:06 RNuWM