List of usage examples for org.jfree.chart.plot PiePlot3D setCircular
public void setCircular(boolean flag)
From source file:com.globalsight.util.JfreeCharUtil.java
public static void drawPieChart3D(String title, Map<String, Double> datas, File OutFile) { PieDataset dataset = buildDatas(datas); JFreeChart chart = ChartFactory.createPieChart3D(title, dataset, true, true, false); PiePlot3D plot = (PiePlot3D) 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.setForegroundAlpha(0.7f);//ww w . java 2 s. c o m plot.setCircular(true); TextTitle textTitle = new TextTitle(title); Font font = new Font(textTitle.getFont().getName(), Font.CENTER_BASELINE, 20); textTitle.setFont(font); 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.requirementmanager.view.requirements.NewPieChartPanel.java
/** * @param dataset/*from ww w. j av a2 s.c o m*/ * the data to be displayed by the pie chart * @param title * the title of the chart @return the pie chart to be displayed */ private static JFreeChart createChart(PieDataset dataset, String title) { JFreeChart chart = ChartFactory.createPieChart3D(title, // chart title dataset, // data true, // include legend true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot();// 3D pie chart. the cats // are going to love // this. plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(true); plot.setLabelGap(0.02); plot.setStartAngle(270); plot.setDirection(Rotation.ANTICLOCKWISE); //Rotator rotator = new Rotator(plot); //rotator.start(); return chart; }
From source file:org.shredzone.bullshitcharts.chart.AgreementPieGenerator.java
@Override public Plot generate() { PieDatasetCreator dataset = new PieDatasetCreator(); dataset.addChoice("disagree"); // TODO: i18n dataset.addChoice("indecisive"); dataset.addChoice("agree"); dataset.setFavouriteChoice("agree"); dataset.setObnoxiousChoice("disagree"); dataset.setTendency(getTendency());/*from ww w . ja v a2 s .c om*/ PiePlot3D plot = new PiePlot3D(dataset.generate()); plot.setCircular(true); plot.setStartAngle(110d); plot.setForegroundAlpha(0.6f); plot.setDarkerSides(true); plot.setOutlineVisible(false); return plot; }
From source file:org.shredzone.bullshitcharts.chart.ChoicePieGenerator.java
@Override public Plot generate() { PieDatasetCreator dataset = new PieDatasetCreator(); String choice1 = getValue("c1", ""); String choice2 = getValue("c2", null); String choice3 = getValue("c3", null); String choice4 = getValue("c4", null); String choice5 = getValue("c5", null); dataset.addChoice(choice1);//from w w w. j a v a 2 s . c om dataset.setFavouriteChoice(choice1); if (choice2 != null) dataset.addChoice(choice2); if (choice3 != null) dataset.addChoice(choice3); if (choice4 != null) dataset.addChoice(choice4); if (choice5 != null) dataset.addChoice(choice5); dataset.setTendency(getTendency()); PiePlot3D plot = new PiePlot3D(dataset.generate()); plot.setCircular(true); plot.setStartAngle(110d); plot.setForegroundAlpha(0.6f); plot.setDarkerSides(true); plot.setOutlineVisible(false); return plot; }
From source file:org.jfree.chart.demo.PieChartDemo7.java
/** * Creates a new demo instance./*from ww w. j ava 2 s. c o m*/ * * @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:loansystem.visual.panel.StartPage.java
private void graficoPorEstado() { ArrayList<GraficoEntidad> graficos; graficos = gDao.obtenerPrestamosPorEstado(); DefaultPieDataset data = new DefaultPieDataset(); if (graficos.size() > 0) { for (GraficoEntidad result : graficos) { //datos.setValue(result.getValor(), result.getSerie(), result.getValorEje()); data.setValue(result.getValorEje(), result.getValor()); }// w w w .java2 s.co m //dibujarGrafico(datos, BAR, "Otorgado vs Recuperado", "Moneda", "Monto",PlotOrientation.VERTICAL,pnelOtorgadoRecuperado); // Creando el Grafico /*JFreeChart grafica = ChartFactory.createPieChart( "Prstamos por Estado", data, true, true, false);*/ JFreeChart grafica = ChartFactory.createPieChart3D("Prstamos por Estado", data, true, true, false); grafica.setBackgroundPaint(Color.white); PiePlot3D plot = (PiePlot3D) grafica.getPlot(); plot.setForegroundAlpha(0.6f); plot.setCircular(true); plot.setLabelGap(0.01); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} {1} ({2})")); plot.setBackgroundPaint(null); // Mostrar Grafico ChartPanel panel = new ChartPanel(grafica); pnelPorEstado.add(panel); pnelPorEstado.revalidate(); pnelPorEstado.repaint(); } }
From source file:com.uttesh.pdfngreport.handler.PdfReportHandler.java
/** * This method will generate the chart image file by using the Jfree chart * library// w w w . ja v a 2 s . co m * * @param dataSet * @throws FileNotFoundException * @throws IOException * * @see DefaultPieDataset */ public void generateChart(DefaultPieDataset dataSet, String os) throws FileNotFoundException, IOException { try { JFreeChart chart = ChartFactory.createPieChart3D("", dataSet, true, true, false); ChartStyle.theme(chart); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setForegroundAlpha(0.6f); plot.setCircular(true); plot.setSectionPaint("Passed", Color.decode("#019244")); plot.setSectionPaint("Failed", Color.decode("#EE6044")); plot.setSectionPaint("Skipped", Color.decode("#F0AD4E")); Color transparent = new Color(0.0f, 0.0f, 0.0f, 0.0f); plot.setLabelOutlinePaint(transparent); plot.setLabelBackgroundPaint(transparent); plot.setLabelShadowPaint(transparent); plot.setLabelLinkPaint(Color.GRAY); Font font = new Font("SansSerif", Font.PLAIN, 10); plot.setLabelFont(font); PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); plot.setLabelGenerator(gen); if (os != null && os.equalsIgnoreCase("w")) { ChartUtilities.saveChartAsPNG( new File(reportLocation + Constants.BACKWARD_SLASH + Constants.REPORT_CHART_FILE), chart, 560, 200); } else { ChartUtilities.saveChartAsPNG( new File(reportLocation + Constants.FORWARD_SLASH + Constants.REPORT_CHART_FILE), chart, 560, 200); } } catch (Exception e) { e.printStackTrace(System.err); if (os != null && os.equalsIgnoreCase("w")) { new File(reportLocation + Constants.BACKWARD_SLASH + Constants.REPORT_CHART_FILE).delete(); } else { new File(reportLocation + Constants.FORWARD_SLASH + Constants.REPORT_CHART_FILE).delete(); } System.exit(-1); } }
From source file:kcse_2013_results.Pie_Chart_KCSE_School_Performance.java
/** * Creates a chart./* w w w. j a v a2 s. c o m*/ * * @param dataset the dataset. * * @return A chart. */ public JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart3D("KCSE 2013 Results Summary ", // chart title dataset, // data true, // include legend true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setForegroundAlpha(0.95f); plot.setCircular(true); plot.setLabelGap(0.02); return chart; }
From source file:de.xirp.chart.ChartManager.java
/** * Returns a pie chart. The chart is generated from the given * {@link de.xirp.db.Record} and key array. The flag * <code>relative</code> indicated whether or not relative * values should be used./*from w w w. j a v a 2 s .c o m*/ * * @param record * The record containing the data. * @param keys * The keys to use. * @param relative * Flag indicating if relative values should be used. * @return A pie chart. * @see org.jfree.chart.JFreeChart * @see de.xirp.db.Record */ private static JFreeChart createPieChart(Record record, String[] keys, boolean relative) { String chartTitle = (relative ? I18n.getString("ChartManager.text.relative") //$NON-NLS-1$ : I18n.getString("ChartManager.text.absolute")) //$NON-NLS-1$ + I18n.getString("ChartManager.text.occurencesOfKey") + record.getName() + ": "; //$NON-NLS-1$ //$NON-NLS-2$ DefaultPieDataset dataset = new DefaultPieDataset(); Map<String, Long> values; values = ChartDatabaseUtil.getValuesForRecord(record, keys, relative); for (String s : values.keySet()) { dataset.setValue(s, values.get(s)); } JFreeChart chart; if (options.is(OptionName.THREE_D)) { chart = ChartFactory.createPieChart3D(chartTitle, dataset, true, true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage(NO_DATA_AVAILABLE); plot.setLabelGenerator(new CustomLabelGenerator(options)); } else { chart = ChartFactory.createPieChart(chartTitle, dataset, true, true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(true); plot.setNoDataMessage(NO_DATA_AVAILABLE); plot.setCircular(false); plot.setLabelGap(0.02); plot.setLabelGenerator(new CustomLabelGenerator(options)); } exportAutomatically(null, chart); return chart; }
From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminAuthView.java
private void drawGraph(String name, Integer[] responses) { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Answer 1", responses[0].doubleValue()); dataset.setValue("Answer 2", responses[1].doubleValue()); dataset.setValue("Answer 3", responses[2].doubleValue()); JFreeChart chart = ChartFactory.createPieChart3D(name, dataset, true, true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setForegroundAlpha(0.5f);/*from ww w . ja va 2s . c o m*/ plot.setCircular(true); final JFreeChartWrapper chartP = new JFreeChartWrapper(chart); GridLayout diagramLayout = new GridLayout(2, 2); diagramLayout.setSpacing(true); diagramLayout.setMargin(true); diagramLayout.setSizeFull(); diagramLayout.addComponent(chartP); diagramPanel.setContent(diagramLayout); }