Code: Select all
/**
* Scatter chart wanted.
*
* @return JFreeChart.
*/
private JFreeChart testScatterChart2() {
JFreeChart result = null;
final XYSeriesCollection c = new XYSeriesCollection();
final XYSeries s1 = new XYSeries("1");
s1.add(1.0, 2.6);
c.addSeries(s1);
final XYSeries s2 = new XYSeries("2");
s2.add(2.0, -3.7);
c.addSeries(s2);
final XYSeries s3 = new XYSeries("3");
s3.add(3.0, 2.5);
c.addSeries(s3);
final XYSeries s4 = new XYSeries("Gesamt");
s4.add(4.0, 1.5);
c.addSeries(s4);
result = ChartFactory.createScatterPlot("Example", "X", "Y", c, PlotOrientation.VERTICAL, true, true, false);
//show item labels:
final XYPlot plot = result.getXYPlot();
final XYItemRenderer renderer = plot.getRenderer();
final StandardXYItemLabelGenerator generator = new StandardXYItemLabelGenerator("{1} %", NumberFormat.getInstance(), NumberFormat.getInstance());
renderer.setSeriesItemLabelGenerator(0, generator); //0 = 1st series
renderer.setSeriesItemLabelsVisible(0, true); //0 = first series
return result;
}//testScatterChart2()


Same with right plot border, I I set the ItemLabelPosition to TextAnchor.CENTER_LEFT.