Bug 707395 (setHorizontalAxisTrace() in CombinedXYPlot) - I solved this problem but maybe this is not the best solution.
In method draw(Graphics2D g2, Rectangle2D plotArea, ChartRenderingInfo info), after this code:
Code: Select all
if (info != null) {
info.setDataArea(dataArea);
}
// draw all the charts
for (int i = 0; i < this.subplots.size(); i++) {
XYPlot plot = (XYPlot) subplots.get(i);
plot.draw(g2, this.subplotAreas[i], info);
}
Code: Select all
if (info != null) {
info.setDataArea(dataArea);
}
But I found another problem connected with drawing secondary axis on CombinedDomainXYPlot. The axis is invisible.
Code which presents this error (based on CombinedXYPlotDemo1).
Code: Select all
private JFreeChart createCombinedChart() {
// create subplot 1...
XYDataset data1 = createDataset1();
XYItemRenderer renderer1 = new StandardXYItemRenderer();
NumberAxis rangeAxis1 = new NumberAxis("Range 1");
XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
// add secondary axis
subplot1.setSecondaryDataset(0, createDataset2());
NumberAxis axis2 = new NumberAxis("Range Axis 2");
axis2.setAutoRangeIncludesZero(false);
subplot1.setSecondaryRangeAxis(0, axis2);
subplot1.setSecondaryRangeAxisLocation(0, AxisLocation.BOTTOM_OR_RIGHT);
subplot1.setSecondaryRenderer(0, new StandardXYItemRenderer());
// the end
XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0);:
(...)
}
Code: Select all
plot.setInsets(new Insets(0,0,0,50));
Best Regards
Grzegorz