List of usage examples for org.jfree.chart ChartFactory createBarChart
public static JFreeChart createBarChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:userinterface.AdminRole.DataAnalysisJPanel.java
private void donorHealthBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_donorHealthBtnActionPerformed // TODO add your handling code here: int count = 0; int count1 = 0; for (Organization org : enterprise.getOrganizationDirectory().getOrganizationList()) { if (org instanceof NutritionistOrganization) { for (WorkRequest request : org.getWorkQueue().getWorkRequestList()) { count = count + 1;/*from w ww . j a v a2 s. c o m*/ } } if (org instanceof LabOrganization) { for (WorkRequest request : org.getWorkQueue().getWorkRequestList()) { count1++; } } } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(count, "Number", "unfit"); dataset.setValue(count1, "Number", "fit"); JFreeChart chart = ChartFactory.createBarChart("Donors", "Donor", "Number", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.black); ChartFrame frame = new ChartFrame("Donor Information", chart); frame.setVisible(true); frame.setSize(450, 500); }
From source file:dumbara.view.Chart1.java
public static void getIncomebyDate() { DefaultCategoryDataset objDataset = new DefaultCategoryDataset(); try {/*from w w w . j a va 2s. co m*/ Chart4[] chart4s = SalesController.getIncomeByDate(); for (Chart4 chart4 : chart4s) { objDataset.setValue(chart4.getSumIncme(), "Days Income", chart4.getSalesDate()); } } catch (ClassNotFoundException | SQLException ex) { Logger.getLogger(Chart1.class.getName()).log(Level.SEVERE, null, ex); } // JFreeChart objChart = ChartFactory.createBarChart("Total Sales Comparisson by Date", "Sales Date", "Sales Income", objDataset, PlotOrientation.VERTICAL, true, true, false); ChartFrame frame = new ChartFrame("Data Analysis Wizard - v2.1.4", objChart); frame.pack(); frame.setSize(1100, 600); frame.setVisible(true); frame.setLocationRelativeTo(null); }
From source file:ch.unibe.iam.scg.archie.controller.ProviderChartFactory.java
/** * /*from w w w.ja v a 2 s.c om*/ * @param pieDataset * @return */ @SuppressWarnings("deprecation") private JFreeChart createJFreeBarChart(CategoryDataset barDataset) { if (this.model.isThreeDimensional() && this.model.isLineChart()) { return ChartFactory.createLineChart3D(this.model.getChartName(), "Category", "Value", barDataset, PlotOrientation.VERTICAL, true, true, false); } else if (this.model.isThreeDimensional() && !this.model.isLineChart()) { return ChartFactory.createBarChart3D(this.model.getChartName(), "Category", "Value", barDataset, PlotOrientation.VERTICAL, true, true, false); } else if (this.model.isLineChart()) { JFreeChart chart = ChartFactory.createLineChart(this.model.getChartName(), "Category", "Value", barDataset, PlotOrientation.VERTICAL, true, true, false); LineAndShapeRenderer renderer = (LineAndShapeRenderer) ((CategoryPlot) chart.getPlot()).getRenderer(); renderer.setShapesVisible(true); renderer.setShapesFilled(true); return chart; } return ChartFactory.createBarChart(this.model.getChartName(), "Category", "Value", barDataset, PlotOrientation.VERTICAL, true, true, false); }
From source file:Interface.FoodStandardSupervisor.ConsumedWastedJPanel.java
private void btnCalculateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCalculateActionPerformed // TODO add your handling code here: Date toDate1 = jDateChooser1.getDate(); Date toDate2 = jDateChooser2.getDate(); if ((toDate1 == null) || (toDate2 == null)) { JOptionPane.showMessageDialog(null, "Invalid date..Kindly enter valid date."); return;// w w w . j a v a 2 s . c om } long fromDate = (jDateChooser1.getDate().getTime()) / (1000 * 60 * 60 * 24); long toDate = (jDateChooser2.getDate().getTime()) / (1000 * 60 * 60 * 24); int approved = 1; int disapproved = 1; //int purchasedType = 1; for (WorkRequest request : organization.getWorkQueue().getWorkRequestList()) { long requestDate = (request.getRequestDate().getTime()) / (1000 * 60 * 60 * 24); Employee e = request.getCollectorDriver().getEmployee(); if (e instanceof FoodCollectionDriverEmployee) { if ((requestDate >= fromDate) && (requestDate <= toDate)) { if (!request.getStatus().equalsIgnoreCase("Pending")) { if (((FoodStandardWorkRequest) (request)).getStatus().equalsIgnoreCase("Approved")) { approved++; } else if (((FoodStandardWorkRequest) (request)).getStatus() .equalsIgnoreCase("To be dumped")) { disapproved++; } } } else { JOptionPane.showMessageDialog(null, "There are no records for this search criteria."); } } } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(approved, "Number of food collected", "Consumable food"); dataset.setValue(disapproved, "Number of food collected", "Dumped food"); JFreeChart chart = ChartFactory.createBarChart("Consumable Vs Dumped", "Status of food", "Number of food items", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeGridlinePaint(Color.BLUE); ChartFrame frame = new ChartFrame("Bar Chart for Types of food collected", chart); frame.setVisible(true); frame.setSize(450, 350); }
From source file:pe.egcc.eureka.app.view.RepoResumen.java
private Object crearImagen(List<Map<String, ?>> lista) { //datos del grfico String moneda = null;/*from w ww . j a v a 2 s . c o m*/ DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (Map<String, ?> map : lista) { double importe = Double.parseDouble(map.get("IMPORTE").toString()); moneda = map.get("MONENOMBRE").toString(); String accion = map.get("ACCION").toString(); dataset.addValue(importe, moneda, accion); } JFreeChart graficoBarras = ChartFactory.createBarChart("RESUMEN DE MOVIMIENTOS", //Ttulo de la grfica "TIPOS DE MOVIMIENTOS", //leyenda Eje horizontal "MILES DE " + moneda, //leyenda Eje vertical dataset, //datos PlotOrientation.VERTICAL, //orientacin true, //incluir leyendas true, //mostrar tooltips true); graficoBarras.setBackgroundPaint(Color.LIGHT_GRAY); CategoryPlot plot = (CategoryPlot) graficoBarras.getPlot(); plot.setBackgroundPaint(Color.CYAN); //fondo del grafico plot.setDomainGridlinesVisible(true);//lineas de rangos, visibles plot.setRangeGridlinePaint(Color.BLACK);//color de las lineas de rangos // Crear imagen BufferedImage imagen = graficoBarras.createBufferedImage(500, 300); return imagen; }
From source file:forms.frDados.java
/** * Inicializa o grfico de intensidade de sinal dos satlites. *///from w w w . j a va2 s.c om private void initSatGrafico() { dadosGraficoSats.clear(); plot = ChartFactory.createBarChart("Intensidade do sinal", "PRN", "SNR", dadosGraficoSats, PlotOrientation.VERTICAL, false, true, true); plot.getTitle().setFont(Font.decode("arial-16")); plot.getTitle().setPadding(5, 20, 5, 20); plot.setPadding(new RectangleInsets(10, 10, 0, 10)); //plot.setBackgroundPaint(new Color(255,255,255,0)); BarRenderer br = (BarRenderer) plot.getCategoryPlot().getRenderer(); br.setSeriesPaint(0, Color.BLUE); br.setMaximumBarWidth(0.05); plot.getCategoryPlot().getRangeAxis().setRange(new Range(0, 50), true, true); br.setBaseItemLabelsVisible(true); br.setSeriesItemLabelFont(0, Font.decode("arial-12")); br.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); br.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER)); SpringLayout lm = new SpringLayout(); ChartPanel cp = new ChartPanel(plot); cp.setBorder(LineBorder.createGrayLineBorder()); lm.putConstraint(SpringLayout.EAST, pnlSatPlot, 10, SpringLayout.EAST, cp); lm.putConstraint(SpringLayout.WEST, cp, 10, SpringLayout.WEST, pnlSatPlot); lm.putConstraint(SpringLayout.SOUTH, pnlSatPlot, 10, SpringLayout.SOUTH, cp); lm.putConstraint(SpringLayout.NORTH, cp, 10, SpringLayout.NORTH, pnlSatPlot); pnlSatPlot.setLayout(lm); pnlSatPlot.add(cp); }
From source file:de.tsystems.mms.apm.performancesignature.PerfSigProjectAction.java
private JFreeChart createChart(final JSONObject jsonObject, final CategoryDataset dataset) throws UnsupportedEncodingException { final String measure = jsonObject.getString(Messages.PerfSigProjectAction_ReqParamMeasure()); final String chartDashlet = jsonObject.getString("chartDashlet"); final String testCase = jsonObject.getString("dashboard"); final String customMeasureName = jsonObject.getString("customName"); final String aggregation = jsonObject.getString("aggregation"); String unit = "", color = Messages.PerfSigProjectAction_DefaultColor(); for (DashboardReport dr : getLastDashboardReports()) { if (dr.getName().equals(testCase)) { final Measure m = dr.getMeasure(chartDashlet, measure); if (m != null) { unit = aggregation.equalsIgnoreCase("Count") ? "num" : m.getUnit(); color = URLDecoder.decode(m.getColor(), "UTF-8"); }// w w w. j a v a 2 s . c o m break; } } String title = customMeasureName; if (StringUtils.isBlank(customMeasureName)) title = PerfSigUtils.generateTitle(measure, chartDashlet); final JFreeChart chart = ChartFactory.createBarChart(title, // title "build", // category axis label unit, // value axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend false, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); final CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); //domainAxis.setLowerMargin(0.0); //domainAxis.setUpperMargin(0.0); //domainAxis.setCategoryMargin(0.0); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer(); renderer.setSeriesPaint(0, Color.decode(color)); return chart; }
From source file:UserInterface.Supplier.SalesOverviewJPanel.java
private void viewGraphJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewGraphJButtonActionPerformed DefaultTableModel dtm = (DefaultTableModel) performanceJTable.getModel(); int rows = dtm.getRowCount(); DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (int i = 0; i < rows; i++) { int quant = (int) performanceJTable.getValueAt(i, 1); dataSet.setValue(quant, "QuantitySold", (String) performanceJTable.getValueAt(i, 0)); }//from w w w. j a v a 2 s .c om JFreeChart chart = ChartFactory.createBarChart("Sales Performance Chart", "Product Name", "Quantity Sold", dataSet, PlotOrientation.VERTICAL, false, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeGridlinePaint(Color.BLACK); ChartFrame frame = new ChartFrame("Sales Overview", chart); frame.setVisible(true); frame.setSize(600, 600); }
From source file:ReportGen.java
private void defaultPreview() throws NumberFormatException { tableModel = (DefaultTableModel) dataTable.getModel(); tableModel.getDataVector().removeAllElements(); tableModel.fireTableDataChanged();//w ww . j a v a2 s. c o m String str[] = { "X", "Y" }; tableModel.setColumnIdentifiers(str); exportcounttableexcel.setEnabled(false); exportcounttablepdf.setEnabled(false); // exportgraphtoimage.setEnabled(false); ChartPanel chartPanel; displaypane.removeAll(); displaypane.revalidate(); displaypane.repaint(); displaypane.setLayout(new BorderLayout()); //row String series1 = "Results"; //column String values[] = { "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" }; int value[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; for (int i = 0; i < values.length; i++) { tableModel.addRow(new Object[] { values[i], value[i] }); } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int c = 0; c < value.length; c++) { dataset.addValue(value[c], series1, values[c]); } chart = ChartFactory.createBarChart("181 North Place Residences Graph", // chart title "Default", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); final org.jfree.chart.axis.CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); chartPanel = new ChartPanel(chart); displaypane.add(chartPanel, BorderLayout.CENTER); }
From source file:Logic.mongoC.java
public void diasTweet(String usuario) { HashMap<String, String> conteo = new HashMap(); conteo.put("Lunes", "0"); conteo.put("Martes", "0"); conteo.put("Miercoles", "0"); conteo.put("Jueves", "0"); conteo.put("Viernes", "0"); conteo.put("Sabado", "0"); conteo.put("Domingo", "0"); Document soloN = this.coll.find(eq("ScreenName", usuario)).first(); usuario regreso = this.gson.fromJson(soloN.getString("todo"), usuario.class); for (twitt t : regreso.getTimeline()) { Date d = t.getFecha();/* www . j a v a 2s . co m*/ int dia = d.getDay(); if (dia == 1) { int cl = Integer.valueOf(conteo.get("Lunes")); cl++; conteo.put("Lunes", String.valueOf(cl)); } if (dia == 2) { int cl = Integer.valueOf(conteo.get("Martes")); cl++; conteo.put("Martes", String.valueOf(cl)); } if (dia == 3) { int cl = Integer.valueOf(conteo.get("Miercoles")); cl++; conteo.put("Miercoles", String.valueOf(cl)); } if (dia == 4) { int cl = Integer.valueOf(conteo.get("Jueves")); cl++; conteo.put("Jueves", String.valueOf(cl)); } if (dia == 5) { int cl = Integer.valueOf(conteo.get("Viernes")); cl++; conteo.put("Viernes", String.valueOf(cl)); } if (dia == 6) { int cl = Integer.valueOf(conteo.get("Sabado")); cl++; conteo.put("Sabado", String.valueOf(cl)); } if (dia == 7) { int cl = Integer.valueOf(conteo.get("Domingo")); cl++; conteo.put("Domingo", String.valueOf(cl)); } } JFreeChart Grafica; DefaultCategoryDataset Datos = new DefaultCategoryDataset(); for (Map.Entry<String, String> entry : conteo.entrySet()) { String key = entry.getKey().toString(); Integer value = Integer.valueOf(entry.getValue()); Datos.addValue(value, usuario, key); System.out.println("KEY " + key + " vaue " + value); } Grafica = ChartFactory.createBarChart("Tweets por dia", "Dias", "Numero de Tweets", Datos, PlotOrientation.VERTICAL, true, true, false); ChartPanel Panel = new ChartPanel(Grafica); JFrame Ventana = new JFrame("JFreeChart"); Ventana.getContentPane().add(Panel); Ventana.pack(); Ventana.setVisible(true); Ventana.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); }