List of usage examples for org.jfree.chart.plot PiePlot setCircular
public void setCircular(boolean flag)
From source file:com.wsn.PieChartDemo.java
/** * Creates a chart./*ww w .j ava2 s .com*/ * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo", // chart title dataset, // data true, // include legend true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; }
From source file:br.ufba.eleicoestransparentes.view.chart.GraficoPizza.java
/** * Creates a chart./* w w w .j a va 2s . c om*/ * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset, String titulo) { JFreeChart chart = ChartFactory.createPieChart(titulo, // chart title dataset, // data true, // include legend true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("Nenhum dado disponibilizado"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; }
From source file:com.globalsight.util.JfreeCharUtil.java
public static void drawPieChart2D(String title, Map<String, Double> datas, File OutFile) { PieDataset dataset = buildDatas(datas); JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})", NumberFormat.getNumberInstance(), new DecimalFormat("0.00%"))); plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})")); chart.setBackgroundPaint(Color.white); plot.setCircular(true); TextTitle textTitle = new TextTitle(title); Font font = new Font(textTitle.getFont().getName(), Font.CENTER_BASELINE, 20); textTitle.setFont(font);//from w ww . ja v a2 s .c om chart.setTitle(textTitle); FileOutputStream fos_jpg = null; try { fos_jpg = new FileOutputStream(OutFile); ChartUtilities.writeChartAsJPEG(fos_jpg, 1, chart, 640, 480, null); fos_jpg.close(); } catch (Exception e) { s_logger.error(e.getMessage(), e); } }
From source file:edu.wpi.cs.wpisuitetng.modules.requirementsmanager.view.charts.StatView.java
/** * Creates a chart.//w w w . j a v a2 s.c o m * * @param dataset * the dataset. * * @return A chart. */ private static JFreeChart createPieStatusChart() { final StatusRequirementStatistics statusRequirementStatistics = new StatusRequirementStatistics(); final JFreeChart chart = statusRequirementStatistics.buildPieChart(); final PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(true); plot.setLabelGap(0.02); return chart; }
From source file:org.sipfoundry.sipxconfig.site.cdr.CdrReports.java
private static Image createTerminationCallsPieImage(List<CdrGraphBean> beans) { // Create a dataset DefaultPieDataset data = new DefaultPieDataset(); // Fill dataset with beans data for (CdrGraphBean terminationCall : beans) { data.setValue(terminationCall.getKey(), terminationCall.getCount()); }//from w ww.j a v a2s .c om // Create a chart with the dataset JFreeChart chart = ChartFactory.createPieChart(EMPTY_TITLE, data, true, true, true); chart.setBackgroundPaint(Color.lightGray); chart.getTitle().setPaint(Color.BLACK); PiePlot chartplot = (PiePlot) chart.getPlot(); chartplot.setCircular(true); chartplot.setLabelGenerator(new StandardPieSectionLabelGenerator(PIECHART_SECTIONLABEL_FORMAT)); // Create and return the image return chart.createBufferedImage(500, 220, BufferedImage.TYPE_INT_RGB, null); }
From source file:utils.Graphs.java
public static File generate(File baseFolder, String titles[], int[] values, Color backgroundColor) { DefaultPieDataset dataset = new DefaultPieDataset(); // add our data values int i = -1;//ww w.java 2 s . co m for (String title : titles) { i++; dataset.setValue(title, values[i]); } final JFreeChart chart = // ChartFactory.createPieChart("", dataset, true, true, false); ChartFactory.createPieChart("", // chart title dataset, // data true, // include legend true, false); PiePlot plot = (PiePlot) chart.getPlot(); //PiePlot3D plot = (PiePlot3D) chart.getPlot(); //plot.setStartAngle(290); plot.setStartAngle(45); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); // final PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(backgroundColor); // plot.setLegendLabelGenerator( // new StandardPieSectionLabelGenerator("{0} {2}")); chart.setBorderVisible(false); chart.getPlot().setOutlineVisible(false); chart.getLegend().setFrame(BlockBorder.NONE); // get the same background chart.setBackgroundPaint(backgroundColor); chart.getLegend().setBackgroundPaint(backgroundColor); // hide the shadow effects plot.setShadowXOffset(0); plot.setShadowYOffset(0); //chart.getLegend().setVisible(false); plot.setCircular(true); //plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} {2}", NumberFormat.getNumberInstance(), NumberFormat plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{2}", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance())); plot.setNoDataMessage("No data found."); Color greenColor = new Color(0x8FBC0C); Color redColor = new Color(0xFF0000); //Color redColor = new Color(0xDA6022); plot.setSectionPaint(0, greenColor); plot.setSectionPaint(1, redColor); plot.setSectionOutlinesVisible(true); final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file = new File(baseFolder, "chart.png"); try { ChartUtilities.saveChartAsPNG(file, chart, 200, 160, info); } catch (IOException ex) { Logger.getLogger(Graphs.class.getName()).log(Level.SEVERE, null, ex); } // //// final ChartPanel chartPanel = new ChartPanel(chart, true); // final ChartPanel chartPanel = new ChartPanel(chart, true); // chartPanel.setMinimumDrawWidth(0); // chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); // chartPanel.setMinimumDrawHeight(0); // chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); // JDialog dialog = new JDialog(); // dialog.add(chartPanel); // dialog.setLayout(new GridLayout(1, 1)); // dialog.setSize(400, 200); // dialog.setVisible(true); return file; }
From source file:org.jfree.chart.demo.PieChartDemo7.java
/** * Creates a new demo instance./*from w ww . ja v a 2s. c om*/ * * @param title the frame title. */ public PieChartDemo7(String title) { super(title); JPanel panel = new JPanel(new GridLayout(2, 2)); DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Section 1", 23.3); dataset.setValue("Section 2", 56.5); dataset.setValue("Section 3", 43.3); dataset.setValue("Section 4", 11.1); JFreeChart chart1 = ChartFactory.createPieChart("Chart 1", dataset, false, false, false); JFreeChart chart2 = ChartFactory.createPieChart("Chart 2", dataset, false, false, false); PiePlot plot2 = (PiePlot) chart2.getPlot(); plot2.setCircular(false); JFreeChart chart3 = ChartFactory.createPieChart3D("Chart 3", dataset, false, false, false); PiePlot3D plot3 = (PiePlot3D) chart3.getPlot(); plot3.setForegroundAlpha(0.6f); plot3.setCircular(true); JFreeChart chart4 = ChartFactory.createPieChart3D("Chart 4", dataset, false, false, false); PiePlot3D plot4 = (PiePlot3D) chart4.getPlot(); plot4.setForegroundAlpha(0.6f); panel.add(new ChartPanel(chart1)); panel.add(new ChartPanel(chart2)); panel.add(new ChartPanel(chart3)); panel.add(new ChartPanel(chart4)); panel.setPreferredSize(new Dimension(800, 600)); setContentPane(panel); }
From source file:com.netsteadfast.greenstep.action.CommonPieChartAction.java
private void fillChart(String title, List<String> names, List<String> colors, List<Float> values) throws Exception { DefaultPieDataset data = new DefaultPieDataset(); for (int ix = 0; ix < names.size(); ix++) { data.setValue(names.get(ix), values.get(ix)); }//from w ww. j a v a 2 s. c o m this.chart = ChartFactory.createPieChart3D(title, data, true, true, false); LegendTitle legend = this.chart.getLegend(); legend.setItemFont(new Font("", Font.TRUETYPE_FONT, 9)); PiePlot plot = (PiePlot) this.chart.getPlot(); plot.setCircular(true); plot.setBackgroundAlpha(0.9f); plot.setForegroundAlpha(0.5f); plot.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9)); this.setPlotColor(plot, names, colors); this.chart.setTitle(new TextTitle(title, new Font("", Font.TRUETYPE_FONT, 9))); }
From source file:charts.ErrorPorcentajePie.java
private JFreeChart createChart(PieDataset dataset, String title) { JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("no data"); plot.setCircular(false); plot.setLabelGap(0.02);/*from w w w . j a va2s .c o m*/ return chart; }
From source file:pingsnmpapp.classPieGraph.java
public JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Grfica de Disco", // chart title dataset, // data true, // include legend true, false);/*w w w. j a v a 2 s . c o m*/ PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; }