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();
}
public AttributedString generateAttributedSectionLabel(PieDataset dataset, Comparable key) {
return null;
}
});
} else if (labels.getDynamicText() != null) {
plot.setLegendLabelGenerator(new DynamicPieGenerator(chartView, labels.getDynamicText()));
} else {
plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator());
}
}