Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#996 Histogram autorange doesn't refresh after adding a serie

1.0.x
open
nobody
General (896)
5
2012-11-27
2010-05-02
Diaoul
No

HistogramDataset dataset = new HistogramDataset();
dataset.setType(HistogramType.FREQUENCY);
JFreeChart chart = ChartFactory.createHistogram("Where is Charlie ?", "xTitle", "yTitle", dataset, PlotOrientation.VERTICAL, false, false, false);
double[] value = new double[10000];
Random generator = new Random();
for (int i = 0; i < 10000; i++) {
value[i] = 20 * generator.nextGaussian() - 10;
}
dataset.addSeries("Charlie", value, 100);
try {
ChartUtilities.saveChartAsPNG(new File("NotCharlie.png"), chart, 800, 400);
} catch (IOException e) {
}
// Force refreshing autorange on both axis
chart.getXYPlot().getDomainAxis().setAutoRange(false);
chart.getXYPlot().getDomainAxis().setAutoRange(true);
chart.getXYPlot().getRangeAxis().setAutoRange(false);
chart.getXYPlot().getRangeAxis().setAutoRange(true);
try {
ChartUtilities.saveChartAsPNG(new File("Charlie.png"), chart, 800, 400);
} catch (IOException e) {
}

Discussion