RealTime Plotting

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

RealTime Plotting

Post by Marty » Tue Sep 24, 2002 10:07 am

Is it Possible to perform real time plotting with this package?

My application recieves data from a com part every 30 sec I would like to plot the data as it comes along every 30sec is this possible and if so how?

Ted Hill

Re: RealTime Plotting

Post by Ted Hill » Tue Sep 24, 2002 9:16 pm

Marty,

Yes you can do this.

Every time you get more data, you need to update the dataset/datamodel that supports your chart and tell it to redraw.

For example, you can create a new JFreeChart and then call

ChartPanel.setChart(myNewJFreeChart);

This will update your existing ChartPanel with a 'refreshed' chart.

Ted Hill

David Gilbert

Re: RealTime Plotting

Post by David Gilbert » Wed Sep 25, 2002 8:29 am

Hi Marty,

JFreeChart is designed to automatically redraw a chart (if it is in a ChartPanel) whenever the dataset changes, so all you should have to do is add a new data point or update an existing one.

There are a couple of provisos:

(1) The chart is completely redrawn, so performance can be an issue if you are updating the chart many times per second. But every 30 seconds will not be a problem.

(2) The dataset implementations are not thread safe at present. I'm looking at adding a reader-writer lock, but I need to experiment with it a bit.

(3) There isn't a way for datasets to 'drop' old data at present (although there is some new code in CVS to help with this), so if you keep adding to your dataset every 30 seconds without removing old data, memory usage will slowly increase.

Regards,

DG.

Locked