updating data sources

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

updating data sources

Post by G Visser » Thu Oct 11, 2001 12:50 pm

Below is an example of a JFreeChart, JFreeChartPanel and XYDataSource
I've constructed.
I've made my own XYDataSource and don't think the problem lies
there.
The chart look good at first but when I make a change to my dataSource the JFreeChartPanel stays unchanged.

JFreeChart chart = JFreeChart.createXYChart(xyData);
JFreeChartPanel chartPanel = new JFreeChartPanel(chart);
chartPanel.getChart().setTitle("HTC vs Temperature");
this.add(chartPanel, BorderLayout.CENTER);
this.revalidate();

I've found a way around this by repeating this whole constructing
proccess, but that just feels wrong.
I've tried
- this.revalidate();
or
- ChartChangeEvent e = new com.jrefinery.chart.event.ChartChangeEvent(this, chart);
chartPanel.chartChanged(e);

although I couldn't figer out what 'source' should really be
in ChartChangeEvent(source, chart);
- chart.fireChartChanged();


none of these work. I need help!

thanks in advance
Gerard Visser

John Currier

RE: updating data sources

Post by John Currier » Fri Oct 12, 2001 6:47 pm

I don't think the event notification stuff really works yet.

Try:
chart.setDataSource(xyData);

John

David Gilbert

RE: updating data sources

Post by David Gilbert » Fri Oct 12, 2001 7:59 pm

Hi,

John is correct - updating datasources on the fly is not fully implemented yet.

However, the good news is that it is being worked on. I have just got the first cut finished of some code for a new TimeSeriesDataSource (plus supporting classes) - this will make it a lot easier to create charts of time series data (financial data is my interest).

My next step is to make this work dynamically so that when you update a time series it automatically flows through to update the chart. In the process of getting this working I should be able to finish off the event processing code...and the next version of JFreeChart will be that much better.

Code will be posted on the site in due course...

Regards,

Dave Gilbert.

tevch

RE: updating data sources

Post by tevch » Thu Oct 18, 2001 9:56 pm

ChartChangeEvent event = new ChartChangeEvent(xyData1, chart, ChartChangeEvent.DATA_SOURCE_MODIFIED);

chart.notifyListeners(event);

It works fine

John Currier

RE: updating data sources

Post by John Currier » Thu Oct 18, 2001 10:39 pm

David, can you make sure the new notification mechanism is optional? That is, you have to explicitly add the chart as a listener to the data model?

I get periodic updates from a server with multiple ticks in an update. An old tick gets removed whenever a new tick gets added. With a pure event-driven model the updating of the chart would bog things down quite a bit as opposed to the current mechanism of doing all the updates to the model and notifying the chart en-masse.

John

Locked