private void setupLegendLabels(PiePlot plot, Chart chart, PieChartView chartView) {
if (!chart.isLegendVisible())
return;
ChartLegend legend = chart.getLegend();
if (legend == null || legend.getLabels() == null)
return;
final ChartLabels labels = legend.getLabels();
if (labels.getText() != null) {
// simple text = the same string for every item
plot.setLegendLabelGenerator(new PieSectionLabelGenerator() {
public String generateSectionLabel(PieDataset pieDataset, Comparable comparable) {
return labels.getText();