public static JFreeChart createChart(String title, List <Result> results){
DefaultPieDataset pieDataset = new DefaultPieDataset();
Iterator<Result> itr = results.iterator();
while (itr.hasNext()) {
Result result = itr.next();
String itemName = result.getItemName();
BigDecimal itemResult = result.getItemResult();
pieDataset.setValue(itemName, itemResult);
}
JFreeChart chart = null;
try {
chart = ChartFactory.createPieChart(title, pieDataset,true, false, false);
} catch (Exception e) {
log.error("Threw a ParseException in createChart:, full message:",
e);
}
return chart;
}
如何翻转标签?
答案 0 :(得分:10)
您需要使用setLabelGenerator()
上的PiePlot
方法将标签生成器设置为null。您可以从图表中获取图表并将其投射到PiePlot
:
((PiePlot) chart.getPlot()).setLabelGenerator(null);