|
To dynamically update chart's model without recreating the model object
you need to use MxStandardChartModel. The instances of this model are
returned by all XML, database and import functions. If you created your own model,
you can convert it to MxStandardChartModel by calling asStandardModel() function:
chart.setStyle(new MxFrameChartStyle());
chart.setModel(new MxSampleChartModel(2,5).asStandardModel());
To update MxStandardChartModel use model API functions and then call repaint() method
to refresh the chart. For example, to display latest values of some variable you can delete
first column of data and insert a new column when it becomes available:
MxStandardChartModel model = (MxStandardChartModel) chart.getModel();
model.deleteCol(0);
model.insertCol(Integer.toString(3000+count++), new double[] {.....},-1 );
chart.repaint();
You can see this example running by selecting Samples topic of Swing section in
WebCharts3D Designer's Help and clicking the appropriate sample link.
|