List of usage examples for org.jfree.chart ChartFrame ChartFrame
public ChartFrame(String title, JFreeChart chart)
From source file:lectorarchivos.VerCSV.java
public static void mostrarGrafica(JTable jTableInfoCSV) { //Fuente de datos DefaultCategoryDataset dataset = new DefaultCategoryDataset(); //Recorremos la columna del consumo de la tabla for (int i = jTableInfoCSV.getRowCount() - 1; i >= 0; i--) { if (Double.parseDouble(jTableInfoCSV.getValueAt(i, 4).toString()) > 0) dataset.setValue(Double.parseDouble(jTableInfoCSV.getValueAt(i, 4).toString()), "Consumo", jTableInfoCSV.getValueAt(i, 0).toString()); }//from w w w .j av a 2 s . c o m //Creando el grfico JFreeChart chart = ChartFactory.createBarChart3D("Consumo", "Fecha", "Consumo", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.cyan); chart.getTitle().setPaint(Color.black); chart.setBackgroundPaint(Color.white); chart.removeLegend(); //Cambiar color de barras CategoryPlot plot = (CategoryPlot) chart.getPlot(); BarRenderer barRenderer = (BarRenderer) plot.getRenderer(); barRenderer.setSeriesPaint(0, Color.decode("#5882FA")); // Mostrar Grafico ChartFrame frame = new ChartFrame("CONSUMO", chart); frame.pack(); frame.getChartPanel().setMouseZoomable(false); frame.setVisible(true); panel.add(frame); }
From source file:UserInterface.StoreManager.StoreReportsPanel.java
private void shelfReportsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shelfReportsButtonActionPerformed // TODO add your handling code here: ArrayList<Comparison> cmp1 = new ArrayList<>(); for (Shelf s1 : enterprise.getShelfDirectory().getShelfDirectory()) { int xcount = 0; for (ShelfItem si : s1.getShelfList()) { xcount = xcount + si.getQuantity(); }//from w w w. j av a2 s.c o m Comparison c = new Comparison("Shelf " + s1.getShelfID(), xcount); cmp1.add(c); } Collections.sort(cmp1); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(cmp1.get(cmp1.size() - 1).getNumber(), "Products", cmp1.get(cmp1.size() - 1).getString()); dataset.setValue(cmp1.get(cmp1.size() - 2).getNumber(), "Products", cmp1.get(cmp1.size() - 2).getString()); dataset.setValue(cmp1.get(cmp1.size() - 3).getNumber(), "Products", cmp1.get(cmp1.size() - 3).getString()); JFreeChart chart = ChartFactory.createBarChart( "Top 3 mostly visited shelfs based on no of products remaining", "Products", "No of products Remaining", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLUE); ChartFrame frame = new ChartFrame("Mostly visited Shelf Report", chart); frame.setVisible(true); frame.setSize(600, 400); }
From source file:org.activequant.tradesystem.system.integration.VolatilityCharterTradeSystem.java
private CandlestickChart chartIt(CandleSeries tempSeries) { // simply chart it. CandlestickChart chart = new CandlestickChart(); chart.setCandleSeries(tempSeries);//from www .j av a2s .c o m ChartFrame cf = new ChartFrame("" + tempSeries.getSeriesSpecification().toString(), chart.getChart()); cf.setBounds(window * 400, 0, 400, 300); cf.setVisible(true); charts.add(cf); window++; return chart; }
From source file:Gui.admin.GererlesSratistique.java
private void StatistiquesBouttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StatistiquesBouttonActionPerformed int size = evaluationTable.getRowCount(); System.out.println(size);//from www . j a v a 2 s . c o m List<Double> notes = new ArrayList<Double>(); List<Integer> ids = new ArrayList<Integer>(); for (int i = 0; i < size; i++) { notes.add((new Double(evaluationTable.getValueAt(i, 3).toString()))); ids.add((int) evaluationTable.getValueAt(i, 1)); } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int i = 0; i < size; i++) { dataset.setValue(new Double(notes.get(i)), "notes", new Double(ids.get(i))); } //dataset.setValue(evaluationTable); JFreeChart chart = ChartFactory.createBarChart3D("Notes Adhrents", "Id Adhrents", "Notes", dataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.black); ChartFrame frame = new ChartFrame(" les notes des adhrents", chart); frame.setVisible(true); frame.setSize(450, 350); try { } catch (Exception e) { } /* String note =noteTxt.getText(); String idAdherent=idAdherentEvaluText.getText(); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(new Double(note), "notes", new Double(idAdherent)); //dataset.setValue(evaluationTable); JFreeChart chart = ChartFactory.createBarChart3D("Notes Adhrents", "Id Adhrents", "Notes", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p= chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.black); ChartFrame frame = new ChartFrame(" les notes des adhrents", chart); frame.setVisible(true); frame.setSize(450,350); */ try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("statistiques.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); } catch (Exception e) { } }
From source file:Interface.FoodCollectionSupervisor.TypeOfFoodCitizens.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;/*from w w w .java 2s. c o m*/ } long fromDate = (jDateChooser1.getDate().getTime()) / (1000 * 60 * 60 * 24); long toDate = (jDateChooser2.getDate().getTime()) / (1000 * 60 * 60 * 24); int homeFoodType = 0; int cannedType = 0; int purchasedType = 0; for (WorkRequest request : organization.getWorkQueue().getWorkRequestList()) { long requestDate = (request.getRequestDate().getTime()) / (1000 * 60 * 60 * 24); Employee e = request.getSender().getEmployee(); if (e instanceof CitizenEmployee) { if ((requestDate >= fromDate) && (requestDate <= toDate)) { if (!request.getStatus().equalsIgnoreCase("New Request")) { if (((FoodCollectionWorkRequest) request).getFood().getFoodType() .equalsIgnoreCase("Canned Food")) { cannedType++; } else if (((FoodCollectionWorkRequest) request).getFood().getFoodType() .equalsIgnoreCase("Home made Food")) { homeFoodType++; } else if (((FoodCollectionWorkRequest) request).getFood().getFoodType() .equalsIgnoreCase("Purchased Food")) { purchasedType++; } } } // else{ // // JOptionPane.showMessageDialog(null, "There are no records for this search criteria."); // } } } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(cannedType, "Number of food collected", "Canned Food"); dataset.setValue(purchasedType, "Number of food collected", "Purchased Food"); dataset.setValue(homeFoodType, "Number of food collected", "Home made Food"); JFreeChart chart = ChartFactory.createBarChart("Citizens-Different types of food collected", "Types of food", "Number of food collected", 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:GUI.TelaPrincipal.java
private void botaoConsultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoConsultarActionPerformed DefaultCategoryDataset barChartData = new DefaultCategoryDataset(); barChartData.setValue(20000, "Contribution", "JANUARY"); barChartData.setValue(15000, "Contribution", "FEBRUARY"); barChartData.setValue(30000, "Contribution", "MARCH"); JFreeChart barChart = ChartFactory.createBarChart("Church", "Monthly", "Contribution", barChartData, PlotOrientation.VERTICAL, false, true, false); CategoryPlot barchrt = barChart.getCategoryPlot(); barchrt.setRangeGridlinePaint(Color.PINK); barchrt.setBackgroundPaint(Color.WHITE); ChartFrame frame = new ChartFrame("Lala", barChart); frame.setVisible(true);// www. j a va 2 s . c om frame.setSize(800, 500); }
From source file:userInterface.CustomerWorkArea.ViewChartJPanel.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (CarInspection carList : userAccount.getPerson().getCarInspectionHistory().getCarInspectionHistory()) { dataSet.setValue(carList.getBrakingSys(), "Brakes", carList.getTimestamp()); }/*from w ww . jav a 2 s . c om*/ JFreeChart chart = ChartFactory.createBarChart("Brakes", "Timestamp", "Brakes", dataSet, PlotOrientation.HORIZONTAL.VERTICAL, false, true, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLACK); ChartFrame frame = new ChartFrame("BRAKES GRAPH", chart); frame.setVisible(true); frame.setSize(600, 600); // TODO add your handling code here: }
From source file:graph.plotter.BarMenu.java
/** * This is the main working button for this class... It creates bar chart analyZing whole data set * /*w ww. j av a 2 s . co m*/ * @param evt */ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: try { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); int i; i = 0; String genre = " "; if (Button == 1) while (i < count) { double amount = Double.parseDouble(Table.getModel().getValueAt(i, 1).toString()); String name = Table.getModel().getValueAt(i, 0).toString(); dataset.setValue(new Double(amount), genre, name); i++; genre += " "; } else { try { BufferedReader br = new BufferedReader(new FileReader(jTextField3.getText())); String Line; while ((Line = br.readLine()) != null) { String[] value = Line.split(","); double val = Double.parseDouble(value[1]); dataset.setValue(new Double(val), genre, value[0]); genre += " "; System.out.println(value[0]); } } catch (FileNotFoundException ex) { Logger.getLogger(BarMenu.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(BarMenu.class.getName()).log(Level.SEVERE, null, ex); } } JFreeChart chart = ChartFactory.createBarChart3D("Amount", "Name", "Amount", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.white); p.setBackgroundPaint(Color.black); ChartFrame frame = new ChartFrame("Bar Chart", chart); saveButton = new JButton("Save image in Project Folder"); frame.setLayout(new BorderLayout()); JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints gc = new GridBagConstraints(); gc.gridx = 1; gc.gridy = 0; panel.add(saveButton, gc); frame.add(panel, BorderLayout.SOUTH); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("Bar_Chart.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); } catch (Exception ex) { } } }); frame.setVisible(true); frame.setSize(858, 513); } catch (Exception e) { } }
From source file:UserInterface.DoctorRole.ViewPatientReport.java
public void Graph() { dataset = new DefaultCategoryDataset(); if (!(patient.getTestDir().getTestdir().isEmpty())) { for (Test vs : patient.getTestDir().getTestdir()) { dataset.addValue(Float.parseFloat(vs.getBloodPressure()), "Blood Pressure", vs.getTimestamp()); dataset.addValue(Float.parseFloat(vs.getBloodPlatlets()), "Blood Platelets", vs.getTimestamp()); dataset.addValue(Float.parseFloat(vs.getHemoglobinLevel()), "Hemoglobin Level", vs.getTimestamp()); //dataset.addValue(vs.getWeight(), "Weight", vs.getTimestamp()); }// w w w. j av a2 s. c o m JFreeChart chartFactory = ChartFactory.createBarChart3D("VitalSign", "Time", "VitalSign", dataset, PlotOrientation.VERTICAL, true, true, false); BarRenderer renderer = null; CategoryPlot plot = chartFactory.getCategoryPlot(); renderer = new BarRenderer(); ChartFrame frame = new ChartFrame("Bar Chart for VitalSign", chartFactory); frame.setVisible(true); frame.setSize(700, 320); } else { JOptionPane.showMessageDialog(this, "No Vital Signs To Display On Graph!!!"); } }
From source file:userinterface.AdminRole.DataAnalysisJPanel.java
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed // TODO add your handling code here: int haemo = 0, bp = 0, weight = 0, temp = 0; for (Organization org : enterprise.getOrganizationDirectory().getOrganizationList()) { if (org instanceof DonorOrganization) { for (Donor donor : org.getDonorDirectory().getDonorList()) { for (VitalSigns vs : donor.getVsh().getVitalSignHistory()) { if (vs.getHaemoglobinLevel() < 13) { haemo++;/* w w w. j av a2s. com*/ } if (vs.getBloodPressure() < 80 || vs.getBloodPressure() > 120) { bp++; } if (vs.getWeight() < 110 || vs.getWeight() > 400) { weight++; } if (vs.getTemperature() < 90 || vs.getTemperature() > 99) { temp++; } } } } } DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("haemoglobin", haemo); dataset.setValue("bloodpressure", bp); dataset.setValue("weight", weight); dataset.setValue("temperature", temp); JFreeChart chart = ChartFactory.createPieChart("DonorInformation", dataset, true, true, true); // CategoryPlot p = chart.getCategoryPlot(); // p.setRangeGridlinePaint(Color.black); PiePlot p = (PiePlot) chart.getPlot(); ChartFrame frame = new ChartFrame("Donor Information", chart); frame.setVisible(true); frame.setSize(450, 500); }