I'm trying to add annotations to a chart. It seems like it's added, since the size()
of the plot's annotations list increases if I add one more. The problem is that it's not being displayed.
OHLCDataset candles = createCandleDataset();
// Create chart
chart = ChartFactory.createCandlestickChart(
"mychart", "", "", candles, true);
XYPlot plot = (XYPlot) chart.getPlot();
XYShapeAnnotation a1 = new XYShapeAnnotation(
new Rectangle2D.Double(10.0, 20.0, 20.0, 30.0),
new BasicStroke(1.0f), Color.blue);
plot.addAnnotation(a1);
ChartPanel panel = new ChartPanel(chart);
setContentPane(panel);
Any ideas?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…