org.jfree.data.general.PieDataset Java Examples

The following examples show how to use org.jfree.data.general.PieDataset. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StandardPieURLGenerator.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generates a URL.
 *
 * @param dataset  the dataset (ignored).
 * @param key  the item key ({@code null} not permitted).
 * @param pieIndex  the pie index.
 *
 * @return A string containing the generated URL.
 */
@Override
public String generateURL(PieDataset dataset, Comparable key,
        int pieIndex) {
    String url = this.prefix;
    try {
        if (url.contains("?")) {
            url += "&" + this.categoryParamName + "="
                    + URLEncoder.encode(key.toString(), "UTF-8");
        } else {
            url += "?" + this.categoryParamName + "="
                    + URLEncoder.encode(key.toString(), "UTF-8");
        }
        if (this.indexParamName != null) {
            url += "&" + this.indexParamName + "=" + pieIndex;
        }
    } catch (UnsupportedEncodingException e) {  // this won't happen :)
        throw new RuntimeException(e);
    }
    return url;
}
 
Example #2
Source File: AbstractPieItemLabelGenerator.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates the array of items that can be passed to the
 * {@link MessageFormat} class for creating labels.  The returned array
 * contains four values:
 * <ul>
 * <li>result[0] = the section key converted to a <code>String</code>;</li>
 * <li>result[1] = the formatted data value;</li>
 * <li>result[2] = the formatted percentage (of the total);</li>
 * <li>result[3] = the formatted total value.</li>
 * </ul>
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param key  the key (<code>null</code> not permitted).
 *
 * @return The items (never <code>null</code>).
 */
protected Object[] createItemArray(PieDataset dataset, Comparable key) {
    Object[] result = new Object[4];
    double total = DatasetUtilities.calculatePieDatasetTotal(dataset);
    result[0] = key.toString();
    Number value = dataset.getValue(key);
    if (value != null) {
        result[1] = this.numberFormat.format(value);
    }
    else {
        result[1] = "null";
    }
    double percent = 0.0;
    if (value != null) {
        double v = value.doubleValue();
        if (v > 0.0) {
            percent = v / total;
        }
    }
    result[2] = this.percentFormat.format(percent);
    result[3] = this.numberFormat.format(total);
    return result;
}
 
Example #3
Source File: ChartFactory.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a pie chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link PiePlot} instance
 * as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A pie chart.
 */
public static JFreeChart createPieChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    PiePlot plot = new PiePlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #4
Source File: SWTPieChartDemo1.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a chart.
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {
    
    JFreeChart chart = ChartFactory.createPieChart(
        "Pie Chart Demo 1",  // chart title
        dataset,             // data
        true,               // include legend
        true,
        false
    );

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;
    
}
 
Example #5
Source File: SWTPieChartDemo1.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a chart.
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {
    
    JFreeChart chart = ChartFactory.createPieChart(
        "Pie Chart Demo 1",  // chart title
        dataset,             // data
        true,               // include legend
        true,
        false
    );

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;        
}
 
Example #6
Source File: PiePlot.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the dataset and sends a {@link DatasetChangeEvent} to 'this'.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 * 
 * @see #getDataset()
 */
public void setDataset(PieDataset dataset) {
    // if there is an existing dataset, remove the plot from the list of 
    // change listeners...
    PieDataset existing = this.dataset;
    if (existing != null) {
        existing.removeChangeListener(this);
    }

    // set the new dataset, and register the chart as a change listener...
    this.dataset = dataset;
    if (dataset != null) {
        setDatasetGroup(dataset.getGroup());
        dataset.addChangeListener(this);
    }

    // send a dataset change event to self...
    DatasetChangeEvent event = new DatasetChangeEvent(this, dataset);
    datasetChanged(event);
}
 
Example #7
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a 3D pie chart using the specified dataset.  The chart object 
 * returned by this method uses a {@link PiePlot3D} instance as the
 * plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A pie chart.
 */
public static JFreeChart createPieChart3D(String title,
                                          PieDataset dataset,
                                          boolean legend,
                                          boolean tooltips,
                                          boolean urls) {

    PiePlot3D plot = new PiePlot3D(dataset);
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
            legend);

}
 
Example #8
Source File: ChartFactory.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a 3D pie chart using the specified dataset.  The chart object
 * returned by this method uses a {@link PiePlot3D} instance as the
 * plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A pie chart.
 */
public static JFreeChart createPieChart3D(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    PiePlot3D plot = new PiePlot3D(dataset);
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #9
Source File: AbstractPieItemLabelGenerator.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates the array of items that can be passed to the
 * {@link MessageFormat} class for creating labels.  The returned array
 * contains four values:
 * <ul>
 * <li>result[0] = the section key converted to a <code>String</code>;</li>
 * <li>result[1] = the formatted data value;</li>
 * <li>result[2] = the formatted percentage (of the total);</li>
 * <li>result[3] = the formatted total value.</li>
 * </ul>
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param key  the key (<code>null</code> not permitted).
 *
 * @return The items (never <code>null</code>).
 */
protected Object[] createItemArray(PieDataset dataset, Comparable key) {
    Object[] result = new Object[4];
    double total = DatasetUtilities.calculatePieDatasetTotal(dataset);
    result[0] = key.toString();
    Number value = dataset.getValue(key);
    if (value != null) {
        result[1] = this.numberFormat.format(value);
    }
    else {
        result[1] = "null";
    }
    double percent = 0.0;
    if (value != null) {
        double v = value.doubleValue();
        if (v > 0.0) {
            percent = v / total;
        }
    }
    result[2] = this.percentFormat.format(percent);
    result[3] = this.numberFormat.format(total);
    return result;
}
 
Example #10
Source File: ChartFactory.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A ring chart.
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #11
Source File: ChartFactory.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A ring chart.
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #12
Source File: ChartFactory.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a 3D pie chart using the specified dataset.  The chart object
 * returned by this method uses a {@link PiePlot3D} instance as the
 * plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @return A pie chart.
 *
 * @since 1.0.7
 */
public static JFreeChart createPieChart3D(String title, PieDataset dataset,
        boolean legend, boolean tooltips, Locale locale) {

    ParamChecks.nullNotPermitted(locale, "locale");
    PiePlot3D plot = new PiePlot3D(dataset);
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #13
Source File: ChartFactory.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a 3D pie chart using the specified dataset.  The chart object
 * returned by this method uses a {@link PiePlot3D} instance as the
 * plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A pie chart.
 */
public static JFreeChart createPieChart3D(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    PiePlot3D plot = new PiePlot3D(dataset);
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #14
Source File: PiePlot.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the dataset and sends a {@link DatasetChangeEvent} to 'this'.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @see #getDataset()
 */
public void setDataset(PieDataset dataset) {
    // if there is an existing dataset, remove the plot from the list of
    // change listeners...
    PieDataset existing = this.dataset;
    if (existing != null) {
        existing.removeChangeListener(this);
    }

    // set the new dataset, and register the chart as a change listener...
    this.dataset = dataset;
    if (dataset != null) {
        setDatasetGroup(dataset.getGroup());
        dataset.addChangeListener(this);
    }

    // send a dataset change event to self...
    DatasetChangeEvent event = new DatasetChangeEvent(this, dataset);
    datasetChanged(event);
}
 
Example #15
Source File: StandardPieURLGenerator.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Generates a URL.
 *
 * @param dataset  the dataset (ignored).
 * @param key  the item key ({@code null} not permitted).
 * @param pieIndex  the pie index.
 *
 * @return A string containing the generated URL.
 */
@Override
public String generateURL(PieDataset dataset, Comparable key,
        int pieIndex) {
    String url = this.prefix;
    try {
        if (url.contains("?")) {
            url += "&amp;" + this.categoryParamName + "="
                    + URLEncoder.encode(key.toString(), "UTF-8");
        } else {
            url += "?" + this.categoryParamName + "="
                    + URLEncoder.encode(key.toString(), "UTF-8");
        }
        if (this.indexParamName != null) {
            url += "&amp;" + this.indexParamName + "=" + pieIndex;
        }
    } catch (UnsupportedEncodingException e) {  // this won't happen :)
        throw new RuntimeException(e);
    }
    return url;
}
 
Example #16
Source File: AbstractPieItemLabelGenerator.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates the array of items that can be passed to the
 * {@link MessageFormat} class for creating labels.  The returned array
 * contains four values:
 * <ul>
 * <li>result[0] = the section key converted to a <code>String</code>;</li>
 * <li>result[1] = the formatted data value;</li>
 * <li>result[2] = the formatted percentage (of the total);</li>
 * <li>result[3] = the formatted total value.</li>
 * </ul>
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param key  the key (<code>null</code> not permitted).
 *
 * @return The items (never <code>null</code>).
 */
protected Object[] createItemArray(PieDataset dataset, Comparable key) {
    Object[] result = new Object[4];
    double total = DatasetUtilities.calculatePieDatasetTotal(dataset);
    result[0] = key.toString();
    Number value = dataset.getValue(key);
    if (value != null) {
        result[1] = this.numberFormat.format(value);
    }
    else {
        result[1] = "null";
    }
    double percent = 0.0;
    if (value != null) {
        double v = value.doubleValue();
        if (v > 0.0) {
            percent = v / total;
        }
    }
    result[2] = this.percentFormat.format(percent);
    result[3] = this.numberFormat.format(total);
    return result;
}
 
Example #17
Source File: PieChartWrapper.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public String generateSectionLabel(PieDataset dataset, Comparable key) {
    String result = null;
    if (dataset != null) {
        int value = dataset.getValue(key).intValue();
        if (value == 0) {
            return null;
        }

        if (enumKeyCls == null) {
            if (key instanceof Key) {
                return String.format("%s (%d)", StringUtils.trim(((Key) key).getDisplayName(), 20, true), value);
            } else {
                return String.format("%s (%d)", key.toString(), value);
            }

        } else {
            return String.format("%s (%d)", UserUIContext.getMessage(enumKeyCls, key.toString()), value);
        }
    }
    return result;
}
 
Example #18
Source File: ChartFactory.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a 3D pie chart using the specified dataset.  The chart object 
 * returned by this method uses a {@link PiePlot3D} instance as the
 * plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A pie chart.
 */
public static JFreeChart createPieChart3D(String title,
                                          PieDataset dataset,
                                          boolean legend,
                                          boolean tooltips,
                                          boolean urls) {

    PiePlot3D plot = new PiePlot3D(dataset);
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
            legend);

}
 
Example #19
Source File: SWTPieChartDemo1.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a chart.
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {
    
    JFreeChart chart = ChartFactory.createPieChart(
        "Pie Chart Demo 1",  // chart title
        dataset,             // data
        true,               // include legend
        true,
        false
    );

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;
    
}
 
Example #20
Source File: AbstractPieItemLabelGenerator.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Generates a label for a pie section.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param key  the section key (<code>null</code> not permitted).
 *
 * @return The label (possibly <code>null</code>).
 */
protected String generateSectionLabel(PieDataset dataset, Comparable key) {
    String result = null;
    if (dataset != null) {
        Object[] items = createItemArray(dataset, key);
        result = MessageFormat.format(this.labelFormat, items);
    }
    return result;
}
 
Example #21
Source File: PieChartDemo1.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a sample dataset.
 * 
 * @return A sample dataset.
 */
private static PieDataset createDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("One", new Double(43.2));
    dataset.setValue("Two", new Double(10.0));
    dataset.setValue("Three", new Double(27.5));
    dataset.setValue("Four", new Double(17.5));
    dataset.setValue("Five", new Double(11.0));
    dataset.setValue("Six", new Double(19.4));
    return dataset;        
}
 
Example #22
Source File: PieChartFXDemo1.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a sample dataset.
 * 
 * Source: http://www.bbc.co.uk/news/business-15489523
 *
 * @return A sample dataset.
 */
private static PieDataset createDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("Samsung", new Double(27.8));
    dataset.setValue("Others", new Double(55.3));
    dataset.setValue("Nokia", new Double(16.8));
    dataset.setValue("Apple", new Double(17.1));
    return dataset;
}
 
Example #23
Source File: PieChartFXDemo1.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a sample dataset.
 * 
 * Source: http://www.bbc.co.uk/news/business-15489523
 *
 * @return A sample dataset.
 */
private static PieDataset createDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("Samsung", new Double(27.8));
    dataset.setValue("Others", new Double(55.3));
    dataset.setValue("Nokia", new Double(16.8));
    dataset.setValue("Apple", new Double(17.1));
    return dataset;
}
 
Example #24
Source File: StatisticsController.java    From JDeSurvey with GNU Affero General Public License v3.0 5 votes vote down vote up
@Secured({"ROLE_ADMIN","ROLE_SURVEY_ADMIN"})
private JFreeChart createChart(PieDataset pieDataset, String title) {
try{
	JFreeChart chart = ChartFactory.createPieChart(title, pieDataset, false,true,false);

	chart.setBackgroundPaint(null);//this line necessary for transparency of background
       final ChartPanel chartPanel = new ChartPanel(chart);
       chartPanel.setOpaque(false); //this line necessary for transparency of background
       chartPanel.setBackground(new Color(0, 0, 0, 0)); //this line necessary for transparency of background
       
	PiePlot plot = (PiePlot) chart.getPlot();
	
	//Color[] colors = {new Color(170, 195, 217, 255),new Color(246, 140, 31, 255),new Color(204, 204, 204, 255),new Color(231, 238, 144, 255),new Color(51, 51, 51, 255),new Color(101, 125, 151, 255),new Color(0, 102, 255, 255)}; 
	//PieRenderer renderer = new PieRenderer(colors); 
	//renderer.setColor(plot, pieDataset);
	
	
	PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0}:{1}%"); 
	plot.setLabelGenerator(generator);
	
	plot.setStartAngle(270);
	plot.setDirection(Rotation.CLOCKWISE);
	
	return chart;
} catch (Exception e) {
	log.error(e.getMessage(),e);
	throw (new RuntimeException(e));
}
}
 
Example #25
Source File: OrdersChartPanel.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
private PieDataset getPieDataSet() {
	DefaultPieDataset dataset = new DefaultPieDataset();
	for (Entry<Object, Double> data : groupOrdersBy().entrySet()) {
		dataset.setValue(String.valueOf(data.getKey()), data.getValue());
	}

	return dataset;
}
 
Example #26
Source File: PieChartFXDemo1.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
@Override 
public void start(Stage stage) throws Exception {
    PieDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset); 
    ChartViewer viewer = new ChartViewer(chart);  
    stage.setScene(new Scene(viewer)); 
    stage.setTitle("JFreeChart: PieChartFXDemo1.java"); 
    stage.setWidth(700);
    stage.setHeight(390);
    stage.show(); 
}
 
Example #27
Source File: LegacyChartType.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private PieDataset createPieDataset() {
  final DefaultPieDataset dataset = new DefaultPieDataset();
  dataset.setValue( "Part 1", 23 );// NON-NLS
  dataset.setValue( "Part 2", 35 );// NON-NLS
  dataset.setValue( "Part 3", 42 );// NON-NLS
  return dataset;
}
 
Example #28
Source File: AbstractPieItemLabelGenerator.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Generates a label for a pie section.
 * 
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param key  the section key (<code>null</code> not permitted).
 * 
 * @return The label (possibly <code>null</code>).
 */
protected String generateSectionLabel(PieDataset dataset, Comparable key) {
    String result = null;    
    if (dataset != null) {
        Object[] items = createItemArray(dataset, key);
        result = MessageFormat.format(this.labelFormat, items);
    }
    return result;
}
 
Example #29
Source File: StatisticsController.java    From JDeSurvey with GNU Affero General Public License v3.0 5 votes vote down vote up
public void setColor(PiePlot plot, PieDataset dataset) 
{ 
    List <Comparable> keys = dataset.getKeys(); 
    int aInt; 

    for (int i = 0; i < keys.size(); i++) 
    { 
        aInt = i % this.color.length; 
        plot.setSectionPaint(keys.get(i), this.color[aInt]); 
    } 
}
 
Example #30
Source File: AbstractPieItemLabelGenerator.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Generates a label for a pie section.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param key  the section key (<code>null</code> not permitted).
 *
 * @return The label (possibly <code>null</code>).
 */
protected String generateSectionLabel(PieDataset dataset, Comparable key) {
    String result = null;
    if (dataset != null) {
        Object[] items = createItemArray(dataset, key);
        result = MessageFormat.format(this.labelFormat, items);
    }
    return result;
}