List of usage examples for org.jfree.chart ChartFactory createPieChart
public static JFreeChart createPieChart(String title, PieDataset dataset, boolean legend, boolean tooltips, boolean urls)
From source file:eu.cassandra.training.utils.ChartUtils.java
/** * This function is used for creating a pie chart of a Person Model's * statistical attributes./*from w ww .j a v a 2 s. c o m*/ * * @param title * The chart's title * @param person * The person under consideration * * @return a chart panel with the statistical graphical representation. */ public static ChartPanel createPieChart(String title, Person person) { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Activity Models", person.getActivityModelsSize()); dataset.setValue("Response Models", person.getResponseModelsSize()); JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, true, true); PiePlot plot = (PiePlot) chart.getPlot(); PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0} = {1}", new DecimalFormat("0"), new DecimalFormat("0.00%")); plot.setLabelGenerator(generator); return new ChartPanel(chart); }
From source file:org.pau.assetmanager.viewmodel.MonthlyReportViewModel.java
/** * Generates the image of a pie chart that displays the percentage of income * of the different books which for a given year are profitable * /*from w ww . j a v a2 s . co m*/ * @return the relative random URL generated */ @DependsOn({ "selectedBook", "clientType", "monthlyReportYear" }) public String getIncomePieChartURL() { if (bookSelection.getSelectedBook() == null) { return ""; } List<Annotation> anotations = getAnnotationsInAscendingDateOrder(Optional.of(monthlyReportYear)); PieDataset categoryModel = ChartDataModel.incomesPieChartDataset(anotations); JFreeChart jfchart = ChartFactory.createPieChart( "Beneficios ( ingresos menos gastos, siendo los ingresos mayores a los gastos )", categoryModel, true, true, false); PiePlot piePlot = ((PiePlot) jfchart.getPlot()); piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1} , {2} )", NumberFomatter.PERCENTAGE_FORMATTER, NumberFormat.getPercentInstance())); piePlot.setBackgroundPaint(Color.white); return ResourceImageGenerator.getFunction().apply(jfchart); }
From source file:org.openmrs.module.pmtct.web.view.chart.InfantPieChartView.java
/** * @see org.openmrs.module.pmtct.web.view.chart.AbstractChartView#createChart(java.util.Map, * javax.servlet.http.HttpServletRequest) */// w w w . ja v a2 s.c o m @Override protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) { UserContext userContext = Context.getUserContext(); ApplicationContext appContext = ContextProvider.getApplicationContext(); PMTCTModuleTag tag = new PMTCTModuleTag(); List<Object> res = new ArrayList<Object>(); DefaultPieDataset pieDataset = new DefaultPieDataset(); String title = "", descriptionTitle = "", dateInterval = ""; Concept concept = null; SimpleDateFormat df = Context.getDateFormat(); Encounter matEnc = null; Date today = new Date(); Date oneYearFromNow = new Date(new Date().getTime() - PMTCTConstants.YEAR_IN_MILLISECONDS); String endDate = df.format(today); String startDate = df.format(oneYearFromNow); dateInterval = "(" + new SimpleDateFormat("dd-MMM-yyyy").format(oneYearFromNow) + " - " + new SimpleDateFormat("dd-MMM-yyyy").format(today) + ")"; if (request.getParameter("type").compareTo("1") == 0) { try { // Date myDate = new Date("1/1/" + ((new Date()).getYear() + 1900)); // String startDate = df.format(myDate); // Date today=new Date(); // Date oneYearFromNow=new Date(new Date().getTime() - PMTCTConstants.YEAR_IN_MILLISECONDS); PmtctService pmtct; pmtct = Context.getService(PmtctService.class); try { res = pmtct.getGeneralStatForInfantTests_Charting_IFM(startDate, endDate); } catch (SQLException ex) { ex.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } List<String> infantFeedingMethodOptions = new ArrayList<String>(); List<Integer> infantFeedingMethodValues = new ArrayList<Integer>(); Collection<ConceptAnswer> answers = Context.getConceptService() .getConcept(PMTCTConstants.INFANT_FEEDING_METHOD).getAnswers(); for (ConceptAnswer str : answers) { infantFeedingMethodOptions.add(str.getAnswerConcept().getName().getName()); infantFeedingMethodValues.add(0); } infantFeedingMethodOptions.add("Others"); infantFeedingMethodValues.add(0); for (Object ob : res) { int patientId = (Integer) ((Object[]) ob)[0]; matEnc = tag.getMaternityEncounterInfo(patientId); String infantFeedingMethod = tag.observationValueByConcept(matEnc, PMTCTConstants.INFANT_FEEDING_METHOD); int i = 0; boolean found = false; for (String s : infantFeedingMethodOptions) { if ((s.compareToIgnoreCase(infantFeedingMethod)) == 0) { infantFeedingMethodValues.set(i, infantFeedingMethodValues.get(i) + 1); found = true; } i++; } if (!found) { infantFeedingMethodValues.set(infantFeedingMethodValues.size() - 1, infantFeedingMethodValues.get(infantFeedingMethodValues.size() - 1) + 1); } } int i = 0; for (String s : infantFeedingMethodOptions) { if (infantFeedingMethodValues.get(i) > 0) { Float percentage = new Float(100 * infantFeedingMethodValues.get(i) / res.size()); pieDataset.setValue(s + " (" + infantFeedingMethodValues.get(i) + " , " + percentage + "%)", percentage); } i++; } title = appContext.getMessage("pmtct.menu.infantTest", null, userContext.getLocale()); concept = Context.getConceptService().getConcept(PMTCTConstants.INFANT_FEEDING_METHOD); } catch (Exception ex) { ex.printStackTrace(); } } else if (request.getParameter("type").compareTo("2") == 0) { try { // Date myDate2 = new Date("1/1/" + ((new Date()).getYear() + 1900)); // String startDate2 = df.format(myDate2); // Date today=new Date(); // Date oneYearFromNow=new Date(new Date().getTime() - PMTCTConstants.YEAR_IN_MILLISECONDS); // String endDate2 = df.format(today); // String startDate2 = df.format(oneYearFromNow); // dateInterval = "(" + new SimpleDateFormat("dd-MMM-yyyy").format(oneYearFromNow) + " - " + new SimpleDateFormat("dd-MMM-yyyy").format(today) + ")"; PmtctService pmtct; pmtct = Context.getService(PmtctService.class); try { res = pmtct.getGeneralStatForInfantTests_Charting_SerAt9Months(startDate, endDate); } catch (SQLException ex) { ex.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } List<String> hivTestResultOptions = new ArrayList<String>(); List<Integer> ser9m_hivTestResultValues = new ArrayList<Integer>(); Collection<ConceptAnswer> answers = Context.getConceptService() .getConcept(PMTCTConstants.RESULT_OF_HIV_TEST).getAnswers(); for (ConceptAnswer str : answers) { hivTestResultOptions.add(str.getAnswerConcept().getName().getName()); ser9m_hivTestResultValues.add(0); } hivTestResultOptions.add("Others"); ser9m_hivTestResultValues.add(0); for (Object ob : res) { int val = 0; String temp = "", ser9m_hivTestResult = ""; temp = "" + ((Object[]) ob)[2]; val = (temp.compareTo("") == 0) ? 0 : Integer.parseInt(temp); if (val > 0) ser9m_hivTestResult = tag.getConceptNameById(temp); int i = 0; boolean ser9m_found = false; for (String s : hivTestResultOptions) { if ((s.compareToIgnoreCase(ser9m_hivTestResult)) == 0) { ser9m_hivTestResultValues.set(i, ser9m_hivTestResultValues.get(i) + 1); ser9m_found = true; } i++; } if (!ser9m_found) { ser9m_hivTestResultValues.set(ser9m_hivTestResultValues.size() - 1, ser9m_hivTestResultValues.get(ser9m_hivTestResultValues.size() - 1) + 1); } } int i = 0; for (String s : hivTestResultOptions) { if (ser9m_hivTestResultValues.get(i) > 0) { Float percentage = new Float(100 * ser9m_hivTestResultValues.get(i) / res.size()); pieDataset.setValue(s + " (" + ser9m_hivTestResultValues.get(i) + " , " + percentage + "%)", percentage); } i++; } title = appContext.getMessage("pmtct.menu.infantTest", null, userContext.getLocale()); concept = null; descriptionTitle = Context.getEncounterService() .getEncounterType(PMTCTConfigurationUtils.getSerology9MonthEncounterTypeId()).getName(); descriptionTitle += dateInterval; } catch (Exception ex) { ex.printStackTrace(); } } else if (request.getParameter("type").compareTo("3") == 0) { try { // Date myDate3 = new Date("1/1/" + ((new Date()).getYear() + 1900)); // String startDate3 = df.format(myDate3); // String endDate3 = df.format(today); // String startDate3 = df.format(oneYearFromNow); // dateInterval = "(" + new SimpleDateFormat("dd-MMM-yyyy").format(oneYearFromNow) + " - " + new SimpleDateFormat("dd-MMM-yyyy").format(today) + ")"; PmtctService pmtct; pmtct = Context.getService(PmtctService.class); try { res = pmtct.getGeneralStatForInfantTests_Charting_SerAt18Months(startDate, endDate); } catch (SQLException ex) { ex.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } List<String> hivTestResultOptions = new ArrayList<String>(); List<Integer> ser18m_hivTestResultValues = new ArrayList<Integer>(); Collection<ConceptAnswer> answers = Context.getConceptService() .getConcept(PMTCTConstants.RESULT_OF_HIV_TEST).getAnswers(); for (ConceptAnswer str : answers) { hivTestResultOptions.add(str.getAnswerConcept().getName().getName()); ser18m_hivTestResultValues.add(0); } hivTestResultOptions.add("Others"); ser18m_hivTestResultValues.add(0); for (Object ob : res) { int val = 0; String temp = "", ser18m_hivTestResult = ""; temp = "" + ((Object[]) ob)[2]; val = (temp.compareTo("") == 0) ? 0 : Integer.parseInt(temp); if (val > 0) ser18m_hivTestResult = tag.getConceptNameById(temp); int i = 0; boolean ser18m_found = false; for (String s : hivTestResultOptions) { if ((s.compareToIgnoreCase(ser18m_hivTestResult)) == 0) { ser18m_hivTestResultValues.set(i, ser18m_hivTestResultValues.get(i) + 1); ser18m_found = true; } i++; } if (!ser18m_found) { ser18m_hivTestResultValues.set(ser18m_hivTestResultValues.size() - 1, ser18m_hivTestResultValues.get(ser18m_hivTestResultValues.size() - 1) + 1); } } int i = 0; for (String s : hivTestResultOptions) { if (ser18m_hivTestResultValues.get(i) > 0) { Float percentage = new Float(100 * ser18m_hivTestResultValues.get(i) / res.size()); pieDataset.setValue( s + " (" + ser18m_hivTestResultValues.get(i) + " , " + percentage + "%)", percentage); } i++; } title = appContext.getMessage("pmtct.menu.infantTest", null, userContext.getLocale()); concept = null; descriptionTitle = Context.getEncounterService() .getEncounterType(PMTCTConfigurationUtils.getSerology18MonthEncounterTypeId()).getName(); descriptionTitle += dateInterval; } catch (Exception ex) { ex.printStackTrace(); } } else if (request.getParameter("type").compareTo("4") == 0) { try { PmtctService pmtct; pmtct = Context.getService(PmtctService.class); try { res = pmtct.getGeneralStatForInfantTests_Charting_PCR(startDate, endDate); } catch (SQLException ex) { ex.printStackTrace(); } List<String> hivTestResultOptions = new ArrayList<String>(); List<Integer> pcr_hivTestResultValues = new ArrayList<Integer>(); Collection<ConceptAnswer> answers = Context.getConceptService() .getConcept(PMTCTConstants.RESULT_OF_HIV_TEST).getAnswers(); for (ConceptAnswer str : answers) { hivTestResultOptions.add(str.getAnswerConcept().getName().getName()); pcr_hivTestResultValues.add(0); } hivTestResultOptions.add("Others"); pcr_hivTestResultValues.add(0); for (Object ob : res) { int val = 0; String temp = "", pcr_hivTestResult = ""; temp = "" + ((Object[]) ob)[2]; val = (temp.compareTo("") == 0) ? 0 : Integer.parseInt(temp); if (val > 0) pcr_hivTestResult = tag.getConceptNameById(temp); int i = 0; boolean pcr_found = false; for (String s : hivTestResultOptions) { if ((s.compareToIgnoreCase(pcr_hivTestResult)) == 0) { pcr_hivTestResultValues.set(i, pcr_hivTestResultValues.get(i) + 1); pcr_found = true; } i++; } if (!pcr_found) { pcr_hivTestResultValues.set(pcr_hivTestResultValues.size() - 1, pcr_hivTestResultValues.get(pcr_hivTestResultValues.size() - 1) + 1); } } int i = 0; for (String s : hivTestResultOptions) { if (pcr_hivTestResultValues.get(i) > 0) { Float percentage = new Float(100 * pcr_hivTestResultValues.get(i) / res.size()); pieDataset.setValue(s + " (" + pcr_hivTestResultValues.get(i) + " , " + percentage + "%)", percentage); } i++; } title = appContext.getMessage("pmtct.menu.infantTest", null, userContext.getLocale()); concept = null; descriptionTitle = Context.getEncounterService() .getEncounterType(PMTCTConfigurationUtils.getPCRTestEncounterTypeId()).getName(); descriptionTitle += dateInterval; } catch (Exception ex) { ex.printStackTrace(); } } JFreeChart chart = ChartFactory.createPieChart(title + " : " + ((null != concept) ? concept.getPreferredName(userContext.getLocale()) + dateInterval : descriptionTitle), pieDataset, true, true, false); return chart; }
From source file:UserInterface.AdministrativeRole.ReportsJPanel.java
private void appEasyReportBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_appEasyReportBtnActionPerformed // TODO add your handling code here: int countEasy = 0; int countSomewhat = 0; int countVery = 0; for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) { if (organization instanceof AdminOrganization) { for (FarmerFeedbackWorkRequest request : organization.getFeedbackWorkQueue() .getFarmerFeedbackList()) { if (request.getSiteUserFriendly().equalsIgnoreCase("Easy To Use")) { countEasy++;/* w w w. j a v a 2s . co m*/ } else if (request.getSiteUserFriendly().equalsIgnoreCase("Somewhat Difficult")) { countSomewhat++; } else if (request.getSiteUserFriendly().equalsIgnoreCase("Very Difficult")) { countVery++; } } break; } } float total = countEasy + countSomewhat + countVery; float pEasy = (countEasy / total) * 100; float pSomewhat = (countSomewhat / total) * 100; float pVery = (countVery / total) * 100; DefaultPieDataset pieDataSet = new DefaultPieDataset(); pieDataSet.setValue("Easy To Use%: " + pEasy, pEasy); pieDataSet.setValue("Somewhat Difficult%: " + pSomewhat, pSomewhat); pieDataSet.setValue("Very Difficult%: " + pVery, pVery); JFreeChart chart = ChartFactory.createPieChart("Application Easiness Level", pieDataSet, true, true, true); PiePlot plot = (PiePlot) chart.getPlot(); ChartFrame frame = new ChartFrame("Application Easiness Level", chart); frame.setVisible(true); frame.setSize(500, 500); }
From source file:org.gridchem.client.gui.panels.myccg.resource.HPCChartPanel.java
private JFreeChart createChart(HashSet<ComputeBean> resources, ChartType chartType, LoadType loadType) { JFreeChart chart = null;//from w ww . ja va 2 s .c o m Plot plot; AbstractDataset dataset; if (loadType.equals(LoadType.SUMMARY)) { dataset = ChartDataset.createDataset(resources, chartType); } else { dataset = ChartDataset.createDataset(resources, chartType, loadType); } if (chartType.equals(ChartType.SUMMARY)) { chart = ChartFactory.createBarChart("", // chart title "Resources", // domain axis label createTitle(loadType), // range axis label (CategoryDataset) dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); renderBarChart(chart); } else if (chartType.equals(ChartType.PIE)) { chart = ChartFactory.createPieChart(createTitle(loadType), // chart title (DefaultPieDataset) dataset, // data false, // include legend true, // tooltips? false // URLs? ); } else if (chartType.equals(ChartType.BAR)) { chart = ChartFactory.createBarChart("", // chart title "Resources", // domain axis label createTitle(loadType), // range axis label (CategoryDataset) dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); renderBarChart(chart); } else if (chartType.equals(ChartType.LAYERED)) { plot = new CategoryPlot((CategoryDataset) dataset, new CategoryAxis("Resources"), new NumberAxis(createTitle(loadType)), new LayeredBarRenderer()); ((CategoryPlot) plot).setOrientation(PlotOrientation.VERTICAL); chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); renderLayeredBarChart(chart); } else if (chartType.equals(ChartType.STACKED)) { chart = ChartFactory.createStackedBarChart("", // chart title "Resources", // domain axis label createTitle(loadType), // range axis label (CategoryDataset) dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); renderStackedBarChart(chart); } else if (chartType.equals(ChartType.BAR)) { chart = ChartFactory.createBarChart("", // chart title "Resources", // domain axis label createTitle(loadType), // range axis label (CategoryDataset) dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); } return chart; }
From source file:views.Student_Home.java
private void populateTasks() { ArrayList taskList = studentActions.fetchTasks(); while (taskModel.getRowCount() != 0) { taskModel.removeRow(taskModel.getRowCount() - 1); }/*from w ww .j a va 2s . c o m*/ Task task = new Task(); Date currDate = new Date(); int totalTime = 0; int timePassed = 0; for (int i = 0; i < taskList.size(); i++) { task = (Task) taskList.get(i); this.taskLinkedList.add(task.getTaskId()); if (currDate.before(task.getStartDate())) { String[] str = { task.getTaskId(), task.getTaskDescription(), task.getProjectId(), "Up coming" }; taskModel.insertRow(taskModel.getRowCount(), str); } else { String[] str = { task.getTaskId(), task.getTaskDescription(), task.getProjectId(), "In progress" }; taskModel.insertRow(taskModel.getRowCount(), str); timePassed = timePassed + (currDate.getDate() - task.getStartDate().getDate()); } totalTime = totalTime + (task.getEndDate().getDate() - task.getStartDate().getDate()); } DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Task completed", timePassed); dataset.setValue("Pending Tasks", totalTime - timePassed); JFreeChart taskStatusChart = ChartFactory.createPieChart("Tasks completion status", dataset, true, true, true); PiePlot piePlot = (PiePlot) taskStatusChart.getPlot(); ChartPanel chartPanel = new ChartPanel(taskStatusChart); chartPanel.setSize(323, 303); chartPanel.setVisible(true); //chartPanel.setLocation(500, 200); taskPieChart.removeAll(); taskPieChart.add(chartPanel); taskPieChart.updateUI(); taskPieChart.repaint(); }
From source file:org.jfree.chart.demo.JFreeChartDemoBase.java
/** * Creates and returns a sample pie chart. * * @return a sample pie chart./*from ww w . j ava 2 s. c o m*/ */ public JFreeChart createPieChartOne() { // create a default chart based on some sample data... final String title = this.resources.getString("pie.pie1.title"); final CategoryDataset data = DemoDatasetFactory.createCategoryDataset(); final PieDataset extracted = DatasetUtilities.createPieDatasetForRow(data, 0); final JFreeChart chart = ChartFactory.createPieChart(title, extracted, true, true, false); // then customise it a little... chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.orange)); final PiePlot plot = (PiePlot) chart.getPlot(); plot.setCircular(false); // make section 1 explode by 100%... plot.setExplodePercent(1, 1.00); return chart; }
From source file:com.polivoto.vistas.Charts.java
private JPanel hacerPiePanel(Pregunta pregunta, List<Opcion> opciones) { JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(Color.white); DefaultPieDataset data = new DefaultPieDataset(); // Fuente de Datos for (Opcion opc : opciones) { data.setValue(opc.getNombre(), opc.getCantidad()); }//from ww w . j a v a 2s. com // Creando el Grafico JFreeChart chart = ChartFactory.createPieChart("\n" + pregunta.getTitulo(), data, true, false, //TOOLTIPS false); chart.setBackgroundPaint(Color.white); chart.getTitle().setFont(new Font("Roboto", 0, 28)); // Crear el Panel del Grafico con ChartPanel ChartPanel chartPanel = new ChartPanel(chart); PiePlot plot = (PiePlot) chart.getPlot(); Rectangle bounds = panel.getBounds(); chartPanel.setBounds(bounds.x, bounds.y, bounds.height, bounds.height); panel.add(chartPanel); plot.setLabelGenerator(null); plot.setBackgroundPaint(Color.white); plot.setOutlineVisible(false); //StandardPieSectionLabelGenerator labels = new StandardPieSectionLabelGenerator("{0} = {1}"); //plot.setLabelGenerator(labels); plot.setBaseSectionOutlinePaint(Color.white); plot.setShadowXOffset(0); plot.setShadowYOffset(0); //#7cb5ec,#f45b5b,#90ed7d,#434348, //#f7a35c,#8085e9,#f15c80,#e4d354, //#2b908f,#91e8e1 Color[] colors = { new Color(124, 181, 236), new Color(244, 91, 91), new Color(144, 237, 125), new Color(67, 67, 72), new Color(247, 163, 92), new Color(128, 133, 233), new Color(241, 92, 128), new Color(228, 211, 84), new Color(43, 144, 143), new Color(145, 232, 225) }; PieRenderer renderer = new PieRenderer(colors); renderer.setColor(plot, data); LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); Font nwfont = new Font("Roboto", 0, 18); legend.setItemFont(nwfont); legend.setFrame(new BlockBorder(0, 0, 0, 90, Color.white)); legend.setBackgroundPaint(Color.WHITE); legend.setItemLabelPadding(new RectangleInsets(8, 8, 8, 0)); //RectangleInsets padding = new RectangleInsets(5, 5, 5, 5); //legend.setItemLabelPadding(padding); plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{1} {0}")); plot.setLegendItemShape(new Rectangle(25, 25)); return panel; }
From source file:org.jfree.chart.demo.JFreeChartDemoBase.java
/** * Creates and returns a sample pie chart. * * @return a sample pie chart.// w ww .j a v a 2 s.c om */ public JFreeChart createPieChartTwo() { // create a default chart based on some sample data... final String title = this.resources.getString("pie.pie2.title"); final CategoryDataset data = DemoDatasetFactory.createCategoryDataset(); final Comparable category = (Comparable) data.getColumnKeys().get(1); final PieDataset extracted = DatasetUtilities.createPieDatasetForColumn(data, category); final JFreeChart chart = ChartFactory.createPieChart(title, extracted, true, true, false); // then customise it a little... chart.setBackgroundPaint(Color.lightGray); final PiePlot pie = (PiePlot) chart.getPlot(); pie.setLabelGenerator(new StandardPieItemLabelGenerator("{0} = {2}", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance())); pie.setBackgroundImage(JFreeChart.INFO.getLogo()); pie.setBackgroundPaint(Color.white); pie.setBackgroundAlpha(0.6f); pie.setForegroundAlpha(0.75f); return chart; }
From source file:org.pau.assetmanager.viewmodel.MonthlyReportViewModel.java
/** * Generates the image of a pie chart that displays the percentage of * expenses of the different concept which for a given year are loosing * money (not profitable)/*from w w w . j a v a 2 s . c om*/ * * NOTE: usually, a given concept is only related to either income or * expenses but this *not* always the case (for example, in stocks the * concept is the company involved and there can be incomes and expenses) * * @return the relative random URL generated */ @DependsOn({ "selectedBook", "clientType", "monthlyReportYear" }) public String getExpensesPieChartURL() { if (bookSelection.getSelectedBook() == null) { return ""; } Map<String, Double> expensesDataForBook = AnnotationsBusiness.getExpensesDataForBook(bookSelection, monthlyReportYear, clientType); PieDataset categoryModel = ChartDataModel.expensesPieChartDataset(expensesDataForBook); JFreeChart jfchart = ChartFactory.createPieChart("Gastos (nicamente gastos)", categoryModel, true, true, false); PiePlot piePlot = ((PiePlot) jfchart.getPlot()); piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1} , {2} )", NumberFomatter.PERCENTAGE_FORMATTER, NumberFormat.getPercentInstance())); piePlot.setBackgroundPaint(Color.white); return ResourceImageGenerator.getFunction().apply(jfchart); }