improve realtime chart performance

A discussion forum for JFreeChart (a 2D chart library for the Java platform).

improve realtime chart performance

Postby goldie » Mon Jan 29, 2018 1:15 pm

Hi all,

I am using a DynamicTimeSeriesCollection dataset in a TimeSeriesChart to show live data on a chart.

The rate of getting new data is only one per second, but the requirement is that the chart should scroll smoothly. To achieve that, in the chart updater thread I calculate the data point between the new data and the latest one, and keep adding the interpolated values to the chart for example 20 times in a second.
This works well on a small resolution chart, but when I put the window on a FHD or bigger monitor the chart became sluggish.

Any idea how to speed up chart drawing?

Or is there any solution to implement a smooth scrolling chart with value updates coming in just in every 1 second (maybe some trick to not to draw the already drawn point just scroll them somehow)?

Things I tried:
- decrease chart resolution by:
(not helping)

- using -Dsun.java2d.opengl=true - no visible difference in speed

- not adding shadowgenerator: it helped a bit, so now there is no shadows, but that is still OK

Thansk a lot in advance

oh and I tried XChart and the chart library in the VisualVM java profiler, both claim that they are faster for real time charts then jfreechart, but they are much slower.

btw the datasets are not big, only 3 lines showing 1 minutes of data (so 3 dataset each with 20 x 60 data) (20fps during 60 seconds)
Posts: 2
Joined: Mon Jan 29, 2018 1:00 pm

Re: improve realtime chart performance

Postby david.gilbert » Wed Jan 31, 2018 9:31 pm

Each chart repaint will redraw everything, so it isn't the most efficient. There aren't any optimisations available to make it faster, unfortunately. There was a project that was optimising for realtime updates:

I don't think it is maintained anymore (I might be wrong though) but it could be worth a look.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited
JFreeChart Project Leader
Posts: 11664
Joined: Fri Mar 14, 2003 10:29 am

Re: improve realtime chart performance

Postby goldie » Tue Feb 06, 2018 9:11 am

Hi David,

thanks for the answer!
btw. I tried with a more powerful hardware and now it looks kind of OK.

have a nice day
Posts: 2
Joined: Mon Jan 29, 2018 1:00 pm

Return to JFreeChart

Who is online

Users browsing this forum: No registered users and 8 guests