Dynamic Data Input to JFreeChart

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

Dynamic Data Input to JFreeChart

Post by Jim Kallenborn » Thu Nov 02, 2000 5:23 pm

I would like to supply JFreeChart a dataset for plotting, dynamically from an application calling JFreeChart. Is there a way to feed JFreeChart an new dataset for plotting without recompiling the program each time a new dataset is supplied?

David Gilbert

RE: Dynamic Data Input to JFreeChart

Post by David Gilbert » Sun Nov 05, 2000 9:57 am

Hi Jim,

There are two approaches that you should be able to use:

(1) Call myChart.setDataSource(...) and supply a completely new datasource instance - the chart should get redrawn;

(2) Write your own class DynamicXYDataSource (or DynamicCategoryDataSource) that implements the XYDataSource interface AND has methods for modifying individual values within the data-source. Be sure to notify registered listeners that the data has changed...the chart is registered by default, and when it receives notification of the data change it should redraw itself. [If I ever find some time, I'll have a go at writing a couple of general purpose dynamic data sources to include in the download].

The idea for using interfaces to supply data to JFreeChart came from Swing's JTable class and the TableModel interface. So if you are familiar with how Swing works, you will know what I am trying to achieve.

Regards,

DG.

Locked