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
updating data sources
RE: updating data sources
I don't think the event notification stuff really works yet.
Try:
chart.setDataSource(xyData);
John
Try:
chart.setDataSource(xyData);
John
RE: updating data sources
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.
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.
RE: updating data sources
ChartChangeEvent event = new ChartChangeEvent(xyData1, chart, ChartChangeEvent.DATA_SOURCE_MODIFIED);
chart.notifyListeners(event);
It works fine
chart.notifyListeners(event);
It works fine
RE: updating data sources
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
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