从JFreeChart饼图中删除标签

时间:2011-05-27 17:16:38

标签: java jfreechart labels pie-chart

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;
    }    

如何翻转标签?

1 个答案:

答案 0 :(得分:10)

您需要使用setLabelGenerator()上的PiePlot方法将标签生成器设置为null。您可以从图表中获取图表并将其投射到PiePlot

((PiePlot) chart.getPlot()).setLabelGenerator(null);