mj1984jp / afreechart

Automatically exported from code.google.com/p/afreechart
0 stars 0 forks source link

How to set percentage on PieChart? #10

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

The pie chart showing the percentage with the label

What version of the product are you using? On what operating system?
0.0.4... Android 3.2

Please provide any additional information below.

I Want to show the percentage with the labels on the pie chart.

I was reading the sample, and I can't put the percentage...

createDataset:

dataset.setValue(series1, new Double(1.0));
        dataset.setValue(series2, new Double(4.0));
        dataset.setValue(series3, new Double(3.0));
        dataset.setValue(series4, new Double(5.0));
        dataset.setValue(series5, new Double(23.50));
        dataset.setValue(series6, new Double(13.27));
        dataset.setValue(series7, new Double(8.27));
        dataset.setValue(series8, new Double(22.12));
        dataset.setValue(series9, new Double(35.39));
        dataset.setValue(series10, new Double(15.14));
        dataset.setValue(series11, new Double(18.12));
        dataset.setValue(series12, new Double(0.0));

private static AFreeChart createChart(PieDataset dataset) {

        AFreeChart chart = ChartFactory.createPieChart(
                "", // chart title
                dataset, // data
                true, // include legend
                true,
                true);
        TextTitle title = chart.getTitle();
        title.setToolTipText("A title tooltip!");

        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setLabelFont(new Font("SansSerif", Typeface.NORMAL, 12));
        plot.setNoDataMessage("No data available");
        plot.setCircular(false);
       // plot.setLabelGap(0.02);
       // plot.setSimpleLabels(true);
        //plot.setExplodePercent(key, percent)
        plot.setExplodePercent(148.81, 1);

        return chart;

    }

Original issue reported on code.google.com by rafaelde...@gmail.com on 7 May 2012 at 7:23