I switched from using a non-buffered to a buffered ChartPanel and it seems like changes I make to the chart randomly get propagated or get thrown out.
Just changing the constructor useBuffer parameter causes all of these changes. Each time I replot something different happens (I put an example of what happens at the bottom)
I've tried to fire every change event I can find but nothing works. Here is the method I added to my subclass of ChartPanel :
Code: Select all
public void updateChart(){
getChart().setNotify(true); // force a redraw
//update title
getChart().titleChanged(
new TitleChangeEvent(getChart().getTitle()));
//update x axis
getChart().getXYPlot().axisChanged(
new AxisChangeEvent(getChart().getXYPlot().getDomainAxis()));
//update y axis
getChart().getXYPlot().axisChanged(
new AxisChangeEvent(getChart().getXYPlot().getRangeAxis()));
//general chart change?
chartChanged(new ChartChangeEvent(this));
//try dataset change
getChart().getXYPlot().datasetChanged(new DatasetChangeEvent(
getChart().getXYPlot(), getChart().getXYPlot().getDataset()));
getChart().fireChartChanged();
getChart().plotChanged(new PlotChangeEvent(getChart().getXYPlot()));
}
Example:
Replot 1: Axes are not updated, title is updated, legend is incorrect
Replot 2: X axis and title are correct, Y axis is incorrect, title and legend are correct
Replot 3: Everything OK
Replot 4: Title isnt wrong, Y axis is OK but the gridlines have disappeared
Replot 5: everything OK
Also the legend sometimes disappears and reappears
..........................................
Thanks so much for any help!
-Rachel