Example usage for org.jfree.chart.labels StandardPieSectionLabelGenerator StandardPieSectionLabelGenerator

List of usage examples for org.jfree.chart.labels StandardPieSectionLabelGenerator StandardPieSectionLabelGenerator

Introduction

In this page you can find the example usage for org.jfree.chart.labels StandardPieSectionLabelGenerator StandardPieSectionLabelGenerator.

Prototype

public StandardPieSectionLabelGenerator(String labelFormat) 

Source Link

Document

Creates a new section label generator using the specified label format string, and platform default number and percentage formatters.

Usage

From source file:edu.coeia.charts.PieChartPanel.java

private static JFreeChart createChart(final PieDataset dataset, String str) {
    final JFreeChart chart = ChartFactory.createPieChart3D(str, // chart title
            dataset, // data
            true, // include legend
            true, false);//from  ww w  .  j  av  a2 s .c  o m

    final PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(290);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    StandardPieSectionLabelGenerator labelGenerator = new StandardPieSectionLabelGenerator("{0} {2}");
    plot.setLabelGenerator(labelGenerator);
    plot.setNoDataMessage("No data to display");
    return chart;
}

From source file:gavisualizer.PieChart.java

@Override
public void generate() {
    // Creates Pie Chart from variables
    JFreeChart chart = ChartFactory.createPieChart(_title, // chart title
            _dataset, // data
            false, // include legend
            false, false);//from  w ww.  j a v  a 2 s. c  o m

    // Set Plot canvas color and direction
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    plot.setBackgroundPaint(Color.WHITE);

    /*
    *  Use these to edit the decimal percentage: 
    *       NumberFormat nf = NumberFormat.getPercentInstance();
    *       nf.setRoundingMode(RoundingMode.);
    *       nf.setMinimumFractionDigits(2);
    *       plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} {2}", NumberFormat.getNumberInstance(), nf));
    *  
    *  And remove line 63
    */

    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} {2}"));
    plot.setOutlinePaint(Color.white);

    _chart = chart;
}

From source file:com.tencent.wstt.apt.chart.PieChart.java

private JFreeChart createChart() {
    this.dataset = new DefaultPieDataset();
    final JFreeChart chart = ChartFactory.createPieChart("??", this.dataset, true, true, false);
    chart.getTitle().setFont(new Font("", Font.BOLD, 20));
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{1}"));
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);//from  ww w  . j a  v  a2s  .c om
    plot.setLabelGap(0.02);
    return chart;
}

From source file:room.utilization.PieChart.java

private JFreeChart createChart(PieDataset dataset) {
    JFreeChart chart = null;//from   www  .  j  a  va2 s.  c om
    PieSectionLabelGenerator pl = null;
    PiePlot3D plot = null;
    chart = ChartFactory.createPieChart3D(chartTitle, dataset, true, true, false);
    pl = new StandardPieSectionLabelGenerator("{0} = {2}");
    plot = (PiePlot3D) chart.getPlot();

    plot.setLabelGenerator(pl);
    plot.setLabelFont(new Font("Helvatica", Font.BOLD, 10));
    return chart;
}

From source file:com.jtk.pengelolaanujian.view.dashboard.PiePanelVnv.java

private ChartPanel createChart(PieDataset data) {
    piechart = ChartFactory.createPieChart("Soal Vnv", data, true, true, false);
    PiePlot plot = (PiePlot) piechart.getPlot();
    plot.setSectionPaint("Belum Di VNV", new Color(135, 206, 250));
    plot.setSectionPaint("sudah Di VNV", new Color(205, 133, 63));
    plot.setNoDataMessage("Data Tidak Ada");
    plot.setExplodePercent("data", 0.1D);
    plot.setLabelBackgroundPaint(new Color(255, 228, 225));
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})"));
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator());

    // Key = 0 ----> section as String (Windows, Linux, Lainnya)
    // Key = 1 ----> section as value (300,200,100)
    // KEy - 2 ----> section as percentage (50%,33%,17 %) Muncul jika aplikasi telah di running
    plot.setSimpleLabels(true);/* w  ww.  j  ava2s.c o  m*/
    plot.setInteriorGap(0.0D);
    return new ChartPanel(piechart);
}

From source file:com.jtk.pengelolaanujian.view.dashboard.PiePanelUjian.java

private ChartPanel createChart(PieDataset data) {
    piechart = ChartFactory.createPieChart("Ujian Status", data, true, true, false);
    PiePlot plot = (PiePlot) piechart.getPlot();
    plot.setSectionPaint("Terlalui", new Color(60, 70, 5));
    plot.setSectionPaint("Belum", new Color(100, 20, 30));
    plot.setNoDataMessage("Data Tidak Ada");
    plot.setExplodePercent("data", 0.1D);
    plot.setLabelBackgroundPaint(new Color(255, 228, 225));
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})"));
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator());

    // Key = 0 ----> section as String (Windows, Linux, Lainnya)
    // Key = 1 ----> section as value (300,200,100)
    // KEy - 2 ----> section as percentage (50%,33%,17 %) Muncul jika aplikasi telah di running

    plot.setSimpleLabels(true);//from  w  w  w. ja v a  2s. c o  m
    plot.setInteriorGap(0.0D);
    return new ChartPanel(piechart);
}

From source file:org.openmrs.module.usagestatistics.web.view.chart.FoundByChartView.java

@Override
protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) {
    UsageStatisticsService svc = Context.getService(UsageStatisticsService.class);
    int[] stats = svc.getFoundByStats(getFromDate(), getUntilInclusiveDate(), getLocation(), getUsageFilter());

    String labelLink = ContextProvider.getMessage("usagestatistics.foundBy.directLink");
    String labelId = ContextProvider.getMessage("usagestatistics.foundBy.idSearch");
    String labelName = ContextProvider.getMessage("usagestatistics.foundBy.nameSearch");

    double total = stats[0];
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue(labelLink, 100.0 * stats[1] / total);
    dataset.setValue(labelId, 100.0 * stats[2] / total);
    dataset.setValue(labelName, 100.0 * stats[3] / total);

    JFreeChart chart = ChartFactory.createPieChart(null, dataset, false, false, false);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setInteriorGap(0.0);/* w ww  . j  av a2 s .c o  m*/
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})"));
    plot.setLabelFont(getFont());

    return chart;
}

From source file:com.jtk.pengelolaanujian.view.dashboard.PiePanelNilai.java

private ChartPanel createChart(PieDataset data) {
    piechart = ChartFactory.createPieChart("Nilai Upload", data, true, true, false);
    PiePlot plot = (PiePlot) piechart.getPlot();
    plot.setSectionPaint("Belum Di Print", new Color(60, 70, 5));
    plot.setSectionPaint("Sudah Di Print", new Color(100, 20, 30));
    plot.setNoDataMessage("Data Tidak Ada");
    plot.setExplodePercent("data", 0.1D);
    plot.setLabelBackgroundPaint(new Color(255, 228, 225));
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})"));
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator());

    // Key = 0 ----> section as String (Windows, Linux, Lainnya)
    // Key = 1 ----> section as value (300,200,100)
    // KEy - 2 ----> section as percentage (50%,33%,17 %) Muncul jika aplikasi telah di running

    plot.setSimpleLabels(true);/* w  ww.j  a  v  a2s  .c  o m*/
    plot.setInteriorGap(0.0D);
    return new ChartPanel(piechart);
}

From source file:org.gaixie.micrite.jfreechart.style.PieStyle.java

/**
 * ?1 ,? Familiar(30%) /*from   w w  w .  ja v  a 2s  .c o m*/
 * @param chart
 */
public static void styleOne(JFreeChart chart) {
    PiePlot plot = (PiePlot) chart.getPlot();
    PieDataset pd = plot.getDataset();
    PieStyle.setBackground(chart);
    if (pd != null) {
        //?
        plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})"));
        //??
        for (int i = 0; i < pd.getItemCount(); i++) {
            int color = i % colors.length;
            plot.setSectionPaint(pd.getKey(i), colors[color]);
        }
    } else {
        plot.setNoDataMessage("NO DATA");
    }

}

From source file:com.jtk.pengelolaanujian.view.dashboard.PiePanelSoal.java

private ChartPanel createChart(PieDataset data) {

    piechart = ChartFactory.createPieChart("Soal Upload", data, true, true, false);
    PiePlot plot = (PiePlot) piechart.getPlot();
    plot.setSectionPaint("Belum Di Print", new Color(135, 206, 250));
    plot.setSectionPaint("Sudah Di Print", new Color(205, 133, 63));
    plot.setNoDataMessage("Data Tidak Ada");
    plot.setExplodePercent("data", 0.1D);
    plot.setLabelBackgroundPaint(new Color(255, 228, 225));
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})"));
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator());

    // Key = 0 ----> section as String (Windows, Linux, Lainnya)
    // Key = 1 ----> section as value (300,200,100)
    // KEy - 2 ----> section as percentage (50%,33%,17 %) Muncul jika aplikasi telah di running
    plot.setSimpleLabels(true);//from w  ww  .  j a  va  2 s  .co  m
    plot.setInteriorGap(0.0D);
    return new ChartPanel(piechart);
}