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:Vista.frm_MasVendidoCategoriaInforme.java
private void graficarDatos() { BL.Funciones_frm_MasVendido fun = new Funciones_frm_MasVendido(); try {/*from w ww. j a v a 2 s. c om*/ DefaultPieDataset data = new DefaultPieDataset(); for (int i = 0; i < id_categoria.length; i++) { data.setValue(categoria[i], fun.procentajeMasVendido(cantidad[i], sumatoriaCantidades())); } ChartPanel panel; JFreeChart chart = ChartFactory.createPieChart3D("PASTEL", data, true, true, true); panel = new ChartPanel(chart); panel.setBounds(0, 30, 450, 450); pan_derecha.add(panel); } catch (Exception e) { } }
From source file:org.hxzon.demo.jfreechart.PieDatasetDemo.java
private static JFreeChart createPieChart3D(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart3D("Pie Chart 3D Demo 1", // chart title dataset, // data true, // include legend true, false);//w w w . j a v a2s. c om PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setNoDataMessage("No data available"); return chart; }
From source file:teambootje.A2.java
public A2() { initComponents();//from w w w.j a v a2 s . co m setLocationRelativeTo(null); setLayout(new BorderLayout()); //Create and set up the window. setTitle("SS Rotterdam Analyse || Analyse 2"); ImageIcon icon = new ImageIcon("img/bootje.jpg"); setIconImage(icon.getImage()); // back BTN JButton back = new JButton("Back"); add(back, BorderLayout.NORTH); back.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); // panel en Label JPanel ana = new JPanel(); add(ana, BorderLayout.CENTER); //tabel String sql = "SELECT Datum, COUNT(*) AS Aantal FROM posts GROUP BY Datum"; List<Object[]> list = new ArrayList<Object[]>(); ResultSet rs = null; try { rs = db.runSql(sql); while (rs.next()) { String datum = rs.getString("Datum"); int aantal = rs.getInt("Aantal"); String[] row = new String[rs.getMetaData().getColumnCount()]; for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { row[i - 1] = rs.getString(i); } list.add(row); //chart JButton chart = new JButton("Chart"); add(chart, BorderLayout.SOUTH); chart.addActionListener(new ActionListener() { String dat = datum; int a1 = aantal; @Override public void actionPerformed(ActionEvent e) { DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue(dat, a1); pieDataset.setValue("2015-04-06", new Integer(5)); pieDataset.setValue("2015-04-05", new Integer(5)); pieDataset.setValue("2015-04-04", new Integer(14)); pieDataset.setValue("2015-04-03", new Integer(4)); pieDataset.setValue("2015-04-02", new Integer(1)); pieDataset.setValue("2015-04-01", new Integer(32)); pieDataset.setValue("2015-03-31", new Integer(32)); pieDataset.setValue("2015-03-30", new Integer(9)); pieDataset.setValue("2015-03-29", new Integer(4)); pieDataset.setValue("2015-03-28", new Integer(1)); pieDataset.setValue("2015-03-27", new Integer(3)); pieDataset.setValue("2015-03-26", new Integer(6)); pieDataset.setValue("2015-03-25", new Integer(1)); pieDataset.setValue("2015-03-24", new Integer(1)); pieDataset.setValue("2015-03-23", new Integer(1)); pieDataset.setValue("2015-03-22", new Integer(1)); pieDataset.setValue("2015-03-21", new Integer(1)); pieDataset.setValue("2015-03-20", new Integer(1)); pieDataset.setValue("2015-03-19", new Integer(1)); pieDataset.setValue("2015-03-18", new Integer(2)); pieDataset.setValue("2015-03-17", new Integer(1)); JFreeChart chart = ChartFactory.createPieChart3D("Aantal Posts per datum", pieDataset, true, true, true); PiePlot3D p = (PiePlot3D) chart.getPlot(); //p.setForegroundAlpha(TOP_ALIGNMENT); ChartFrame pie = new ChartFrame("Aantal Posts per datum", chart); pie.setVisible(true); pie.setSize(500, 500); pie.setLocationRelativeTo(null); //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); } } catch (SQLException e) { JOptionPane.showMessageDialog(null, e); } Object[][] array = new Object[list.size()][]; Object columnNames[] = { "Datum", "Aantal" }; list.toArray(array); JTable table = new JTable(array, columnNames); JScrollPane scroll = new JScrollPane(table); scroll.setPreferredSize(new Dimension(400, 400)); ana.add(scroll); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.PieChartExpression.java
protected JFreeChart computeChart(final Dataset dataset) { PieDataset pieDataset = null;/* ww w . java 2 s . c o m*/ if (dataset instanceof PieDataset) { pieDataset = (PieDataset) dataset; } if (isThreeD()) { return ChartFactory.createPieChart3D(computeTitle(), pieDataset, isShowLegend(), false, false); } else { return ChartFactory.createPieChart(computeTitle(), pieDataset, isShowLegend(), false, false); } }
From source file:userInterface.cdcRole.DecisionChartJPanel.java
private static JFreeChart createChart(PieDataset piedataset) { // System.out.println("1"); JFreeChart jfreechart = ChartFactory.createPieChart3D("Top 5 States (For Vaccinations)", piedataset, true, false, false);/*from w w w .ja v a 2s . c o m*/ PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot(); pieplot3d.setDrawingSupplier(new ChartDrawingSupplier()); pieplot3d.setStartAngle(270D); pieplot3d.setDirection(Rotation.ANTICLOCKWISE); pieplot3d.setForegroundAlpha(0.6F); return jfreechart; }
From source file:ch.unibe.iam.scg.archie.controller.ProviderChartFactory.java
/** * /*from ww w . j a v a2s . c o m*/ * @param pieDataset * @return */ private JFreeChart createJFreePieChart(PieDataset pieDataset) { if (this.model.isThreeDimensional()) { return ChartFactory.createPieChart3D(this.model.getChartName(), pieDataset, false, true, false); } return ChartFactory.createPieChart(this.model.getChartName(), pieDataset, false, true, false); }
From source file:org.jfree.chart.demo.ThumbnailDemo1.java
private static JFreeChart createChart2(PieDataset piedataset) { JFreeChart jfreechart = ChartFactory.createPieChart3D("Pie Chart 3D Demo 1", piedataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot(); pieplot3d.setDarkerSides(true);/*w ww . j av a2s .c o m*/ pieplot3d.setStartAngle(290D); pieplot3d.setDirection(Rotation.CLOCKWISE); pieplot3d.setForegroundAlpha(0.5F); pieplot3d.setOutlinePaint(null); pieplot3d.setNoDataMessage("No data to display"); return jfreechart; }
From source file:net.sf.jdmf.visualization.clustering.ChartGenerator.java
/** * Generates a pie chart showing the percentage of points falling into each * cluster.//from w w w .j a v a 2 s .c o m * * @param clusters clusters found by a clustering algorithm * @return a pie chart showing the distribution of points into clusters */ public JFreeChart generatePieChart(List<Cluster> clusters) { DefaultPieDataset dataset = new DefaultPieDataset(); for (Cluster cluster : clusters) { dataset.setValue(cluster.getName(), cluster.getPointPercentage()); } return ChartFactory.createPieChart3D("Cluster Analysis", dataset, true, true, false); }
From source file:org.cyberoam.iview.charts.CustomToolTipGeneratorForDiskUsage.java
/** * This method generates JFreeChart instance for 3D Pie chart with iView customization. * @param reportID specifies that for which report Chart is being prepared. * @param rsw specifies data set which would be used for the Chart * @param requeest used for Hyperlink generation from uri. * @return jfreechart instance with iView Customization. *///w ww . ja va 2 s.co m public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) { boolean xFlag = false; ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID); JFreeChart chart = null; try { ReportColumnBean reportColumnBean, reportColumnBeanX = null; GraphBean graphBean = null; DataLinkBean dataLinkBean = null; DefaultPieDataset dataset = new DefaultPieDataset(); graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());//Getting GraphBean reportColumnBeanX = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getXColumnId());//getting ReportColumnBean For X Axis // String xColumnDBname = reportColumnBeanX.getDbColumnName(); if (reportColumnBeanX.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBeanX.getDataLinkId()); } reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getZColumnId()); rsw.beforeFirst(); reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getYColumnId()); String yColumnName = reportColumnBean.getColumnName(); if (dataLinkBean == null && reportColumnBean.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId()); } String xData = null; while (rsw.next()) { xData = rsw.getString(reportColumnBeanX.getDbColumnName()); if (xData == null || "".equalsIgnoreCase(xData) || "null".equalsIgnoreCase(xData)) { xData = "N/A"; } else if (reportColumnBeanX.getColumnFormat() == TabularReportConstants.PROTOCOL_FORMATTING && xData.indexOf(':') != -1) { String data = data = ProtocolBean.getProtocolNameById(Integer.parseInt( rsw.getString(reportColumnBeanX.getDbColumnName()).substring(0, xData.indexOf(':')))); xData = data + rsw.getString(reportColumnBeanX.getDbColumnName()).substring(xData.indexOf(':'), xData.length()); } dataset.setValue(xData, new Long(rsw.getLong(reportColumnBean.getDbColumnName()))); } chart = ChartFactory.createPieChart3D("", // chart title dataset, // data true, // include legend true, // tooltips? false // URLs? ); /* *Setting additional customization to the chart. */ //Set the background color for the chart... chart.setBackgroundPaint(Color.white); //Get a reference to the plot for further customisation... PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setBackgroundAlpha(0.0f); plot.setSectionOutlinesVisible(false); plot.setOutlineVisible(false); plot.setStartAngle(290); plot.setDepthFactor(0.1); plot.setDirection(Rotation.CLOCKWISE); plot.setNoDataMessage("No data to display"); plot.setSectionOutlinesVisible(false); plot.setSectionOutlinePaint(Color.white); plot.setOutlineVisible(false); plot.setExplodePercent(dataset.getKey(0), 0.3); plot.setLabelLinkPaint(Color.gray); plot.setLabelBackgroundPaint(Color.white); plot.setLabelFont(new Font("Arial", Font.CENTER_BASELINE, 10)); plot.setLabelOutlinePaint(Color.white); plot.setLabelShadowPaint(Color.white); LegendTitle legend = chart.getLegend(); legend.setItemFont(new Font("Arial", Font.CENTER_BASELINE, 10)); legend.setMargin(0, 0, 2, 0); legend.setHorizontalAlignment(HorizontalAlignment.CENTER); plot.setToolTipGenerator(new CustomToolTipGeneratorForPie3D("{0}: ({1} " + yColumnName + ", {2})")); //Setting Color try { plot.setSectionPaint(dataset.getKey(0), new Color(0, 0, 254)); plot.setSectionPaint(dataset.getKey(1), new Color(255, 0, 254)); plot.setSectionPaint(dataset.getKey(2), new Color(176, 176, 255)); plot.setSectionPaint(dataset.getKey(3), new Color(255, 170, 255)); plot.setSectionPaint(dataset.getKey(4), new Color(69, 153, 204)); } catch (Exception e) { } } catch (Exception e) { CyberoamLogger.appLog.debug("Pie3D.e:" + e, e); } return chart; }
From source file:org.squale.squaleweb.util.graph.PieChartMaker.java
/** * Factorisation du code commun la gnration du graphe * //from w ww . j a v a 2 s. c o m * @param pRequest la requte * @return graphe de type Bubble */ private JFreeChart getCommonChart(HttpServletRequest pRequest) { JFreeChart chart = ChartFactory.createPieChart3D(mTitle, mDataSet, false, false, false); PiePlot3D pieplot3d = (PiePlot3D) chart.getPlot(); final double startAngle = 290D; pieplot3d.setStartAngle(startAngle); final float depthFactor = 0.1f; pieplot3d.setDepthFactor(depthFactor); pieplot3d.setDirection(Rotation.CLOCKWISE); final float foregroundAlpha = 0.5f; pieplot3d.setForegroundAlpha(foregroundAlpha); // Si on est en anglais, on laisse les nombre formates avec des "," pour sparer les milliers // Si on est en francais on remplace les "," par des points NumberFormat numberFormat = SqualeWebActionUtils.getNumberFormat(pRequest); // Pour le formatter de %, on laisse celui par dfaut pieplot3d.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {1} loc ({2})", numberFormat, NumberFormat.getPercentInstance())); return chart; }