List of usage examples for org.jfree.chart ChartFactory createPieChart3D
public static JFreeChart createPieChart3D(String title, PieDataset dataset)
From source file:GroupProject.OriginalChartUI.java
/** * The method to draw pie chart//from w w w. ja v a2 s . c o m * @param pieChartData the data used in the pie chart * @param pieTitle the measurement of pie chart */ public void drawPieChart(Map<String, Long> pieChartData, String pieTitle) { String title = pieTitle; ArrayList<String> keyArrayList = new ArrayList<>(); ArrayList<Long> valueArrayList = new ArrayList<>(); ArrayList<Color> colorArrayList = new ArrayList<>(); colorArrayList.add(new Color(222, 235, 247)); colorArrayList.add(new Color(109, 166, 217)); colorArrayList.add(new Color(155, 195, 230)); colorArrayList.add(new Color(126, 146, 222)); colorArrayList.add(new Color(96, 158, 218)); colorArrayList.add(new Color(53, 132, 203)); colorArrayList.add(new Color(46, 116, 180)); colorArrayList.add(new Color(31, 77, 119)); DefaultPieDataset dataset = new DefaultPieDataset(); Set set = pieChartData.keySet(); for (Map.Entry<String, Long> data : pieChartData.entrySet()) { String key = data.getKey(); Long value = data.getValue(); keyArrayList.add(key); valueArrayList.add(value); } for (int i = 0; i < valueArrayList.size(); i++) { dataset.setValue(keyArrayList.get(i), valueArrayList.get(i)); } JFreeChart chart = ChartFactory.createPieChart3D(title, dataset); chart.setBorderVisible(false); chart.setBorderPaint(new Color(255, 255, 255)); PiePlot3D plot = (PiePlot3D) chart.getPlot(); for (int i = 0; i < valueArrayList.size(); i++) { Color color = colorArrayList.get(i); plot.setSectionPaint(keyArrayList.get(i), color); } plot.setOutlineVisible(false); plot.setForegroundAlpha(0.6f); plot.setStartAngle(0); plot.setBackgroundPaint(new java.awt.Color(255, 255, 255)); ChartPanel chartPanel = new ChartPanel(chart); chartDisplayPanel.removeAll(); chartDisplayPanel.add(chartPanel, BorderLayout.CENTER); chartDisplayPanel.validate(); }
From source file:PDF.Reportes.java
public ArrayList<JFreeChart> grafica(String usuario, String contra) { // IngresoAbd bd = new IngresoAbd(usuario, contra); ArrayList<JFreeChart> graficas = new ArrayList(); List<Beans.Reportes> reportes = ReportesDAO.statusFichas(usuario, contra); // reportes = bd.statusFichas(); Beans.Reportes report = ReportesDAO.preFichas(usuario, contra); // report = bd.preFichas(); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); DefaultPieDataset dataset3 = new DefaultPieDataset(); if (reportes == null || report == null) { return graficas; } else {/* w w w. ja v a2 s . com*/ for (Beans.Reportes reporte : reportes) { String carrera = ""; if (reporte.getNombre().contentEquals("INGENIER?A MECATRNICA")) { carrera = "IMCT"; } if (reporte.getNombre().contentEquals("INGENIER?A ELECTROMEC?NICA")) { carrera = "IEME"; } if (reporte.getNombre().contentEquals("INGENIER?A EN SISTEMAS COMPUTACIONALES")) { carrera = "ISC"; } if (reporte.getNombre().contentEquals("INGENIER?A ELECTRNICA")) { carrera = "IELC"; } if (reporte.getNombre().contentEquals("INGENIER?A EN LOG?STICA")) { carrera = "ILOG"; } if (reporte.getNombre().contentEquals("INGENIER?A INDUSTRIAL")) { carrera = "IIND"; } if (reporte.getNombre().contentEquals("INGENIER?A EN GESTION EMPRESARIAL")) { carrera = "IGEM"; } if (reporte.getNombre() .contentEquals("INGENIER?A EN TECNOLOG?AS DE LA INFORMACIN Y COMUNICACIONES")) { carrera = "TICS"; } if (reporte.getNombre().contentEquals("INGENIER?A QUIMICA")) { carrera = "IQUI"; } dataset.setValue(Integer.parseInt(reporte.getPreficha()), reporte.getPreficha(), carrera); } // Visitas del sitio web 2 JFreeChart chart = ChartFactory.createBarChart3D("Prefichas por carrera", "", "Nmero de prefichas", dataset, PlotOrientation.HORIZONTAL, true, true, false); for (Beans.Reportes reporte : reportes) { String carrera = ""; if (reporte.getNombre().contentEquals("INGENIER?A MECATRNICA")) { carrera = "IMCT"; } if (reporte.getNombre().contentEquals("INGENIER?A ELECTROMEC?NICA")) { carrera = "IEME"; } if (reporte.getNombre().contentEquals("INGENIER?A EN SISTEMAS COMPUTACIONALES")) { carrera = "ISC"; } if (reporte.getNombre().contentEquals("INGENIER?A ELECTRNICA")) { carrera = "IELC"; } if (reporte.getNombre().contentEquals("INGENIER?A EN LOG?STICA")) { carrera = "ILOG"; } if (reporte.getNombre().contentEquals("INGENIER?A INDUSTRIAL")) { carrera = "IIND"; } if (reporte.getNombre().contentEquals("INGENIER?A EN GESTION EMPRESARIAL")) { carrera = "IGEM"; } if (reporte.getNombre() .contentEquals("INGENIER?A EN TECNOLOG?AS DE LA INFORMACIN Y COMUNICACIONES")) { carrera = "TICS"; } if (reporte.getNombre().contentEquals("INGENIER?A QUIMICA")) { carrera = "IQUI"; } dataset2.setValue(Integer.parseInt(reporte.getPrefpagadas()), reporte.getPrefpagadas(), carrera); } JFreeChart chart2 = ChartFactory.createBarChart3D("Prefichas pagadas por carrera", "", "Nmero de prefichas", dataset2, PlotOrientation.HORIZONTAL, true, true, false); int prefichas = 0; if (Integer.parseInt(report.getPreficha()) >= 0) { prefichas = Integer.parseInt(report.getPreficha()); } dataset3.setValue("Prefichas pagadas: " + report.getPrefpagadas(), Integer.parseInt(report.getPrefpagadas())); dataset3.setValue("Prefichas por pagar: " + report.getPreproc(), Integer.parseInt(report.getPreproc())); dataset3.setValue("Prefichas disponibles: " + prefichas, prefichas); JFreeChart chart3 = ChartFactory.createPieChart3D("Meta Deseada: " + report.getNombre(), dataset3); graficas.add(chart3); graficas.add(chart); graficas.add(chart2); } return graficas; }