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();
}
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;
}
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;
}
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;
}
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;
}
Aggregations