Java – JFreeChart XY-chart that refreshes with new set of data? Example

chartsjavajfreechartredrawrefresh

I want to learn how to learn how to create some charts with jfreechart and googlefor some examples. but I couldn't find what I need. This here is good http://www.java2s.com/Code/Java/Chart/CatalogChart.htm but doesn't have a refreshing graph with new displayed values.

I would like to redraw a chart every nth seconds because I update an external dile witha set of values I want to display here.
So how do I tell jfreechart to refresh the drawn graph and display it onthe canvas?

Thanks in advance,

Andreas

Best Answer

This example features a chart that is updated at a selectable rate using an instance of javax.swing.Timer.

Addendum: JFreeChart follows the Swing separable-model variation of MVC. ChartPanel is a convenient top-level view, as seen in this example. For secular data, a TimeSeriesCollection of TimeSeries makes a straightforward data model.

Related Topic