Example usage for org.jfree.chart.plot PiePlot setLabelGap

List of usage examples for org.jfree.chart.plot PiePlot setLabelGap

Introduction

In this page you can find the example usage for org.jfree.chart.plot PiePlot setLabelGap.

Prototype

public void setLabelGap(double gap) 

Source Link

Document

Sets the gap between the edge of the pie and the labels (expressed as a percentage of the plot width) and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:com.wsn.PieChartDemo.java

/**
 * Creates a chart./* w w  w.  j  a  va2 s .  c o  m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo", // chart title
            dataset, // data
            true, // include legend
            true, false);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;

}

From source file:br.ufba.eleicoestransparentes.view.chart.GraficoPizza.java

/**
 * Creates a chart./*from www  . ja  v a  2  s  .  c  o m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset, String titulo) {

    JFreeChart chart = ChartFactory.createPieChart(titulo, // chart title
            dataset, // data
            true, // include legend
            true, false);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("Nenhum dado disponibilizado");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;

}

From source file:edu.wpi.cs.wpisuitetng.modules.requirementsmanager.view.charts.StatView.java

/**
 * Creates a chart./*from   w  w  w  .ja va 2 s . c o m*/
 * 
 * @param dataset
 *            the dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createPieStatusChart() {
    final StatusRequirementStatistics statusRequirementStatistics = new StatusRequirementStatistics();
    final JFreeChart chart = statusRequirementStatistics.buildPieChart();
    final PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(true);
    plot.setLabelGap(0.02);
    return chart;
}

From source file:weka.core.ChartUtils.java

/**
 * Create a pie chart from summary data (i.e. a list of values and their
 * corresponding frequencies).//from  www  .  j  a v  a2  s  .com
 * 
 * @param values a list of values for the chart
 * @param freqs a list of corresponding frequencies
 * @param showLabels true if the chart will show labels
 * @param showLegend true if the chart will show a legend
 * @param additionalArgs optional arguments to the renderer (may be null)
 * @return a pie chart
 * @throws Exception if a problem occurs
 */
protected static JFreeChart getPieChartFromSummaryData(List<String> values, List<Double> freqs,
        boolean showLabels, boolean showLegend, List<String> additionalArgs) throws Exception {

    if (values.size() != freqs.size()) {
        throw new Exception("Number of bins should be equal to number of frequencies!");
    }

    String plotTitle = "Pie Chart";
    String userTitle = getOption(additionalArgs, "-title");
    plotTitle = (userTitle != null) ? userTitle : plotTitle;
    String xLabel = getOption(additionalArgs, "-x-label");
    xLabel = xLabel == null ? "" : xLabel;
    String yLabel = getOption(additionalArgs, "-y-label");
    yLabel = yLabel == null ? "" : yLabel;

    DefaultPieDataset dataset = new DefaultPieDataset();

    for (int i = 0; i < values.size(); i++) {
        String binLabel = values.get(i);
        Number freq = freqs.get(i);

        dataset.setValue(binLabel, freq);
    }

    JFreeChart chart = ChartFactory.createPieChart(plotTitle, // chart title
            dataset, // data
            showLegend, // include legend
            false, false);

    PiePlot plot = (PiePlot) chart.getPlot();
    if (!showLabels) {
        plot.setLabelGenerator(null);
    } else {
        plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
        plot.setNoDataMessage("No data available");
        // plot.setCircular(false);
        plot.setLabelGap(0.02);
    }

    chart.setBackgroundPaint(java.awt.Color.white);
    chart.setTitle(new TextTitle(plotTitle, new Font("SansSerif", Font.BOLD, 12)));

    return chart;
}

From source file:charts.ErrorPorcentajePie.java

private JFreeChart createChart(PieDataset dataset, String title) {
    JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, true, false);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("no data");
    plot.setCircular(false);//from   www . j  ava  2 s.  c om
    plot.setLabelGap(0.02);
    return chart;
}

From source file:pingsnmpapp.classPieGraph.java

public JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart("Grfica de Disco", // chart title
            dataset, // data
            true, // include legend
            true, false);/* ww  w  .  j ava 2  s.  co  m*/

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;

}

From source file:charts.AceptadosRechazadosPie.java

private JFreeChart createChart(PieDataset dataset, String title) {
    JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, true, false);
    //                createBarChart(title, "Cantidades", "Estado de las trazas", dataset, PlotOrientation.VERTICAL, true, true, false);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 11));

    plot.setNoDataMessage("no data");
    plot.setCircular(false);//w w  w . ja v  a 2 s  .  c o m
    plot.setLabelGap(0.02);
    return chart;
}

From source file:com.rapidminer.gui.plotter.charts.RingChartPlotter.java

@Override
public JFreeChart createChart(PieDataset pieDataSet, boolean createLegend) {
    JFreeChart chart = ChartFactory.createRingChart(null, pieDataSet, createLegend, // legend
            true, false);//w ww .jav a2 s .co m

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 11));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);

    return chart;
}

From source file:org.talend.dataprofiler.chart.ChartDecorator.java

/**
 * //  w w w  .j  a  va2s  . co m
 * DOC qiongli Comment method "decoratePiePlot".
 * 
 * @param chart
 */
private static void decoratePiePlot(JFreeChart chart) {

    Font font = new Font("sans-serif", Font.BOLD, BASE_TITLE_LABEL_SIZE);//$NON-NLS-1$
    TextTitle textTitle = chart.getTitle();
    // MOD msjian TDQ-5213 2012-5-7: fixed NPE
    if (textTitle != null) {
        textTitle.setFont(font);
    }

    setLegendFont(chart);
    // TDQ-5213~
    PiePlot plot = (PiePlot) chart.getPlot();
    font = new Font("Monospaced", Font.PLAIN, 10);//$NON-NLS-1$
    plot.setLabelFont(font);
    plot.setNoDataMessage("No data available"); //$NON-NLS-1$
    StandardPieSectionLabelGenerator standardPieSectionLabelGenerator = new StandardPieSectionLabelGenerator(
            ("{0}:{2}"), //$NON-NLS-1$
            NumberFormat.getNumberInstance(), new DecimalFormat(PERCENT_FORMAT));
    plot.setLabelGenerator(standardPieSectionLabelGenerator);
    plot.setLabelLinkPaint(Color.GRAY);
    plot.setLabelOutlinePaint(Color.WHITE);
    plot.setLabelGap(0.02D);
    plot.setOutlineVisible(false);
    plot.setMaximumLabelWidth(0.2D);
    plot.setCircular(false);
    // remove the shadow of the pie chart
    plot.setShadowXOffset(0);
    plot.setShadowYOffset(0);
}

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 w w  w.j  a  v a  2 s .c o  m*/
    plot.setLabelGap(0.02);
    return chart;
}