开发者

Remove labels from JFreeChart Pie Chart

开发者 https://www.devze.com 2023-03-09 06:22 出处:网络
public static JFreeChart createChart(String title, List <Result> results){ DefaultPieDataset pieDataset = new DefaultPieDataset();
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 mes开发者_StackOverflowsage:",
                    e);
        }

    return chart;
    }    

How do I turn the labels of?


You will need to set the label generator to null, using the setLabelGenerator() method on PiePlot. You can get the plot from the chart and cast it to a PiePlot:

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

精彩评论

暂无评论...
验证码 换一张
取 消