List of usage examples for org.jfree.chart ChartFactory createPieChart
public static JFreeChart createPieChart(String title, PieDataset dataset, boolean legend, boolean tooltips, boolean urls)
From source file:org.pathvisio.cytoscape.superpathways.PieGenerator.java
public void generatePie(int number) { // Defining the dataset DefaultPieDataset dataset = new DefaultPieDataset(); for (int i = 0; i < number; i++) { String temp = String.valueOf(i); dataset.setValue(temp, 10);/* w w w . jav a2s . c om*/ } // Defining the chart JFreeChart chart = ChartFactory.createPieChart("", dataset, false, false, false); // Defining the chartPanel //final ChartPanel chartPanel = new ChartPanel(chart); //chartPanel.setPreferredSize(new java.awt.Dimension(350, 350)); //setContentPane(chartPanel); // Defining the plot PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelGenerator(null); plot.setInteriorGap(0.0); //add the following two lines to make the background transparent chart.setBackgroundPaint(new Color(255, 255, 255, 0)); plot.setBackgroundPaint(new Color(255, 255, 255, 0)); //plot.setBackgroundAlpha(0.0f); // Specify the colors here PieRenderer renderer = new PieRenderer(colors); renderer.setColor(plot, dataset); try { // This will create a PNG image ChartUtilities.saveChartAsPNG(new File(imageLocation + "chart.png"), chart, 280, 280, null, true, // encodeAlpha 0); } catch (Exception e) { System.out.println("Exception while creating the chart"); } }
From source file:com.googlecode.logVisualizer.chart.PieChartBuilder.java
private JFreeChart createChart(final PieDataset dataset) { final JFreeChart chart = ChartFactory.createPieChart(getTitle(), dataset, isIncludeLegend(), true, false); final PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setNoDataMessage("No data available"); plot.setIgnoreNullValues(true);//from w w w .ja v a 2 s . c om plot.setIgnoreZeroValues(true); return chart; }
From source file:org.apache.qpid.disttest.charting.writer.ChartWriterTest.java
@Override public void setUp() throws Exception { super.setUp(); DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("a", 1); dataset.setValue("b", 2); _chart1 = ChartFactory.createPieChart("chart1", dataset, true, true, false); _chart2 = ChartFactory.createPieChart("chart2", dataset, true, true, false); _chartDir = TestFileUtils.createTestDirectory(); _writer = new ChartWriter(); _writer.setOutputDirectory(_chartDir); }
From source file:com.js.quickestquail.ui.stats.ExtensionStat.java
private JFreeChart generateChart() { JFreeChart chart = ChartFactory.createPieChart( java.util.ResourceBundle.getBundle("i18n/i18n").getString("stat.extension.title"), // chart title generateDataset(), // data true, // include legend true, false);// w w w .j a v a 2 s. c om chart.setBackgroundPaint(new Color(0xFF, 0xFF, 0xFF, 0)); chart.getPlot().setBackgroundPaint(Color.WHITE); return chart; }
From source file:org.jfree.chart.swt.demo.SWTPieChartDemo1.java
/** * Creates a chart./*from www .j a v a 2 s . c o m*/ * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 1", // chart title dataset, // data true, // include legend true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); 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:sipl.recursos.Graficar.java
public boolean TipoMaterial(ArrayList<Tipo_material> TM, String direccion) throws IOException { boolean flag = false; DefaultPieDataset data = new DefaultPieDataset(); for (int i = 0; i < TM.size(); i++) { data.setValue("Cat." + TM.get(i).getId(), TM.get(i).getCantidad()); }/*w ww . j a va 2 s. c o m*/ JFreeChart chart = ChartFactory.createPieChart("Cantidad de materiales por categora", data, true, true, true); try { ChartUtilities.saveChartAsJPEG(new File(direccion), chart, 500, 500); flag = true; } catch (IOException e) { System.out.println("Error al abrir el archivo"); } return flag; }
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 www. jav a 2 s . com plot.setInteriorGap(0.0D); return new ChartPanel(piechart); }
From source file:ch.unibe.iam.scg.archie.ui.charts.PatientsChart.java
/** * (non-Javadoc)/* w w w.j a va2s . c om*/ * * @see ch.unibe.iam.scg.archie.ui.charts.AbstractChartComposite# * initializeChart() */ @Override protected JFreeChart initializeChart() { // create a chart... JFreeChart chart = ChartFactory.createPieChart(PatientsChart.CHART_TITLE, (DefaultPieDataset) this.creator.getDataset(), true, // legend? true, // tooltips? false // URLs? ); // Set chart background color to it's parents background chart.setBackgroundPaint(new Color(this.parent.getBackground().getRed(), this.parent.getBackground().getGreen(), this.parent.getBackground().getBlue())); return chart; }
From source file:cn.edu.thss.iise.bpmdemo.charts.SWTPieChartDemo1.java
/** * Creates a chart.//from ww w .j a va2 s . c o m * * @param dataset * the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 1", // chart // title dataset, // data true, // include legend true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); 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: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);/* w ww . j a va 2 s .c o m*/ plot.setInteriorGap(0.0D); return new ChartPanel(piechart); }