Hi,
A couple questions:
1. How do I get a chart to redraw itself? I want it to redraw after I've updated some date.
2. Before or after redrawing itself, is there a way to destroy the older chart?
thanks,
Hostos
redrawing a chart
Re: redrawing a chart
Hostos Monegro wrote:
> 1. How do I get a chart to redraw itself? I want it to
> redraw after I've updated some date.
If your chart is displayed in a ChartPanel, it should automatically redraw itself when you update the dataset. If it doesn't, then there is a bug somewhere.
> 2. Before or after redrawing itself, is there a way to
> destroy the older chart?
You can use the setChart(...) method in the ChartPanel class to completely replace the chart that is being displayed. The garbage collector should clean up the old chart at some point.
Regards,
DG.
> 1. How do I get a chart to redraw itself? I want it to
> redraw after I've updated some date.
If your chart is displayed in a ChartPanel, it should automatically redraw itself when you update the dataset. If it doesn't, then there is a bug somewhere.
> 2. Before or after redrawing itself, is there a way to
> destroy the older chart?
You can use the setChart(...) method in the ChartPanel class to completely replace the chart that is being displayed. The garbage collector should clean up the old chart at some point.
Regards,
DG.
Re: redrawing a chart
Hi,
My chart is displayed in a chartpanel, but I haven't tried your suggestion yet. Below, I have included how I create the dataset.
1. So, what your telling me is that after I change any data in this method, the charts will be drawn?
2. To change data in this dataset method (code below) should I make it capable of accepting values or can you suggest another way of going about this?
thanks,
Hostos
/**
* Creates a sample dataset.
*/
private XYDataset createDataset2(){
// create dataset 2...
BasicTimeSeries series2 = new BasicTimeSeries("325xi", Day.class);
series2.add(new Day(1, SerialDate.MARCH, 2002), 1700.2);
series2.add(new Day(2, SerialDate.MARCH, 2002), 1500.2);
series2.add(new Day(3, SerialDate.MARCH, 2002), 5000.2);
series2.add(new Day(4, SerialDate.MARCH, 2002), 1111.3);
series2.add(new Day(5, SerialDate.MARCH, 2002), 1853.5);
series2.add(new Day(6, SerialDate.MARCH, 2002), 1552.3);
series2.add(new Day(7, SerialDate.MARCH, 2002), 1332.0);
series2.add(new Day(8, SerialDate.MARCH, 2002), 9000.3);
series2.add(new Day(9, SerialDate.MARCH, 2002), 1998.2);
series2.add(new Day(10, SerialDate.MARCH, 2002), 1943.2);
series2.add(new Day(11, SerialDate.MARCH, 2002), 1643.9);
series2.add(new Day(12, SerialDate.MARCH, 2002), 1843.2);
series2.add(new Day(13, SerialDate.MARCH, 2002), 1495.3);
series2.add(new Day(14, SerialDate.MARCH, 2002), 1943.6);
series2.add(new Day(15, SerialDate.MARCH, 2002), 1500.7);
series2.add(new Day(16, SerialDate.MARCH, 2002), 1995.9);
return new TimeSeriesCollection(series2);
}
My chart is displayed in a chartpanel, but I haven't tried your suggestion yet. Below, I have included how I create the dataset.
1. So, what your telling me is that after I change any data in this method, the charts will be drawn?
2. To change data in this dataset method (code below) should I make it capable of accepting values or can you suggest another way of going about this?
thanks,
Hostos
/**
* Creates a sample dataset.
*/
private XYDataset createDataset2(){
// create dataset 2...
BasicTimeSeries series2 = new BasicTimeSeries("325xi", Day.class);
series2.add(new Day(1, SerialDate.MARCH, 2002), 1700.2);
series2.add(new Day(2, SerialDate.MARCH, 2002), 1500.2);
series2.add(new Day(3, SerialDate.MARCH, 2002), 5000.2);
series2.add(new Day(4, SerialDate.MARCH, 2002), 1111.3);
series2.add(new Day(5, SerialDate.MARCH, 2002), 1853.5);
series2.add(new Day(6, SerialDate.MARCH, 2002), 1552.3);
series2.add(new Day(7, SerialDate.MARCH, 2002), 1332.0);
series2.add(new Day(8, SerialDate.MARCH, 2002), 9000.3);
series2.add(new Day(9, SerialDate.MARCH, 2002), 1998.2);
series2.add(new Day(10, SerialDate.MARCH, 2002), 1943.2);
series2.add(new Day(11, SerialDate.MARCH, 2002), 1643.9);
series2.add(new Day(12, SerialDate.MARCH, 2002), 1843.2);
series2.add(new Day(13, SerialDate.MARCH, 2002), 1495.3);
series2.add(new Day(14, SerialDate.MARCH, 2002), 1943.6);
series2.add(new Day(15, SerialDate.MARCH, 2002), 1500.7);
series2.add(new Day(16, SerialDate.MARCH, 2002), 1995.9);
return new TimeSeriesCollection(series2);
}