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:teambootje.A1.java
public A1() { initComponents();//from w ww.j a v a 2 s.c om setLocationRelativeTo(null); setLayout(new BorderLayout()); setSize(500, 500); //Create and set up the window. setTitle("SS Rotterdam Analyse || Analyse 1"); 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 JPanel ana = new JPanel(); add(ana, BorderLayout.CENTER); //tabel String nvt = "SELECT Geslacht, COUNT(*) AS Aantal FROM persoon GROUP BY geslacht"; String male = "SELECT Geslacht AS male, COUNT(*) AS Aantal_Male FROM persoon WHERE Geslacht = 'man'"; String Female = "SELECT Geslacht AS female, COUNT(*) AS Aantal_Female FROM persoon WHERE Geslacht = 'vrouw'"; List<Object[]> list = new ArrayList<Object[]>(); ResultSet rs = null; try { rs = db.runSql(nvt); while (rs.next()) { String geslacht = rs.getString("Geslacht"); 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); try { rs = db.runSql(male); while (rs.next()) { String man = rs.getString("male"); int am = rs.getInt("Aantal_Male"); String[] row1 = new String[rs.getMetaData().getColumnCount()]; for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { row1[i - 1] = rs.getString(i); } try { rs = db.runSql(Female); while (rs.next()) { String vrouw = rs.getString("female"); int af = rs.getInt("Aantal_Female"); String[] row2 = new String[rs.getMetaData().getColumnCount()]; for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { row2[i - 1] = rs.getString(i); } Object[][] array = new Object[list.size()][]; Object columnNames[] = { "Geslacht", "Aantal" }; list.toArray(array); JTable table = new JTable(array, columnNames); JScrollPane scroll = new JScrollPane(table); scroll.setPreferredSize(new Dimension(400, 400)); ana.add(scroll); //chart JButton chart = new JButton("Chart"); add(chart, BorderLayout.SOUTH); chart.addActionListener(new ActionListener() { String g1 = geslacht; String m = man; String v = vrouw; int a1 = aantal; int a2 = am; int a3 = af; @Override public void actionPerformed(ActionEvent e) { DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue("Niet vrij gegeven", a1); pieDataset.setValue("Man", a2); pieDataset.setValue("vrouw", a3); JFreeChart chart = ChartFactory.createPieChart3D("Aantal mannen en vrouwen", pieDataset, true, true, true); PiePlot3D p = (PiePlot3D) chart.getPlot(); //p.setForegroundAlpha(TOP_ALIGNMENT); ChartFrame pie = new ChartFrame("Aantal mannen en vrouwen", 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 v) { JOptionPane.showMessageDialog(null, v); } } } catch (SQLException m) { JOptionPane.showMessageDialog(null, m); } } } catch (SQLException e) { JOptionPane.showMessageDialog(null, e); } }
From source file:userInterface.cdcRole.DecisionChartJPanel.java
private static JFreeChart createChart1(PieDataset piedataset) { JFreeChart jfreechart = ChartFactory.createPieChart3D("Top 5 Hospitals (For Orders Placed)", piedataset, true, false, false);/*w ww .j av a 2 s . com*/ PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot(); pieplot3d.setStartAngle(270D); pieplot3d.setDirection(Rotation.ANTICLOCKWISE); pieplot3d.setForegroundAlpha(0.6F); return jfreechart; }
From source file:org.cyberoam.iview.charts.CustomToolTipGeneratorForPie3D.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 w w . jav a2 s .c om*/ 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), Pie3D.pieSections[0]); plot.setSectionPaint(dataset.getKey(1), Pie3D.pieSections[1]); plot.setSectionPaint(dataset.getKey(2), Pie3D.pieSections[2]); plot.setSectionPaint(dataset.getKey(3), Pie3D.pieSections[3]); plot.setSectionPaint(dataset.getKey(4), Pie3D.pieSections[4]); } catch (Exception e) { } } catch (Exception e) { CyberoamLogger.appLog.debug("Pie3D.e:" + e, e); } return chart; }
From source file:com.vectorprint.report.jfree.ChartBuilder.java
private void prepareChart(Dataset data, CHARTTYPE type) throws VectorPrintException { switch (type) { case AREA:/* w ww . j a v a 2 s .c o m*/ chart = ChartFactory.createAreaChart(title, categoryLabel, valueLabel, null, getOrientation(), legend, tooltips, urls); case LINE: if (chart == null) { chart = ChartFactory.createLineChart(title, categoryLabel, valueLabel, null, getOrientation(), legend, tooltips, urls); } case LINE3D: if (chart == null) { chart = ChartFactory.createLineChart3D(title, categoryLabel, valueLabel, null, getOrientation(), legend, tooltips, urls); } case BAR: if (chart == null) { chart = ChartFactory.createBarChart(title, categoryLabel, valueLabel, null, getOrientation(), legend, tooltips, urls); } case BAR3D: if (chart == null) { chart = ChartFactory.createBarChart3D(title, categoryLabel, valueLabel, null, getOrientation(), legend, tooltips, urls); } if (data instanceof CategoryDataset) { CategoryDataset cd = (CategoryDataset) data; chart.getCategoryPlot().setDataset(cd); } else { throw new VectorPrintException("you should use CategoryDataset for this chart"); } break; case PIE: chart = ChartFactory.createPieChart(title, null, legend, tooltips, urls); case PIE3D: if (chart == null) { chart = ChartFactory.createPieChart3D(title, null, legend, tooltips, urls); } if (data instanceof PieDataset) { PieDataset pd = (PieDataset) data; PiePlot pp = (PiePlot) chart.getPlot(); pp.setDataset(pd); } else { throw new VectorPrintException("you should use PieDataset for this chart"); } break; case XYLINE: chart = ChartFactory.createXYLineChart(title, categoryLabel, valueLabel, null, getOrientation(), legend, tooltips, urls); case XYAREA: if (chart == null) { chart = ChartFactory.createXYAreaChart(title, categoryLabel, valueLabel, null, getOrientation(), legend, tooltips, urls); } if (data instanceof XYDataset) { XYDataset xy = (XYDataset) data; chart.getXYPlot().setDataset(xy); } else { throw new VectorPrintException("you should use XYDataset for this chart"); } break; case TIME: chart = ChartFactory.createTimeSeriesChart(title, categoryLabel, valueLabel, null, legend, tooltips, urls); if (data instanceof TimeSeriesCollection) { TimeSeriesCollection xy = (TimeSeriesCollection) data; chart.getXYPlot().setDataset(xy); } else { throw new VectorPrintException("you should use TimeSeriesCollection for this chart"); } break; default: throw new VectorPrintException("unsupported chart"); } chart.setAntiAlias(true); chart.setTextAntiAlias(true); }
From source file:pidev.presentation.Statistiques.java
private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton1ActionPerformed String requete = "select Count(id_Agence) from Agence "; System.out.println(requete);/*from www.ja v a 2s . com*/ try { Statement statement = MyConnection.getInstance().createStatement(); ResultSet resultat = statement.executeQuery(requete); while (resultat.next()) { nombredagence = resultat.getInt(1); } } catch (SQLException ex) { //Logger.getLogger(PersonneDao.class.getName()).log(Level.SEVERE, null, ex); System.out.println("erreur lors du chargement des annonces " + ex.getMessage()); } String requete2 = "select Count(id_Client) from Client "; System.out.println(requete2); try { Statement statement = MyConnection.getInstance().createStatement(); ResultSet resultat = statement.executeQuery(requete2); while (resultat.next()) { nombreclient = resultat.getInt(1); } } catch (SQLException ex) { //Logger.getLogger(PersonneDao.class.getName()).log(Level.SEVERE, null, ex); System.out.println("erreur lors du chargement des annonces " + ex.getMessage()); } DefaultPieDataset result = new DefaultPieDataset(); result.setValue("Agences", nombredagence); result.setValue("Clients", nombreclient); JFreeChart chart = ChartFactory.createPieChart3D("nombre d'agences + nombre de clients", result, true, true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); ChartFrame ch = new ChartFrame("Statistiques", chart); // ChartPanel ch = new ChartPanel(chart); ch.setSize(300, 300); ch.setLocationRelativeTo(null); ch.pack(); ch.setVisible(true); }
From source file:fr.gouv.diplomatie.applitutoriel.utility.Graphique.java
/** * Creer camember3 d.//from w ww. ja va2 s . c o m * * @param title * the title * @param dataset * the dataset * @param legend * the legend * @param tooltips * the tooltips * @param urls * the urls * @return the j free chart * @throws FontFormatException * the font format exception * @throws IOException * Signals that an I/O exception has occurred. */ public static JFreeChart creerCamember3D(final String title, final DefaultPieDataset dataset, final boolean legend, final boolean tooltips, final boolean urls) throws FontFormatException, IOException { dataset.sortByValues(SortOrder.DESCENDING); final JFreeChart jfreeChart = ChartFactory.createPieChart3D(title, dataset, legend, tooltips, urls); jfreeChart.setBackgroundPaint(Color.white); jfreeChart.setBorderVisible(true); jfreeChart.getLegend().setPosition(RectangleEdge.LEFT); final GraphicsEnvironment graph = GraphicsEnvironment.getLocalGraphicsEnvironment(); final InputStream inputStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("hornet/framework/font/LiberationSans-Bold.ttf"); final Font font = Font.createFont(Font.TRUETYPE_FONT, inputStream); graph.registerFont(font); jfreeChart.getLegend().setItemFont(new Font("Liberation Sans", Font.BOLD, 11)); jfreeChart.getLegend().setHeight(400); jfreeChart.getLegend().setBorder(0, 0, 0, 0); jfreeChart.setTitle(new TextTitle(title, new Font("Liberation Sans", Font.BOLD, 16))); final PiePlot piePlot = (PiePlot) jfreeChart.getPlot(); final int nbData = dataset.getItemCount(); int cptColor = 0; for (int x = 0; x < nbData; x++) { if (cptColor >= listColor.size()) { cptColor = 0; } piePlot.setSectionPaint(dataset.getKey(x), listColor.get(cptColor)); cptColor++; } piePlot.setForegroundAlpha(0.5f); piePlot.setLabelFont(new Font("Liberation Sans", Font.BOLD, 12)); piePlot.setLabelOutlineStroke(null); piePlot.setLabelLinkStroke(new BasicStroke(0.4f)); piePlot.setLabelBackgroundPaint(Color.WHITE); piePlot.setLabelLinkStyle(PieLabelLinkStyle.STANDARD); piePlot.setBackgroundAlpha(0); piePlot.setOutlineVisible(false); piePlot.setForegroundAlpha(1); // transparence piePlot.setInteriorGap(0); // le camembert occupe plus de place piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}")); piePlot.setStartAngle(70); piePlot.setCircular(true); // force pour avoir un cercle et pas un oval piePlot.setMaximumLabelWidth(0.20); piePlot.setBaseSectionOutlinePaint(Color.BLACK); // bordure du camembert return jfreeChart; }
From source file:fuel.gui.stats.MotorStatsPanel.java
private void refreshGraphs(Motorcycle motor) { graphContainer.removeAll();//from www . jav a2s.c o m if (motor != null) { DefaultPieDataset usageDataset = new DefaultPieDataset(); try { ResultSet thisMotor = database .Query("SELECT SUM(distance) FROM fuelrecords WHERE motorcycleId = " + motor.getId(), true); ResultSet otherMotors = database.Query( "SELECT SUM(distance) FROM fuelrecords WHERE NOT motorcycleId = " + motor.getId(), true); thisMotor.next(); otherMotors.next(); usageDataset.setValue(motor.toString(), thisMotor.getInt("1")); usageDataset.setValue("Andere motoren", otherMotors.getInt("1")); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart usagePiechart = ChartFactory.createPieChart3D("", usageDataset, true, true, false); PiePlot3D plot3 = (PiePlot3D) usagePiechart.getPlot(); plot3.setForegroundAlpha(0.6f); //plot3.setCircular(true); JPanel usagePiechartPanel = new ChartPanel(usagePiechart); usagePiechartPanel .setBorder(BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Motorgebruik"))); usagePiechartPanel.setPreferredSize(new java.awt.Dimension(240, 240)); usagePiechartPanel.setLayout(new BorderLayout()); DefaultPieDataset stationDataset = new DefaultPieDataset(); try { for (Station station : database.getStations()) { ResultSet numberStations = database.Query( "SELECT DISTINCT stationId FROM fuelrecords WHERE stationId = " + station.getId(), true); if (numberStations.next()) { ResultSet otherMotors = database.Query("SELECT COUNT(*) FROM fuelrecords WHERE stationId = " + station.getId() + " AND motorcycleId = " + motor.getId(), true); otherMotors.next(); if (otherMotors.getInt("1") > 0) { stationDataset.setValue(station.toString(), otherMotors.getInt("1")); } } } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart stationPiechart = ChartFactory.createPieChart3D("", stationDataset, true, true, false); PiePlot3D plot2 = (PiePlot3D) stationPiechart.getPlot(); plot2.setForegroundAlpha(0.6f); //plot3.setCircular(true); JPanel stationPiechartPanel = new ChartPanel(stationPiechart); stationPiechartPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Tankstation verhouding"))); stationPiechartPanel.setPreferredSize(new java.awt.Dimension(240, 240)); stationPiechartPanel.setLayout(new BorderLayout()); DefaultPieDataset fuelDataset = new DefaultPieDataset(); try { ResultSet numberResults = database.Query("SELECT DISTINCT typeOfGas FROM fuelrecords", true); while (numberResults.next()) { ResultSet thisStation = database.Query( "SELECT SUM(liter) FROM fuelrecords WHERE typeOfGas = '" + numberResults.getString("typeOfGas") + "'AND motorcycleId = " + motor.getId(), true); thisStation.next(); if (thisStation.getDouble("1") > 0) { fuelDataset.setValue(numberResults.getString("TYPEOFGAS"), thisStation.getDouble("1")); } } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart fuelPieChart = ChartFactory.createPieChart3D("", fuelDataset, true, true, false); PiePlot3D plot1 = (PiePlot3D) fuelPieChart.getPlot(); plot1.setForegroundAlpha(0.6f); //plot3.setCircular(true); JPanel fuelPieChartPanel = new ChartPanel(fuelPieChart); fuelPieChartPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Brandstof verhouding"))); fuelPieChartPanel.setPreferredSize(new java.awt.Dimension(240, 240)); DefaultCategoryDataset barDataset = new DefaultCategoryDataset(); try { ResultSet motorThing = database .Query("SELECT distance/liter,date FROM fuelrecords WHERE motorcycleId = " + motor.getId() + " ORDER BY date ASC", true); while (motorThing.next()) { barDataset.addValue(motorThing.getDouble("1"), motorThing.getString("DATE"), "Verbruik"); } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart barChart = ChartFactory.createBarChart3D("", // chart title "", // domain axis label "Aantal", // range axis label barDataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips? false // URLs? ); CategoryPlot plot = barChart.getCategoryPlot(); BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer(); renderer.setDrawBarOutline(false); ChartPanel barChartPanel = new ChartPanel(barChart); barChartPanel.getChartRenderingInfo().setEntityCollection(null); barChartPanel.setBorder(BorderFactory.createTitledBorder("Verbruik")); barChartPanel.setPreferredSize(new java.awt.Dimension(320, 240)); barChartPanel.setLayout(new BorderLayout()); JPanel piePanel = new JPanel(new GridLayout(0, 3)); piePanel.add(usagePiechartPanel); piePanel.add(stationPiechartPanel); piePanel.add(fuelPieChartPanel); //uitgaven DefaultPieDataset expensesDataset = new DefaultPieDataset(); try { Map<String, ResultSet> allCosts = new HashMap<String, ResultSet>(); ResultSet fuelCosts = database .Query("SELECT SUM(cost) FROM fuelrecords WHERE motorcycleId = " + motor.getId(), true); allCosts.put("Brandstof", fuelCosts); ResultSet expenses = database.Query("SELECT DISTINCT categoryid FROM expenses", true); while (expenses.next()) { ResultSet set = database.Query("SELECT SUM(costs) FROM expenses WHERE categoryid = " + expenses.getInt("categoryid") + " AND motorcycleid = " + motor.getId(), true); ResultSet set2 = database .Query("SELECT name FROM categories WHERE id = " + expenses.getInt("categoryid"), true); set2.next(); allCosts.put(set2.getString("name"), set); } for (Map.Entry<String, ResultSet> element : allCosts.entrySet()) { element.getValue().next(); if (element.getValue().getInt("1") > 0) { expensesDataset.setValue(element.getKey(), element.getValue().getInt("1")); } } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart expensesPiechart = ChartFactory.createPieChart3D("", expensesDataset, true, true, false); PiePlot3D plot4 = (PiePlot3D) expensesPiechart.getPlot(); plot4.setForegroundAlpha(0.6f); JPanel expensesPiePanel = new ChartPanel(expensesPiechart); expensesPiePanel .setBorder(BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Uitgaven"))); expensesPiePanel.setPreferredSize(new java.awt.Dimension(240, 240)); expensesPiePanel.setLayout(new BorderLayout()); graphContainer.add(piePanel); graphContainer.add(barChartPanel); graphContainer.add(expensesPiePanel); } revalidate(); repaint(); }
From source file:org.deegree.graphics.charts.ChartsBuilder.java
/** * Create a pie 2D/3D Pie Chart/*w ww .j av a2s .c o m*/ * * @param title * * @param keyedValues * The key/value pairs used for the pie chart * @param width * of the output image * @param height * height of the output image * @param is3D * is a 3D Chart * @param legend * for the output chart * @param tooltips * for the output chart * @param lblType * Possible types are <i>Key</i>, <i>Value</i>, <i>KeyValue</i> * @param imageType * of the output image * @param chartConfigs * to configure the output chart, or null to use the default ChartConfig * @return BufferedImage representing the generated chart */ public BufferedImage createPieChart(String title, QueuedMap<String, Double> keyedValues, int width, int height, boolean is3D, boolean legend, boolean tooltips, String lblType, String imageType, ChartConfig chartConfigs) { DefaultPieDataset dataset = new DefaultPieDataset(); Iterator<String> it = keyedValues.keySet().iterator(); while (it.hasNext()) { String key = it.next(); if ("KeyValue".equals(lblType)) { dataset.setValue(StringTools.concat(20, key, " ", keyedValues.get(key)), keyedValues.get(key)); } else if ("Value".equals(lblType)) { dataset.setValue(keyedValues.get(key), keyedValues.get(key)); } else { dataset.setValue(key, keyedValues.get(key)); } } JFreeChart chart = null; if (is3D) { chart = ChartFactory.createPieChart3D(title, dataset, legend, tooltips, false); } else { chart = ChartFactory.createPieChart(title, dataset, legend, tooltips, true); } if (chartConfigs == null) { chartConfigs = this.chartConfigs; } return createBufferedImage(configPieChart(chart, chartConfigs), width, height, imageType); }
From source file:edu.smc.mediacommons.panels.PasswordPanel.java
private JFreeChart createChart(final PieDataset dataset) { final JFreeChart chart = ChartFactory.createPieChart3D("Password Pie Chart", // chart title dataset, // data true, // include legend true, false);/*www .j a va 2 s .c o m*/ final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); plot.setLabelGenerator(new CustomLabelGenerator()); return chart; }
From source file:userInterface.cdcRole.DecisionChartJPanel.java
private static JFreeChart createChart2(PieDataset piedataset) { JFreeChart jfreechart = ChartFactory.createPieChart3D("Top 5 Vaccines", piedataset, true, false, false); PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot(); pieplot3d.setStartAngle(270D);/*from w w w.ja v a 2 s . c om*/ pieplot3d.setDirection(Rotation.ANTICLOCKWISE); pieplot3d.setForegroundAlpha(0.6F); return jfreechart; }