Search in sources :

Example 6 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project MtgDesktopCompanion by nicho92.

the class ManaRepartitionPanel method refresh.

private void refresh() {
    this.removeAll();
    JFreeChart chart = ChartFactory.createPieChart3D(// chart title
    "Color repartition", // data
    getManaRepartitionDataSet(), // include legend
    false, true, true);
    pane = new ChartPanel(chart);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionPaint("Black", Color.BLACK);
    plot.setSectionPaint("White", Color.WHITE);
    plot.setSectionPaint("Blue", Color.BLUE);
    plot.setSectionPaint("Green", Color.GREEN);
    plot.setSectionPaint("Red", Color.RED);
    plot.setSectionPaint("Multi", Color.YELLOW);
    plot.setSectionPaint("Uncolor", Color.GRAY);
    plot.setSectionPaint("black", Color.BLACK);
    plot.setSectionPaint("white", Color.WHITE);
    plot.setSectionPaint("blue", Color.BLUE);
    plot.setSectionPaint("green", Color.GREEN);
    plot.setSectionPaint("red", Color.RED);
    plot.setSectionPaint("multi", Color.YELLOW);
    plot.setSectionPaint("uncolor", Color.GRAY);
    plot.setSimpleLabels(true);
    PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{1}", new DecimalFormat("0"), new DecimalFormat("0.00%"));
    plot.setLabelGenerator(generator);
    this.add(pane, BorderLayout.CENTER);
    this.revalidate();
    this.repaint();
}
Also used : ChartPanel(org.jfree.chart.ChartPanel) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) PieSectionLabelGenerator(org.jfree.chart.labels.PieSectionLabelGenerator) DecimalFormat(java.text.DecimalFormat) PiePlot(org.jfree.chart.plot.PiePlot) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) JFreeChart(org.jfree.chart.JFreeChart)

Example 7 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project dhis2-core by dhis2.

the class DefaultChartService method getMultiplePieChart.

private JFreeChart getMultiplePieChart(PlotData plotData, CategoryDataset[] dataSets) {
    JFreeChart multiplePieChart = ChartFactory.createMultiplePieChart(plotData.getName(), dataSets[0], TableOrder.BY_ROW, !plotData.isHideLegend(), false, false);
    setBasicConfig(multiplePieChart, plotData);
    if (multiplePieChart.getLegend() != null) {
        multiplePieChart.getLegend().setItemFont(SUB_TITLE_FONT);
    }
    MultiplePiePlot multiplePiePlot = (MultiplePiePlot) multiplePieChart.getPlot();
    JFreeChart pieChart = multiplePiePlot.getPieChart();
    pieChart.setBackgroundPaint(DEFAULT_BACKGROUND_COLOR);
    pieChart.getTitle().setFont(SUB_TITLE_FONT);
    PiePlot piePlot = (PiePlot) pieChart.getPlot();
    piePlot.setBackgroundPaint(DEFAULT_BACKGROUND_COLOR);
    piePlot.setOutlinePaint(DEFAULT_BACKGROUND_COLOR);
    piePlot.setLabelFont(LABEL_FONT);
    piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator("{2}"));
    piePlot.setSimpleLabels(true);
    piePlot.setIgnoreZeroValues(true);
    piePlot.setIgnoreNullValues(true);
    piePlot.setShadowXOffset(0d);
    piePlot.setShadowYOffset(0d);
    for (int i = 0; i < dataSets[0].getColumnCount(); i++) {
        piePlot.setSectionPaint(dataSets[0].getColumnKey(i), COLORS[(i % COLORS.length)]);
    }
    return multiplePieChart;
}
Also used : MultiplePiePlot(org.jfree.chart.plot.MultiplePiePlot) PiePlot(org.jfree.chart.plot.PiePlot) MultiplePiePlot(org.jfree.chart.plot.MultiplePiePlot) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) JFreeChart(org.jfree.chart.JFreeChart)

Example 8 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project GT by Tencent.

the class PieChart method createChart.

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);
    plot.setLabelGap(0.02);
    return chart;
}
Also used : DefaultPieDataset(org.jfree.data.general.DefaultPieDataset) PiePlot(org.jfree.chart.plot.PiePlot) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) JFreeChart(org.jfree.chart.JFreeChart) Font(java.awt.Font)

Example 9 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project Openfire by igniterealtime.

the class GraphEngine method getPieChart.

/**
     * Creates a Pie Chart based on map.
     *
     * @return the Pie Chart generated.
     */
public JFreeChart getPieChart(Map<String, Double> pieValues) {
    DefaultPieDataset dataset = new DefaultPieDataset();
    for (String key : pieValues.keySet()) {
        dataset.setValue(key, pieValues.get(key));
    }
    JFreeChart chart = ChartFactory.createPieChart3D(// chart title
    null, // data
    dataset, // include legend
    true, true, false);
    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(false);
    chart.setBorderPaint(null);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.BOLD, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(true);
    plot.setLabelGap(0.02);
    plot.setOutlinePaint(null);
    plot.setLabelLinksVisible(false);
    plot.setLabelGenerator(null);
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}"));
    plot.setStartAngle(270);
    plot.setDirection(Rotation.ANTICLOCKWISE);
    plot.setForegroundAlpha(0.60f);
    plot.setInteriorGap(0.33);
    return chart;
}
Also used : DefaultPieDataset(org.jfree.data.general.DefaultPieDataset) PiePlot(org.jfree.chart.plot.PiePlot) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) JFreeChart(org.jfree.chart.JFreeChart)

Example 10 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project EnrichmentMapApp by BaderLab.

the class ChartUtil method createRadialHeatMapLegend.

public static JFreeChart createRadialHeatMapLegend(List<EMDataSet> dataSets, ChartOptions options) {
    // All the slices must have the same size
    final DefaultPieDataset pieDataset = new DefaultPieDataset();
    for (EMDataSet ds : dataSets) pieDataset.setValue(ds.getName(), 1);
    JFreeChart chart = ChartFactory.createPieChart(// chart title
    null, // data
    pieDataset, // include legend
    false, // tooltips
    true, // urls
    false);
    chart.setAntiAlias(true);
    chart.setBorderVisible(false);
    chart.setBackgroundPaint(UIManager.getColor("Table.background"));
    chart.setBackgroundImageAlpha(0.0f);
    chart.setPadding(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    final PiePlot plot = (PiePlot) chart.getPlot();
    plot.setCircular(true);
    plot.setOutlineVisible(false);
    plot.setBackgroundPaint(UIManager.getColor("Table.background"));
    plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    plot.setShadowPaint(TRANSPARENT_COLOR);
    plot.setShadowXOffset(0.0);
    plot.setShadowYOffset(0.0);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}"));
    plot.setLabelFont(UIManager.getFont("Label.font").deriveFont(LookAndFeelUtil.getSmallFontSize()));
    plot.setLabelPaint(UIManager.getColor("Label.foreground"));
    plot.setLabelBackgroundPaint(TRANSPARENT_COLOR);
    plot.setLabelOutlinePaint(TRANSPARENT_COLOR);
    plot.setLabelShadowPaint(TRANSPARENT_COLOR);
    plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0}"));
    ColorScheme colorScheme = options != null ? options.getColorScheme() : null;
    List<Color> colors = colorScheme != null ? colorScheme.getColors() : null;
    if (// UP, ZERO, DOWN:
    colors == null || colors.size() < 3)
        colors = Arrays.asList(new Color[] { Color.LIGHT_GRAY, Color.WHITE, Color.DARK_GRAY });
    int total = dataSets.size();
    int v = total / -2;
    for (EMDataSet ds : dataSets) {
        plot.setSectionPaint(ds.getName(), ColorUtil.getColor(v, -total, total, colors.get(2), colors.get(1), colors.get(0)));
        v++;
    }
    return chart;
}
Also used : DefaultPieDataset(org.jfree.data.general.DefaultPieDataset) StandardPieToolTipGenerator(org.jfree.chart.labels.StandardPieToolTipGenerator) Color(java.awt.Color) ColorScheme(org.baderlab.csplugins.enrichmentmap.style.ColorScheme) RectangleInsets(org.jfree.ui.RectangleInsets) PiePlot(org.jfree.chart.plot.PiePlot) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) JFreeChart(org.jfree.chart.JFreeChart) Paint(java.awt.Paint)

Aggregations

StandardPieSectionLabelGenerator (org.jfree.chart.labels.StandardPieSectionLabelGenerator)13 PiePlot (org.jfree.chart.plot.PiePlot)12 JFreeChart (org.jfree.chart.JFreeChart)10 DecimalFormat (java.text.DecimalFormat)6 DefaultPieDataset (org.jfree.data.general.DefaultPieDataset)4 ChartPanel (org.jfree.chart.ChartPanel)3 PieSectionLabelGenerator (org.jfree.chart.labels.PieSectionLabelGenerator)3 TextTitle (org.jfree.chart.title.TextTitle)3 Font (java.awt.Font)2 BigDecimal (java.math.BigDecimal)2 NumberFormat (java.text.NumberFormat)2 MultiplePiePlot (org.jfree.chart.plot.MultiplePiePlot)2 PieDataset (org.jfree.data.general.PieDataset)2 Color (java.awt.Color)1 Paint (java.awt.Paint)1 Iterator (java.util.Iterator)1 List (java.util.List)1 CurrencyNode (jgnash.engine.CurrencyNode)1 Engine (jgnash.engine.Engine)1 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)1