Is there a way to include some arbitrary text in the legend in a JFreeChart PieChart? I know it\'s possible to assign a PieSectionLabelGenerator
in order to customi
Looking at the source code of org.jfree.chart.JFreeChart, and seeing that addLegend()
is nothing more than addSubtitle()
behind the scenes, everything indicates that this should be achieved using addSubtitle()
.
Looking at the part where org.jfree.chart.JFreeChart adds its own LegendTitle
item, we can find the setup JFreeChart
uses for placing the Legend here.
So, the solution is to add, for instance, a TextTitle
to the Chart
in an analogous way. The relevant setting here is setPosition(RECTANGLE.BOTTOM)
.
TextTitle legendText = new TextTitle("This is LEGEND: ");
legendText.setPosition(RectangleEdge.BOTTOM);
chart.addSubtitle(legendText);