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:chart.PieChart3D.java
public static void main(String[] args) throws Exception { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("IPhone 5s", new Double(20)); dataset.setValue("SamSung Grand", new Double(20)); dataset.setValue("MotoG", new Double(40)); dataset.setValue("Nokia Lumia", new Double(10)); JFreeChart chart = ChartFactory.createPieChart3D("Mobile Sales", // chart title dataset, // data true, // include legend true, false);/*from w w w . j a v a 2 s .c o m*/ final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(270); plot.setForegroundAlpha(0.60f); plot.setInteriorGap(0.02); int width = 640; /* Width of the image */ int height = 480; /* Height of the image */ File pieChart3D = new File("pie_Chart3D.jpeg"); ChartUtilities.saveChartAsJPEG(pieChart3D, chart, width, height); }
From source file:statistique.PieChart3D.java
public static void main(String[] args) throws Exception { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("IPhone 5s", new Double(20)); dataset.setValue("SamSung Grand", new Double(20)); dataset.setValue("MotoG", new Double(40)); dataset.setValue("Nokia Lumia", new Double(10)); JFreeChart chart = ChartFactory.createPieChart3D("Mobile Sales", // chart title dataset, // data true, // include legend true, false);/*from w w w . j ava 2s.c om*/ final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(270); plot.setForegroundAlpha(0.60f); plot.setInteriorGap(0.02); int width = 640; /* Width of the image */ int height = 480; /* Height of the image */ File pieChart3D = new File("pie_Chart3D.png"); ChartUtilities.saveChartAsPNG(pieChart3D, chart, width, height); }
From source file:id.aas.apps.mvc.view.pieChart.java
public static void main(String[] args) throws SQLException { // pieChart p = new pieChart(); // p.setVisible(true); // p.run(); EventQueue.invokeLater(new Runnable() { @Override/*from w w w. j a v a 2s . c o m*/ public void run() { try { int nilaiKiloan = 0; int nilaiSatuan = 0; pieChart frame = new pieChart(); frame.setVisible(true); String queryKiloan = "SELECT COUNT(*) FROM laundry WHERE jenis_layanan='Laundry Kiloan'"; String querySatuan = "SELECT COUNT(*) FROM laundry WHERE jenis_layanan='Laundry Satuan'"; ConnectionDB.InstanceDB.openConnection(); ResultSet rs = ConnectionDB.InstanceDB.RunSelectQuery(queryKiloan); while (rs.next()) { nilaiKiloan = rs.getInt(1); } System.out.println(nilaiKiloan); ResultSet rs1 = ConnectionDB.InstanceDB.RunSelectQuery(querySatuan); while (rs1.next()) { nilaiSatuan = rs1.getInt(1); } System.out.println(nilaiSatuan); DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue("Laundry Kiloan", nilaiKiloan); pieDataset.setValue("Laundry Satuan", nilaiSatuan); JFreeChart chart = ChartFactory.createPieChart3D("Perbandingan Pengguna Layanan Laundry", pieDataset, true, true, false); ChartPanel cPanel = new ChartPanel(chart); frame.setContentPane(cPanel); } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:CalcoloRitardiLotti.java
public static void main(String[] args) { String id_ref = "cbededce-269f-48d2-8c25-2359bf246f42"; String requestString = "http://dati.openexpo2015.it/catalog/api/action/datastore_search?resource_id=" + id_ref;// ww w . j ava2s. c om HttpClient client = HttpClientBuilder.create().build(); HttpGet request = new HttpGet(requestString); try { HttpResponse response = client.execute(request); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); String result = ""; String resline = ""; Calendar c = Calendar.getInstance(); Date current = Date.valueOf( c.get(Calendar.YEAR) + "-" + (c.get(Calendar.MONTH) + 1) + "-" + c.get(Calendar.DAY_OF_MONTH)); while ((resline = rd.readLine()) != null) result += resline; //System.out.println(jsonObject.toString()); if (result != null) { JSONObject jsonObject = new JSONObject(result); JSONObject resultJson = (JSONObject) jsonObject.get("result"); JSONArray records = (JSONArray) resultJson.get("records"); Date temp1, temp2; //System.out.printf(records.toString()); long diffInizioFineLavori; long ritardo; long den = (24 * 60 * 60 * 1000); JSONObject temp; DefaultCategoryDataset cdata = new DefaultCategoryDataset(); String partialQuery; DefaultPieDataset data = new DefaultPieDataset(); String totalQuery = ""; int countSospesi = 0; int countConclusi = 0; int countVerifica = 0; int countInCorso = 0; int countCollaudo = 0; String stato; for (int i = 0; i < records.length(); i++) { temp = (JSONObject) records.get(i); temp1 = Date.valueOf((temp.getString("Data Consegna Lavori")).substring(0, 10)); temp2 = Date.valueOf((temp.getString("Data Fine lavori")).substring(0, 10)); diffInizioFineLavori = (long) (temp2.getTime() - temp1.getTime()) / den; stato = temp.getString("STATO"); if (stato.equals("Concluso")) countConclusi++; else if (stato.equals("In corso")) countInCorso++; else if (stato.contains("Verifiche")) countVerifica++; else if (stato.contains("Collaudo sospeso") || stato.contains("sospeso")) countSospesi++; else countCollaudo++; if (!temp.getString("STATO").equals("Concluso") && temp2.getTime() < current.getTime()) ritardo = (long) (current.getTime() - temp2.getTime()) / den; else ritardo = 0; cdata.setValue(ritardo, String.valueOf(i + 1), String.valueOf(i + 1)); System.out.println( "Opera: " + temp.getString("Oggetto del lotto") + " | id: " + temp.getInt("_id")); System.out.println("Data consegna lavoro: " + temp.getString("Data Consegna Lavori") + " | Data fine lavoro: " + temp.getString("Data Fine lavori")); System.out.println("STATO: " + temp.getString("STATO")); System.out.println("Differenza in giorni: " + diffInizioFineLavori + " | Numero giorni contrattuali: " + temp.getString("numero di giorni contrattuali")); System.out.println("Ritardo accumulato: " + ritardo); System.out.println("----------------------------------"); partialQuery = "\nid: " + temp.getInt("_id") + "\nOpera:" + temp.getString("Oggetto del lotto") + "\n" + "Data consegna lavoro: " + temp.getString("Data Consegna Lavori") + "Data fine lavoro: " + temp.getString("Data Fine lavori") + "\n" + "STATO: " + temp.getString("STATO") + "\n" + "Differenza in giorni: " + diffInizioFineLavori + " - Numero giorni contrattuali: " + temp.getString("numero di giorni contrattuali") + "\n" + "Ritardo accumulato: " + ritardo + "\n" + "----------------------------------\n"; totalQuery = totalQuery + partialQuery; } JFreeChart chart1 = ChartFactory.createBarChart3D("RITARDI AL " + current, "Id lotto", "ritardo(in giorni)", cdata); ChartRenderingInfo info = null; ChartUtilities.saveChartAsPNG( new File(System.getProperty("user.dir") + "/istogramma" + current + ".png"), chart1, 1500, 1500, info, true, 10); FileUtils.writeStringToFile(new File(current + "_1.txt"), totalQuery); data.setValue("Conclusi: " + countConclusi, countConclusi); data.setValue("Sospeso: " + countSospesi, countSospesi); data.setValue("In Corso: " + countInCorso, countInCorso); data.setValue("Verifica: " + countVerifica, countVerifica); data.setValue("Collaudo: " + countCollaudo, countCollaudo); JFreeChart chart2 = ChartFactory.createPieChart3D("Statistiche del " + current, data, true, true, true); ChartUtilities.saveChartAsPNG(new File(System.getProperty("user.dir") + "/pie" + current + ".png"), chart2, 800, 450); } } catch (Exception e) { e.printStackTrace(); } }
From source file:graphic.Grafico.java
private static javax.swing.JPanel pizza3D(ArrayList nome, ArrayList valor, String tituloGrafico, float transparencia, String tipo) { DefaultPieDataset data = new DefaultPieDataset(); for (int i = 0; i < nome.toArray().length; i++) { data.setValue("" + nome.get(i).toString(), new Double(valor.get(i).toString())); }//from www.j av a2s . c o m JFreeChart chart = ChartFactory.createPieChart3D(tituloGrafico, data, true, true, true); java.awt.Color cor = new java.awt.Color(200, 200, 200); chart.setBackgroundPaint(cor); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setLabelLinksVisible(true); plot.setNoDataMessage("No existem dados para serem exibidos no grfico"); plot.setStartAngle(90); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(transparencia); plot.setInteriorGap(0.20); ChartPanel chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:br.com.ifpb.models.Grafico.java
/** * /* w w w .j ava 2 s. c o m*/ * @param nome * @param valor * @param tituloGrafico * @param transparencia * @param tipo * @return */ private static javax.swing.JPanel pizza3D(ArrayList nome, ArrayList valor, String tituloGrafico, float transparencia, String tipo) { DefaultPieDataset data = new DefaultPieDataset(); for (int i = 0; i < nome.toArray().length; i++) { data.setValue("" + nome.get(i).toString(), new Double(valor.get(i).toString())); } JFreeChart chart = ChartFactory.createPieChart3D(tituloGrafico, data, true, true, true); java.awt.Color cor = new java.awt.Color(200, 200, 200); chart.setBackgroundPaint(cor); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setLabelLinksVisible(true); plot.setNoDataMessage("No existem dados para serem exibidos "); plot.setStartAngle(90); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(transparencia); plot.setInteriorGap(0.20); ChartPanel chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:edu.wpi.cs.wpisuitetng.modules.requirementsmanager.view.charts.IterationRequirementsStatsTest.java
@Test public void iterationPieChart() { Assert.assertEquals(//from ww w. j av a 2s.com ChartFactory.createPieChart3D("Requirements by Iteration", data.toPieDataset(), true, false, false), data.buildPieChart()); }
From source file:edu.esprit.pi.workshop.statistiques.PieChart.java
@Override public JFreeChart construireChart3D() { List<Stock> list = new StockDAO().findAll(); dataset = new DefaultPieDataset(); System.out.println("Remplissage Dynamique du dataset ..."); for (Stock stock : list) { dataset.setValue(stock.getLibelle(), stock.getQtiteStock()); }//from ww w . ja va2 s. c om graphe = ChartFactory.createPieChart3D("Exemple Camemberg 3D", dataset, true, true, false); return graphe; }
From source file:systeminformation.Chart.java
public JFreeChart create3DPieChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart3D("", dataset, true, true, true); PiePlot3D p = (PiePlot3D) chart.getPlot(); PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); p.setLabelGenerator(gen);/*from www. ja v a 2 s. c o m*/ // p.setSimpleLabels(true); p.setForegroundAlpha(0.5f); p.setBackgroundAlpha(0.2f); chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); chart.setBorderVisible(true); return chart; }
From source file:taller.GraficoTorta.java
public GraficoTorta(int posX, int posY, double[] datos, String[] labels, String titulo) { super(""); try {//from w ww . j a v a 2 s . c om DefaultPieDataset defaultpiedataset = new DefaultPieDataset(); for (int i = 0; i < datos.length; i++) defaultpiedataset.setValue(labels[i], datos[i]); JFreeChart jfreechart = ChartFactory.createPieChart3D(titulo, defaultpiedataset, true, true, false); PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot(); pieplot3d.setDarkerSides(true); pieplot3d.setStartAngle(0D); pieplot3d.setDirection(Rotation.CLOCKWISE); pieplot3d.setForegroundAlpha(0.75F); pieplot3d.setNoDataMessage("No hay Datos que Mostrar"); jpanel = new ChartPanel(jfreechart); jpanel.setPreferredSize(new Dimension(300, 300)); setContentPane(jpanel); pack(); RefineryUtilities.centerFrameOnScreen(this); } catch (Exception e) { } }