List of usage examples for org.jfree.chart ChartFactory createPieChart3D
public static JFreeChart createPieChart3D(String title, PieDataset dataset, boolean legend, boolean tooltips, boolean urls)
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);/* w w w . j a v a2s .co 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:org.jw.service.factory.StatisticsChartFactory.java
public static JFreeChart createPieChart3D(PieDataset dataset, String title) { JFreeChart chart = ChartFactory.createPieChart3D(title, dataset, true, true, true); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setForegroundAlpha(0.5f);/* w w w . j av a 2s.com*/ plot.setDirection(Rotation.CLOCKWISE); return chart; }
From source file:net.sf.jasperreports.samples.jfreechart.JFreeChartScriptlet.java
/** * *//*from w ww . ja va 2 s .c o m*/ public void afterReportInit() throws JRScriptletException { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Java", new Double(43.2)); dataset.setValue("Visual Basic", new Double(10.0)); dataset.setValue("C/C++", new Double(17.5)); dataset.setValue("PHP", new Double(32.5)); dataset.setValue("Perl", new Double(1.0)); JFreeChart chart = ChartFactory.createPieChart3D("Pie Chart 3D Demo 1", dataset, true, true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); /* */ this.setVariableValue("Chart", new JCommonDrawableRenderer(chart)); }
From source file:org.posterita.core.PieChart.java
public JFreeChart createChart() throws OperationException { if (dataset == null) { throw new OperationException("Cannot create Pie chart: cause -> dataset empty!"); }// ww w. j a v a 2s . c om switch (type) { case PIE_FLAT: chart = ChartFactory.createPieChart(title, dataset, showLegend, showTooltip, true); break; case PIE_3D: chart = ChartFactory.createPieChart3D(title, dataset, showLegend, showTooltip, true); break; default: throw new OperationException("Invalid Piechart type! Can only be Piechart.PIE_FLAT or Piechart.PIE_3D"); } //setting subtitle if (subtitle != null) { TextTitle title = new TextTitle(subtitle); chart.addSubtitle(title); } return chart; }
From source file:room.utilization.PieChart.java
private JFreeChart createChart(PieDataset dataset) { JFreeChart chart = null;//from ww w . j a va 2 s.co m PieSectionLabelGenerator pl = null; PiePlot3D plot = null; chart = ChartFactory.createPieChart3D(chartTitle, dataset, true, true, false); pl = new StandardPieSectionLabelGenerator("{0} = {2}"); plot = (PiePlot3D) chart.getPlot(); plot.setLabelGenerator(pl); plot.setLabelFont(new Font("Helvatica", Font.BOLD, 10)); return chart; }
From source file:ntpgraphic.PieChart.java
private static JFreeChart createChart(PieDataset piedataset) { jfreechart = ChartFactory.createPieChart3D("Pie Chart 3D Demo 1", piedataset, true, true, false); PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot(); pieplot3d.setDarkerSides(true);/*from w w w . ja va 2 s . co m*/ pieplot3d.setStartAngle(36 * 9); pieplot3d.setNoDataMessage("No data to display"); return jfreechart; }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputPie.java
@Override public void createChart(final IScope scope) { super.createChart(scope); if (style.equals(IKeyword.THREE_D)) { chart = ChartFactory.createPieChart3D(getName(), null, false, true, false); } else if (style.equals(IKeyword.RING)) { chart = ChartFactory.createRingChart(getName(), null, false, true, false); } else if (style.equals(IKeyword.EXPLODED)) { chart = ChartFactory.createPieChart(getName(), null, false, true, false); } else {// ww w.j ava2 s. c o m chart = ChartFactory.createPieChart(getName(), null, false, true, false); } }
From source file:ws.moor.bt.gui.charts.BlockOrigin.java
private JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart3D("Block Origin", dataset, false, false, false); chart.setBackgroundPaint(Color.white); ((PiePlot3D) chart.getPlot()).setSectionPaint(0, Color.YELLOW); ((PiePlot3D) chart.getPlot()).setSectionPaint(0, Color.GREEN); return chart; }
From source file:net.sourceforge.processdash.ui.web.reports.PieChart.java
/** Create a line chart. */ @Override/* w ww . j av a 2 s. c o m*/ public JFreeChart createChart() { CategoryDataset catData = data.catDataSource(); PieDataset pieData = null; if (catData.getColumnCount() == 1) pieData = DatasetUtilities.createPieDatasetForColumn(catData, 0); else pieData = DatasetUtilities.createPieDatasetForRow(catData, 0); JFreeChart chart = null; if (get3DSetting()) { chart = ChartFactory.createPieChart3D(null, pieData, true, true, false); chart.getPlot().setForegroundAlpha(ALPHA); } else { chart = ChartFactory.createPieChart(null, pieData, true, true, false); } PiePlot plot = (PiePlot) chart.getPlot(); if (parameters.get("skipItemLabels") != null || parameters.get("skipWedgeLabels") != null) plot.setLabelGenerator(null); else if (parameters.get("wedgeLabelFontSize") != null) try { float fontSize = Float.parseFloat((String) parameters.get("wedgeLabelFontSize")); plot.setLabelFont(plot.getLabelFont().deriveFont(fontSize)); } catch (Exception lfe) { } if (parameters.get("ellipse") != null) plot.setCircular(true); else plot.setCircular(false); Object colorScheme = parameters.get("colorScheme"); if ("byPhase".equals(colorScheme)) maybeConfigurePhaseColors(plot, pieData); else if ("consistent".equals(colorScheme)) // since 2.0.9 configureConsistentColors(plot, pieData); else if (parameters.containsKey("c1")) configureIndividualColors(plot, pieData); String interiorGap = (String) parameters.get("interiorGap"); if (interiorGap != null) try { plot.setInteriorGap(Integer.parseInt(interiorGap) / 100.0); } catch (NumberFormatException e) { } String interiorSpacing = (String) parameters.get("interiorSpacing"); if (interiorSpacing != null) try { plot.setInteriorGap(Integer.parseInt(interiorSpacing) / 200.0); } catch (NumberFormatException e) { } if (!parameters.containsKey("showZeroValues")) { plot.setIgnoreZeroValues(true); plot.setIgnoreNullValues(true); } return chart; }
From source file:de.rbs90.fwdisp.settingsgui.gui.tabs.statistics.TypeStatisticsPanel.java
public TypeStatisticsPanel() { setName("EinsatzTyp"); setLayout(new BorderLayout()); DefaultPieDataset dataset = new DefaultPieDataset(); HashMap<String, Integer> alarmCount = new HashMap<>(); try {//from ww w.j av a 2s . com ResultSet resultSet = Starter.getDatabase().getStatement() .executeQuery("SELECT TYPE, COUNT(*) AS COUNT FROM ALARMHISTORY GROUP BY TYPE"); while (resultSet.next()) { String type = resultSet.getString("TYPE"); if (type.isEmpty()) type = "unbekannt"; int count = resultSet.getInt("COUNT"); type += " (" + count + ")"; alarmCount.put(type, count); } } catch (SQLException e) { e.printStackTrace(); } for (String key : alarmCount.keySet()) { dataset.setValue(key, alarmCount.get(key)); } JFreeChart chart = ChartFactory.createPieChart3D("Einsatztypen", dataset, false, false, false); chart.setBackgroundPaint(getBackground()); ChartPanel panel = new ChartPanel(chart); panel.setPopupMenu(null); panel.setBackground(getBackground()); add(panel, BorderLayout.CENTER); }