1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| private static JFreeChart createChart(PieDataset dataset) throws IOException {
JFreeChart chart = ChartFactory.createPieChart(null, // chart
// title
dataset, // data
false, // include legend
false, true);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setBackgroundAlpha(0);
plot.setOutlineVisible(false);
Color[] colors = { Color.black, Color.yellow, Color.green };
PieRenderer renderer = new PieRenderer(colors);
renderer.setColor(plot, (DefaultPieDataset) dataset);
//plot.setNoDataMessage("No data available");
plot.setCircular(true);
//plot.setLabelGap(0.02);
chart.setAntiAlias(true);
chart.setTextAntiAlias(true);
chart.setBorderVisible(false);
chart.setBackgroundPaint(new Color(255,255,255,0));
KeypointPNGEncoderAdapter encoder = new KeypointPNGEncoderAdapter();
encoder.setEncodingAlpha(true);
encoder.encode(chart.createBufferedImage(300, 300,BufferedImage.BITMASK , null));
return chart;
} |
Partager