List of usage examples for org.jfree.chart.plot PiePlot setSectionPaint
public void setSectionPaint(int section, Paint paint)
From source file:com.jtk.pengelolaanujian.view.dashboard.PiePanelNilai.java
private ChartPanel createChart(PieDataset data) { piechart = ChartFactory.createPieChart("Nilai Upload", data, true, true, false); PiePlot plot = (PiePlot) piechart.getPlot(); plot.setSectionPaint("Belum Di Print", new Color(60, 70, 5)); plot.setSectionPaint("Sudah Di Print", new Color(100, 20, 30)); plot.setNoDataMessage("Data Tidak Ada"); plot.setExplodePercent("data", 0.1D); plot.setLabelBackgroundPaint(new Color(255, 228, 225)); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})")); plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator()); // Key = 0 ----> section as String (Windows, Linux, Lainnya) // Key = 1 ----> section as value (300,200,100) // KEy - 2 ----> section as percentage (50%,33%,17 %) Muncul jika aplikasi telah di running plot.setSimpleLabels(true);//from ww w . j a v a 2 s . c om plot.setInteriorGap(0.0D); return new ChartPanel(piechart); }
From source file:net.footballpredictions.footballstats.swing.ResultsPieChart.java
/** * Updates the relative sizes of the pie chart segments. *///from w ww .ja v a 2 s. c o m public void updateGraph(int won, int drawn, int lost) { DefaultKeyedValues values = new DefaultKeyedValues(); values.addValue(messageResources.getString("headToHead.won"), won); values.addValue(messageResources.getString("headToHead.drawn"), drawn); values.addValue(messageResources.getString("headToHead.lost"), lost); PieDataset dataSet = new DefaultPieDataset(values); JFreeChart chart = ChartFactory.createPieChart(title, dataSet, false, // Legend. true, // Tooltips. false); // URLs. PiePlot plot = (PiePlot) chart.getPlot(); plot.setInteriorGap(0); plot.setSectionPaint(0, Colours.WIN); plot.setSectionPaint(1, Colours.DRAW); plot.setSectionPaint(2, Colours.DEFEAT); plot.setBackgroundPaint(null); plot.setOutlinePaint(null); plot.setLabelGenerator(null); plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0} {1} ({2})")); setChart(chart); }
From source file:com.jtk.pengelolaanujian.view.dashboard.PiePanelSoal.java
private ChartPanel createChart(PieDataset data) { piechart = ChartFactory.createPieChart("Soal Upload", data, true, true, false); PiePlot plot = (PiePlot) piechart.getPlot(); plot.setSectionPaint("Belum Di Print", new Color(135, 206, 250)); plot.setSectionPaint("Sudah Di Print", new Color(205, 133, 63)); plot.setNoDataMessage("Data Tidak Ada"); plot.setExplodePercent("data", 0.1D); plot.setLabelBackgroundPaint(new Color(255, 228, 225)); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})")); plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator()); // Key = 0 ----> section as String (Windows, Linux, Lainnya) // Key = 1 ----> section as value (300,200,100) // KEy - 2 ----> section as percentage (50%,33%,17 %) Muncul jika aplikasi telah di running plot.setSimpleLabels(true);//from w w w . j av a 2s .c om plot.setInteriorGap(0.0D); return new ChartPanel(piechart); }
From source file:com.googlecode.logVisualizer.chart.TotalConsumptionPie.java
@Override protected ChartPanel createChartPanel() { final ChartPanel panel = super.createChartPanel(); final PiePlot plot = (PiePlot) panel.getChart().getPlot(); plot.setSectionPaint("Eating", DEFAULT_COLORS[0]); plot.setSectionPaint("Drinking", DEFAULT_COLORS[1]); plot.setSectionPaint("Other", DEFAULT_COLORS[2]); plot.setSectionPaint("Rollover", DEFAULT_COLORS[3]); return panel; }
From source file:view.GerarGrafico.java
private JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Grfico de Transaes", // chart title dataset, // data true, // include legend true, false/* w w w.j a v a2 s. com*/ ); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionPaint("Provento", new Color(68, 157, 68)); plot.setSectionPaint("Despesa", new Color(217, 83, 79)); plot.setLabelFont(new Font("Segoue UI", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; }
From source file:servlet.SalesReportPieChart.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* w ww. j a v a 2 s . c o m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { DefaultPieDataset dataset = new DefaultPieDataset(); int totalTickets = Integer.valueOf(request.getParameter("totalTickets")); int totalSoldTickets = Integer.valueOf(request.getParameter("totalSoldTickets")); dataset.setValue("Unsold Tickets", new Double(totalTickets - totalSoldTickets)); dataset.setValue("Sold Tickets", new Double(totalSoldTickets)); JFreeChart chart = ChartFactory.createPieChart("Ticket Sales", // chart title dataset, // data true, // include legend true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionPaint("Unsold Tickets", Color.DARK_GRAY); plot.setSectionPaint("Sold Tickets", Color.CYAN); plot.setExplodePercent("Unsold Tickets", 0.10); plot.setSimpleLabels(true); plot.setBackgroundPaint(Color.WHITE); PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); plot.setLabelGenerator(gen); final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); int width = 500; /* Width of the image */ int height = 400; /* Height of the image */ response.setContentType("image/png"); OutputStream out = response.getOutputStream(); ChartUtilities.writeChartAsPNG(out, chart, 400, 300, info); }
From source file:org.sonar.server.charts.deprecated.PieChart.java
private void configureDefaultColors() { PiePlot plot = (PiePlot) jfreechart.getPlot(); for (int i = 0; i < COLORS.length; i++) { plot.setSectionPaint("" + i, COLORS[i]); }/*from w ww. j av a 2 s . c om*/ }
From source file:com.recomdata.charting.PieRenderer.java
public void setColor(PiePlot plot, PieDataset dataset) { List<Comparable> keys = dataset.getKeys(); int aInt;/*w w w . j a v a 2 s . co m*/ for (int i = 0; i < keys.size(); i++) { aInt = i % this.color.length; plot.setSectionPaint(keys.get(i), this.color[aInt]); } }
From source file:org.hxzon.demo.jfreechart.PieDatasetDemo2.java
private static JFreeChart createPieChart(PieDataset dataset, PieDataset previousDataset) { final boolean greenForIncrease = true; final boolean subTitle = true; final boolean showDifference = true; int percentDiffForMaxScale = 20; 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()); }/*from w w w.j a v a2 s .c o m*/ if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } @SuppressWarnings({ "rawtypes", "unchecked" }) List<Comparable> keys = dataset.getKeys(); DefaultPieDataset series = null; if (showDifference) { series = new DefaultPieDataset(); } double colorPerPercent = 255.0 / percentDiffForMaxScale; for (@SuppressWarnings("rawtypes") Comparable key : keys) { Number newValue = dataset.getValue(key); Number oldValue = previousDataset.getValue(key); if (oldValue == null) { if (greenForIncrease) { plot.setSectionPaint(key, Color.green); } else { plot.setSectionPaint(key, Color.red); } if (showDifference) { series.setValue(key + " (+100%)", newValue); } } else { double percentChange = (newValue.doubleValue() / oldValue.doubleValue() - 1.0) * 100.0; double shade = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255 : Math.abs(percentChange) * colorPerPercent); if (greenForIncrease && newValue.doubleValue() > oldValue.doubleValue() || !greenForIncrease && newValue.doubleValue() < oldValue.doubleValue()) { plot.setSectionPaint(key, new Color(0, (int) shade, 0)); } else { plot.setSectionPaint(key, new Color((int) shade, 0, 0)); } if (showDifference) { series.setValue( key + " (" + (percentChange >= 0 ? "+" : "") + NumberFormat.getPercentInstance().format(percentChange / 100.0) + ")", newValue); } } } if (showDifference) { plot.setDataset(series); } JFreeChart chart = new JFreeChart("Pie Chart Demo 2", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); if (subTitle) { TextTitle subtitle = null; subtitle = new TextTitle("Bright " + (greenForIncrease ? "red" : "green") + "=change >=-" + percentDiffForMaxScale + "%, Bright " + (!greenForIncrease ? "red" : "green") + "=change >=+" + percentDiffForMaxScale + "%", new Font("SansSerif", Font.PLAIN, 10)); chart.addSubtitle(subtitle); } plot.setNoDataMessage("No data available"); return chart; }
From source file:com.netsteadfast.greenstep.action.CommonPieChartAction.java
private void setPlotColor(PiePlot plot, List<String> names, List<String> colors) throws Exception { for (int ix = 0; ix < names.size(); ix++) { plot.setSectionPaint(names.get(ix), Color.decode(colors.get(ix))); }/* w ww .j av a2s. co m*/ }