I have a question regarding multiple legends. I have a combined chart with 2 plots at the moment, but it will be more in future.
How can I set the position of the legends right to each plot?
The Problem is, that all the plots must fit on the same X-axis.

Code: Select all
CombinedDomainXYPlot cPlot = (CombinedDomainXYPlot) chart.getPlot();
XYPlot plot1 = new XYPlot(datasetChCo, null, new NumberAxis(""), createXYLineAndShapeRenderer());
XYPlot plot2 = new XYPlot(datasetPrice, null, new NumberAxis(""), createXYLineAndShapeRenderer());
cPlot.add(plot1);
cPlot.add(plot2);
chart.removeLegend();
LegendTitle lt1= new LegendTitle(plot1.getRenderer());
LegendTitle lt2=new LegendTitle(plot2.getRenderer());
lt1.setPosition(RectangleEdge.RIGHT);
lt2.setPosition(RectangleEdge.RIGHT);
chart.addLegend(lt1);
chart.addLegend(lt2);