List of usage examples for org.jfree.chart.plot PiePlot setExplodePercent
public void setExplodePercent(int section, double percent)
From source file:com.ouc.cpss.view.SupTradeChartBuilder.java
private static JFreeChart createJFreeChart(PieDataset dataset) { /**/*from ww w. j a va 2 s .co m*/ * JFreeChart */ //? StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); // standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20)); // standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15)); //? standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15)); //? ChartFactory.setChartTheme(standardChartTheme); //?? //createPieChart 2D; createPieChart3D 3D JFreeChart chart = ChartFactory.createPieChart("", dataset, true, true, false); //,? chart.setTitle(new TextTitle("", new Font("", Font.ITALIC, 22))); //? LegendTitle legend = chart.getLegend(0); //,ture,? legend.setItemFont(new Font("", Font.BOLD, 20)); //?(??) PiePlot plot = (PiePlot) chart.getPlot(); //?==? plot.setLabelFont(new Font("", Font.BOLD, 22)); // plot.setBaseSectionOutlinePaint(Color.BLUE); // plot.setBaseSectionOutlineStroke(new BasicStroke(0.5f)); //?,??,?? plot.setDirection(Rotation.CLOCKWISE);//,Rotation.CLOCKWISE //() plot.setStartAngle(70); //??? //plot.setExplodePercent(1, 0.5D); //plot.setExplodePercent("One", 0.5D); //,3D? plot.setExplodePercent(dataset.getKey(0), 0.1d); // plot.setLabelLinkPaint(Color.BLUE); // plot.setLabelOutlinePaint(Color.black); // plot.setLabelShadowPaint(Color.RED); // plot.setSectionPaint(1, Color.BLACK); // :,{0},{1},{2}?,??? plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{1}\r\n{2}", NumberFormat.getNumberInstance(), new DecimalFormat("0.00%"))); // plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={2}")); //:(true),(false) plot.setCircular(true); //? plot.setNoDataMessage("??..."); //??? plot.setToolTipGenerator(new StandardPieToolTipGenerator()); // //plot.setURLGenerator(new StandardPieURLGenerator("detail.jsp")); return chart; }
From source file:org.jfree.chart.demo.PieChartDemo2.java
/** * Creates a sample chart./* w ww . ja v a 2 s. co m*/ * * @param dataset the dataset. * * @return a chart. */ private JFreeChart createChart(final PieDataset dataset) { final JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 2", // chart title dataset, // dataset true, // include legend true, false); final PiePlot plot = (PiePlot) chart.getPlot(); plot.setNoDataMessage("No data available"); plot.setExplodePercent(1, 0.30); return chart; }
From source file:org.getobjects.samples.HelloChart.Main.java
/** * This defines the direct action which can be invoked using:<pre> * /HelloThumbnail/wa/Main/chart?chs=128x128&chartType=p3</pre> * //w ww. j a va 2s .c o m * <p> * Note that the method returns a java.awt.BufferedImage. This will get * rendered to a GIF image by the GoDefaultRenderer. * (this method does not return a WOResponse, but it lets the Go machinery * deal with the image result object). * * @return a BufferedImage containing the scaled image */ public Object chartAction() { Dimension size = UGoogleChart.getDimensions(F("chs", "128x128"), null); String chartType = (String) F("cht", "p"); JFreeChart chart = null; if (chartType.equals("p")) { chart = ChartFactory.createPieChart((String) F("title", "Revenue Chart" /* default title */), this.getPieDataset(), UObject.boolValue(F("legend", true)) /* show legend */, UObject.boolValue(F("tooltips", true)) /* show tooltips */, false /* no URLs */); } else if (chartType.equals("p3")) { chart = ChartFactory.createPieChart3D((String) F("title", "Revenue Chart" /* default title */), this.getPieDataset(), UObject.boolValue(F("legend", true)) /* show legend */, UObject.boolValue(F("tooltips", true)) /* show tooltips */, false /* no URLs */); } else if (chartType.startsWith("b")) { // bhs, bvs (one bar with multiple values) // bhg, bvg (one bar for each row) PlotOrientation orientation = PlotOrientation.VERTICAL; if (chartType.startsWith("bh")) orientation = PlotOrientation.HORIZONTAL; if (chartType.endsWith("3")) { chart = ChartFactory.createBarChart3D((String) F("title", "Revenue Chart" /* default title */), (String) F("xlabel", "X-Axis"), (String) F("ylabel", "Y-Axis"), getCatDataSet(), orientation, UObject.boolValue(F("legend", true)) /* show legend */, UObject.boolValue(F("tooltips", true)) /* show tooltips */, false /* no URLs */); } else { chart = ChartFactory.createBarChart((String) F("title", "Revenue Chart" /* default title */), (String) F("xlabel", "X-Axis"), (String) F("ylabel", "Y-Axis"), getRevCatDataSet(), orientation, UObject.boolValue(F("legend", true)) /* show legend */, UObject.boolValue(F("tooltips", true)) /* show tooltips */, false /* no URLs */); } } /* style the chart */ chart.setBorderVisible(true); //chart.setBorderPaint(new Paint(Color.blue)); Paint p = new GradientPaint(0, 0, Color.white, 1000, 0, Color.blue); chart.setBackgroundPaint(p); /* style the plot */ Plot plot = chart.getPlot(); plot.setBackgroundPaint(new Color(240, 240, 250)); /* add explosion for Pies */ if (plot instanceof PiePlot) { PiePlot pplot = (PiePlot) chart.getPlot(); pplot.setExplodePercent("Products", 0.30); // can be multiple explodes } /* create the image for HTTP delivery */ return chart.createBufferedImage(size.width, size.height); }
From source file:servlet.SalesReportPieChart.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w . j a v a 2s .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:com.jtk.pengelolaanujian.view.dashboard.PiePanelUjian.java
private ChartPanel createChart(PieDataset data) { piechart = ChartFactory.createPieChart("Ujian Status", data, true, true, false); PiePlot plot = (PiePlot) piechart.getPlot(); plot.setSectionPaint("Terlalui", new Color(60, 70, 5)); plot.setSectionPaint("Belum", 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. ja v a 2 s. com plot.setInteriorGap(0.0D); return new ChartPanel(piechart); }
From source file:com.jtk.pengelolaanujian.view.dashboard.PiePanelVnv.java
private ChartPanel createChart(PieDataset data) { piechart = ChartFactory.createPieChart("Soal Vnv", data, true, true, false); PiePlot plot = (PiePlot) piechart.getPlot(); plot.setSectionPaint("Belum Di VNV", new Color(135, 206, 250)); plot.setSectionPaint("sudah Di VNV", 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 ww .java 2 s .co m plot.setInteriorGap(0.0D); return new ChartPanel(piechart); }
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);/* ww w .j a v a 2 s . c o m*/ plot.setInteriorGap(0.0D); return new ChartPanel(piechart); }
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. ja va 2 s. com*/ plot.setInteriorGap(0.0D); return new ChartPanel(piechart); }
From source file:result.analysis.Chart.java
void subjectWisePerformance(String batch, String sem, String[] colleges, String code) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (String college : colleges) { db = mongoClient.getDB(college); String collection_name = "cs_" + batch + "_" + sem + "_sem"; DBCollection collection = db.getCollection(collection_name); analyz = new Analyze(db); double number[] = analyz.GetSubjectPassPercent(collection, code); dataset.setValue(number[1] - number[0], college, "FAIL"); dataset.setValue(number[0], college, "PASS"); }//from w w w . j a va 2s. c o m JFreeChart pieChart = ChartFactory.createMultiplePieChart("Classwise Distribution", dataset, TableOrder.BY_ROW, true, true, true); // MultiplePiePlot plot = (PiePlot3D) pieChart.getPlot(); MultiplePiePlot plot = (MultiplePiePlot) pieChart.getPlot(); // plot.setStartAngle(290); // plot.setDirection(Rotation.CLOCKWISE); // plot.setForegroundAlpha(0.5f); JFreeChart subchart = plot.getPieChart(); PiePlot p = (PiePlot) subchart.getPlot(); p.setExplodePercent("PASS", 0.10); p.setExplodePercent("FAIL", 0.30); PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); p.setLabelGenerator(gen); ChartFrame frame = new ChartFrame("Subject Performance of " + batch + " year " + sem + " Semester ", pieChart); frame.setVisible(true); frame.setSize(500, 500); save_jpeg(pieChart); }
From source file:edu.ucla.stat.SOCR.chart.demo.PieChartDemo1.java
/** * Creates a chart/*from w ww .j a va2 s . c o m*/ * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart(chartTitle, // chart title dataset, // data !legendPanelOn, // include legend true, false); TextTitle title = chart.getTitle(); title.setToolTipText("A title tooltip!"); PiePlot plot = (PiePlot) chart.getPlot(); for (int i = 0; i < pulloutFlag.length; i++) { //System.out.println("\""+pulloutFlag[i]+"\""); if (isPullout(i)) { Comparable key = dataset.getKey(i); plot.setExplodePercent(key, 0.30); } } plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); setCategorySummary(dataset); if (rotateOn) { Rotator rotator = new Rotator(plot); rotator.start(); } return chart; }