Example usage for org.jfree.chart ChartFrame setVisible

List of usage examples for org.jfree.chart ChartFrame setVisible

Introduction

In this page you can find the example usage for org.jfree.chart ChartFrame setVisible.

Prototype

public void setVisible(boolean b) 

Source Link

Document

Shows or hides this Window depending on the value of parameter b .

Usage

From source file:AirplaneSettings.java

public void memFuncGraph() {
    // Create XY series for very low flight
    XYSeries veryLow = new XYSeries("Very Low");
    veryLow.add(0.5 * height, veryLow(0.5 * height));
    veryLow.add(0.7 * height, veryLow(0.7 * height));
    veryLow.add(0.8 * height, veryLow(0.8 * height));
    veryLow.add(1.5 * height, veryLow(1.5 * height));

    // Create XY series for low flight
    XYSeries low = new XYSeries("Low");
    low.add(0.5 * height, low(0.5 * height));
    low.add(0.7 * height, low(0.7 * height));
    low.add(0.8 * height, low(0.8 * height));
    low.add(0.9 * height, low(0.9 * height));
    low.add(1.0 * height, low(1.0 * height));
    low.add(1.5 * height, low(1.5 * height));

    // Create XY series for high flight
    XYSeries high = new XYSeries("High");
    high.add(0.5 * height, high(0.5 * height));
    high.add(1.0 * height, high(1.0 * height));
    high.add(1.1 * height, high(1.1 * height));
    high.add(1.2 * height, high(1.2 * height));
    high.add(1.3 * height, high(1.3 * height));
    high.add(1.5 * height, high(1.5 * height));

    // Create XY series for very high flight
    XYSeries veryHigh = new XYSeries("Very High");
    veryHigh.add(0.5 * height, veryHigh(0.5 * height));
    veryHigh.add(1.2 * height, veryHigh(1.2 * height));
    veryHigh.add(1.3 * height, veryHigh(1.3 * height));
    veryHigh.add(1.5 * height, veryHigh(1.5 * height));

    // Add the series to the data set
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(veryLow);/*from   ww w. ja va2  s  . co m*/
    dataset.addSeries(low);
    dataset.addSeries(high);
    dataset.addSeries(veryHigh);

    // Generate the graph
    JFreeChart memFunction = ChartFactory.createXYLineChart("Membership Functions", // Title
            "Plane Height", // x-axis Label
            "Degree", // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            true, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );

    ChartFrame frame = new ChartFrame("Membership Functions", memFunction);
    frame.pack();
    frame.setVisible(true);
}

From source file:UserInterfaces.HAdministration.ReportDataJPanel.java

private void personneljButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_personneljButton3ActionPerformed
    // TODO add your handling code here:
    int timeofadmin = 0;
    int timeofnurse = 0;
    int timeofpathology = 0;
    int timeofphar = 0;
    int timeofphysician = 0;
    int timeofsurgeon = 0;

    for (WorkRequest workRequest : organization.getWorkQueue().getWorkRequestList()) {
        for (ErrorPerson ep : workRequest.getEpd().getErrorpersonlist()) {

            if (ep instanceof AdminstrationErrorPerson) {
                // if (ep.getEpt().getValue().equals(ErrorPerson.ErrorPersonType.ADMINSTRATION.getValue())) {
                timeofadmin = timeofadmin + 1;
            }/*from  w  ww .  j  ava 2s .co  m*/
            if (ep instanceof NurseErrorPerson) {
                timeofnurse = timeofnurse + 1;
            }
            if (ep instanceof PathologistriceErrorPerson) {
                timeofpathology = timeofpathology + 1;
            }
            if (ep instanceof PharmacistErrorPerson) {
                timeofphar = timeofphar + 1;
            }
            if (ep instanceof PhysicianErrorPerson) {
                timeofphysician = timeofphysician + 1;
            }
            if (ep instanceof SurgeonErrorPerson) {
                timeofsurgeon = timeofsurgeon + 1;

            }

            /*if (ep.getEpt().equals(ErrorPerson.ErrorPersonType.NURESE)) {
             timeofnurse = timeofnurse + 1;
             }
             if (ep.getEpt().equals(ErrorPerson.ErrorPersonType.PATHOLOGIST)) {
             timeofpathology = timeofpathology + 1;
             }
             if (ep.getEpt().equals(ErrorPerson.ErrorPersonType.PHARMACIST)) {
             timeofphar = timeofphar + 1;
             }
             if (ep.getEpt().equals(ErrorPerson.ErrorPersonType.PHYSICIAN)) {
             timeofphysician = timeofphysician + 1;
             }
             if (ep.getEpt().equals(ErrorPerson.ErrorPersonType.SURGEON)) {
             timeofsurgeon = timeofsurgeon + 1;
             }*/
        }
    }
    ReportToReporter report = organization.getReport();
    report.setTimeofadmin(timeofadmin);
    report.setTimeofnurse(timeofnurse);
    report.setTimeofpathology(timeofpathology);
    report.setTimeofphar(timeofphar);
    report.setTimeofphysician(timeofphysician);
    report.setTimeofsurgeon(timeofsurgeon);
    report.setStatus("success");

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(timeofadmin, "Adminstration", "Adminstration");
    dataset.addValue(timeofnurse, "Nurse", "Nurse");
    dataset.addValue(timeofpathology, "Pathologist", "Pathologist");
    dataset.addValue(timeofphar, "Pharmacist", "Pharmacist");
    dataset.addValue(timeofphysician, "Physician", "Physician");
    dataset.addValue(timeofsurgeon, "Surgeon", "Surgeon");
    //dataset.setValue(80, "masd", "sss");

    JFreeChart chart = ChartFactory.createBarChart("Personnel", "Position", "Times", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setRangeGridlinePaint(Color.WHITE);
    ChartFrame frame = new ChartFrame("Chart for ERROR", chart);
    frame.setVisible(true);
    frame.setSize(900, 700);

    for (Network network : es.getNetworkList()) {
        for (Enterprise e : network.getEd().getEnterprisesList()) {
            if (e.getOrgName().equals(enterprise.getOrgName())) {
                for (Enterprise en : network.getEd().getEnterprisesList()) {
                    if (e instanceof HospitalEnterprise || e instanceof ClinicEnterprise) {
                        e.setReport(report);
                    }
                }
            }

        }

    }

}

From source file:UserInterfaces.HAdministration.ReportDataJPanel.java

private void sourcejButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sourcejButton1ActionPerformed
    // TODO add your handling code here:
    int firsthandnumber = 0;
    int secondhandnumber = 0;

    // int workrequestSize = organization.getWorkQueue().getWorkRequestList().size();
    // WorkRequest lastRequest = organization.getWorkQueue().getWorkRequestList().get(workrequestSize - 1);
    for (WorkRequest workRequest : organization.getWorkQueue().getWorkRequestList()) {
        if (workRequest.getSource().toString().equals(Source.FIRST)) {
            firsthandnumber = firsthandnumber + 1;
        }/*from  w w  w  .  ja  v  a  2s .  c om*/
        if (workRequest.getSource().toString().equals(Source.SECOND)) {
            secondhandnumber = secondhandnumber + 1;
        }
    }

    ReportToReporter report = organization.getReport();
    report.setFirsthandsource(firsthandnumber);
    report.setSecondhandsource(secondhandnumber);
    report.setStatus("success");

    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("First hand", firsthandnumber);
    dataset.setValue("Second hand", secondhandnumber);

    JFreeChart chart = ChartFactory.createPieChart("Source of Reports", dataset, true, true, true);

    PiePlot p = (PiePlot) chart.getPlot();

    ChartFrame chartFrame = new ChartFrame("Source of Reports", chart);
    chartFrame.setSize(450, 550);
    chartFrame.setVisible(true);

    for (Network network : es.getNetworkList()) {
        for (Enterprise e : network.getEd().getEnterprisesList()) {
            if (e.getOrgName().equals(enterprise.getOrgName())) {
                for (Enterprise en : network.getEd().getEnterprisesList()) {
                    if (en instanceof HospitalEnterprise || en instanceof ClinicEnterprise) {
                        en.setReport(report);
                    }
                }
            }
        }

    }

}

From source file:userinterface.HealthAnalystRole.ViewReportJPanel.java

private void createChart() {
    DefaultCategoryDataset healthDataset = new DefaultCategoryDataset();
    int selectedRow = tblHealthTable.getSelectedRow();
    Device effects = (Device) tblHealthTable.getValueAt(selectedRow, 0);
    //Device device= device.getEffectsOnBodyList().getEffectsOnBodyList().;

    for (Device d : organization.getDeviceDirectory().getDeviceList()) {
        if (d.getEffectsOnBodyList().getEffectsOnBodyList().isEmpty()
                || d.getEffectsOnBodyList().getEffectsOnBodyList().size() == 1) {
            JOptionPane.showMessageDialog(this,
                    "No body organs or only one body organ affected found. At least 2 organs effected records needed to show chart!",
                    "Warning", JOptionPane.INFORMATION_MESSAGE);
            return;
        } else {//  ww  w.  ja  v a 2s  . com
            Double organ = Double.parseDouble(txtOrgan.getText());
            Double value = d.getMaxSAR();
        }
    }
    //ArrayList<EffectsOnBody> effectsOnBodyList = device.getEffectsOnBodyList().getEffectsOnBodyList();

    /*if (effectsOnBodyList.isEmpty() || effectsOnBodyList.size() == 1) {
    JOptionPane.showMessageDialog(this, "No body organs or only one body organ affected found. At least 2 organs effected records needed to show chart!", "Warning", JOptionPane.INFORMATION_MESSAGE);
    return;
    }*/
    Double organ = Double.parseDouble(txtOrgan.getText());
    for (Device device : organization.getDeviceDirectory().getDeviceList()) {
        for (EffectsOnBody b1 : device.getEffectsOnBodyList().getEffectsOnBodyList()) {
            Double value = device.getMaxSAR();

            //healthDataset.addValue(vitalSign.getHeartRate(),"Most Likely Diseases", device.getMaxSAR());
            //vitalSignDataset.addValue(vitalSign.getBloodPressure(),"BP", vitalSign.getTimestamp());
            //vitalSignDataset.addValue(vitalSign.getWeight(),"WT", vitalSign.getTimestamp());
        }

    }

    JFreeChart healthSignChart = ChartFactory.createBarChart3D("Effects On Health Chart", "Time Stamp", "Rate",
            healthDataset, PlotOrientation.VERTICAL, true, false, false);
    healthSignChart.setBackgroundPaint(Color.white);
    CategoryPlot vitalSignChartPlot = healthSignChart.getCategoryPlot();
    vitalSignChartPlot.setBackgroundPaint(Color.lightGray);

    CategoryAxis vitalSignDomainAxis = vitalSignChartPlot.getDomainAxis();
    vitalSignDomainAxis
            .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    NumberAxis vitalSignRangeAxis = (NumberAxis) vitalSignChartPlot.getRangeAxis();
    vitalSignRangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    ChartFrame chartFrame = new ChartFrame("Chart", healthSignChart);
    chartFrame.setVisible(true);
    chartFrame.setSize(500, 500);

}

From source file:StoreAdmin.ManageStoreJPanel.java

private void btntopfiveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btntopfiveActionPerformed
    DefaultTableModel dtm = (DefaultTableModel) tblsearchedproduct.getModel();
    dtm.getRowCount();//from  w  w w . j a  va 2  s . co m

    System.out.println(dtm.getRowCount());

    if (dtm.getRowCount() < 4) {
        JOptionPane.showMessageDialog(null, "Inventory must have more than 4 products to plot the graph");

    } else {

        JFreeChart plotGraphInventory = ChartFactory.createBarChart("Top 5 products in Store", "Products",
                "Profit", plotGrapghInventory(), PlotOrientation.VERTICAL, true, true, false);

        ChartPanel chartPanel = new ChartPanel(plotGraphInventory);
        chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
        ChartFrame frame = new ChartFrame("Market Report", plotGraphInventory);
        frame.setVisible(true);
        frame.setSize(500, 270);
    } //GEN-LAST:event_btntopfiveActionPerformed
}

From source file:com.smanempat.controller.ControllerClassification.java

public void showChart(JLabel jumlahSiswaIPA, JLabel jumlahSiswaIPS, JLabel labelKeterangan) {
    DefaultCategoryDataset barChartData = new DefaultCategoryDataset();
    barChartData.setValue(Integer.parseInt(jumlahSiswaIPA.getText()), "IPA", "IPA");
    barChartData.setValue(Integer.parseInt(jumlahSiswaIPS.getText()), "IPS", "IPS");
    JFreeChart barchart = ChartFactory.createBarChart3D(
            "Grafik Jumlah Siswa per Jurusan, Tahun Ajaran " + labelKeterangan.getText().substring(53, 62) + "",
            "Jurusan", "Jumlah Siswa", barChartData, PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot plotBarChart = barchart.getCategoryPlot();
    ChartFrame chartFrame = new ChartFrame("Grafik Jumlah Siswa Tiap Jurusan", barchart, true);
    chartFrame.setVisible(true);
    chartFrame.setSize(700, 500);/*from   www  .  j ava 2  s . c  o  m*/
    chartFrame.setLocationRelativeTo(null);
    plotBarChart.setRangeGridlinePaint(java.awt.Color.black);
    ChartPanel chartPanel = new ChartPanel(barchart);
}

From source file:UserInterface.TMAnalystRole.TMAnaylstWorkAreaJPanel.java

private void btnRouteAnalysisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRouteAnalysisActionPerformed
    // TODO add your handling code here:
    Line selectedLine = (Line) cboActiveLines.getSelectedItem();
    ArrayList<Route> routeList = new ArrayList<>();

    for (Segment s : selectedLine.getSegments()) {
        routeList.add(s.getRoutes().get(0));
    }/*from   w w  w .jav  a2s .  c  o m*/

    ArrayList<Segment> segmentList = selectedLine.getSegments();
    for (int i = segmentList.size() - 1; i >= 0; i--) {
        routeList.add(segmentList.get(i).getRoutes().get(1));
    }

    int days = (int) spnrRecord.getValue();
    Date today = new Date();
    Date olderThanToday = new Date();
    olderThanToday.setTime(today.getTime() + (long) (-days) * 1000 * 60 * 60 * 24);
    long todayDate = (today.getTime()) / (1000 * 60 * 60 * 24);
    long olderDate = (olderThanToday.getTime()) / (1000 * 60 * 60 * 24);

    Map<Route, Integer> routesWithCapacityList = new LinkedHashMap<>();

    for (Route r : routeList) {
        int routeCount = 0;

        for (TimeSlot.TimeSlotRange ts : TimeSlot.TimeSlotRange.values()) {
            Train selectedTrain = r.fetchRouteSchedule(ts).getTrainOffered();
            int intermediateCount = 0;
            int trainsFound = 0;
            for (TrainOffered selectedTrainOffered : enterprise.getTrainsOfferedHistory().getTrainsOffered()) {
                if (selectedTrainOffered.getTrain().equals(selectedTrain)) {
                    long selectedDate = (selectedTrainOffered.getDayOffered().getTime())
                            / (1000 * 60 * 60 * 24);
                    if (selectedDate >= olderDate && selectedDate <= todayDate) {
                        intermediateCount += selectedTrainOffered.fetchRunningTrainByTimeSlot(ts)
                                .getRunningCapacity();
                        trainsFound++;
                    }
                }

            }
            if (trainsFound != 0) {
                intermediateCount = intermediateCount / trainsFound;
                routeCount += intermediateCount;
            }
        }
        routeCount = Math.round(routeCount / 15);
        routesWithCapacityList.putIfAbsent(r, routeCount);
    }

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    for (Map.Entry<Route, Integer> entry : routesWithCapacityList.entrySet()) {
        dataset.setValue(entry.getValue(), "Routes", entry.getKey().getRouteName());

    }

    JFreeChart chart = ChartFactory.createBarChart(
            "Congestion Levels of Line : " + selectedLine.getLineName() + " for " + days + " days", "Routes",
            "Average Congestion Levels", dataset, PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setRangeGridlinePaint(Color.BLUE);
    ChartFrame frame = new ChartFrame("Bar Chart for Congestion Analysis", chart);
    frame.setVisible(true);
    frame.setSize(this.getWidth(), this.getHeight() + 200);

}

From source file:UserInterface.WaterSupplyAdmin.UsagePatternJPanel.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    int total = 0;

    for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) {
        if (organization instanceof CustomerOrganization) {
            for (Employee employee : organization.getEmployeeDirectory().getEmployeeList()) {
                Customer customer = (Customer) employee;
                total += customer.getTotalUsageVolume();
            }//w  ww .jav  a  2  s  .c  om
        }
    }
    if (total == 0) {
        JOptionPane.showMessageDialog(null, "No Customer has used water yet");
        return;
    }
    DefaultPieDataset dataset = new DefaultPieDataset();
    for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) {
        if (organization instanceof CustomerOrganization) {
            for (Employee employee : organization.getEmployeeDirectory().getEmployeeList()) {
                Customer customer = (Customer) employee;
                dataset.setValue(customer.getName(), customer.getTotalUsageVolume());
            }
        }
    }

    JFreeChart chart = ChartFactory.createPieChart3D("Customer Water Usage", dataset, true, true, true);
    ChartFrame frame = new ChartFrame("Pie Chart demonstrating customer water usage ", chart);
    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(200);
    plot.setForegroundAlpha(0.50f);
    RefineryUtilities.centerFrameOnScreen(frame);
    frame.setVisible(true);
    frame.setSize(650, 550);
}

From source file:UserInterface.CustomerRole.CustomerTaxJPanel.java

public void displayChart(Date date1) {
    int total = 0;
    int k;/* ww w  .  j  a va  2 s  . c  o m*/
    int count = 0;
    int avg = 0;

    Sensor s = (Sensor) jTable1.getValueAt(0, 0);
    Date b = s.getDate();
    DateFormat formatter = new SimpleDateFormat("MM/dd/yy");
    Date date = new Date();
    try {
        date = formatter.parse("12/11/16");
    } catch (Exception e) {

    }
    //date = 
    System.out.println(jTable1.getValueAt(0, 5));
    System.out.println(jTable1.getValueAt(0, 4));
    list = new ArrayList<>();

    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getCurrentEmissionCO2();
            count++;
        }
    }
    avg = total / count;
    list.add(avg);

    int avg1 = 0;

    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getCurrentEmissionCO2();
            count++;
        }
    }

    avg = total / count;
    list.add(avg);
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getNormalCO2();
            count++;
        }
    }
    avg1 = total / count;
    int avg3 = 0;
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getCurrentEmissionNOx();
            count++;
        }
    }
    avg3 = total / count;

    int avg4 = 0;
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getNormalNOx();
            count++;
        }
    }
    avg4 = total / count;

    int avg5 = 0;
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getSolarCurrentEmissionCO2();
            count++;
        }
    }
    avg5 = total / count;
    int avg6 = 0;

    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getSolarNormalCO2();
            count++;
        }
    }

    avg6 = total / count;
    int avg7 = 0;
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getSolarCurrentEmissionNOx();
            count++;
        }
    }
    avg7 = total / count;
    int avg8 = 0;
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getSolarNormalNOx();
            count++;
        }
    }
    avg8 = total / count;

    int combo = avg + avg3;
    int combo1 = avg5 + avg7;

    DefaultPieDataset dataset22 = new DefaultPieDataset();
    dataset22.setValue("Fuel Emission", new Integer(combo));
    dataset22.setValue("Solar Emission ", new Integer(combo1));

    JFreeChart chart22 = ChartFactory.createPieChart3D("Comparison Chart ", // chart title                   
            dataset22, // data 
            true, // include legend                   
            true, false);

    final PiePlot3D plot = (PiePlot3D) chart22.getPlot();
    plot.setStartAngle(270);
    plot.setForegroundAlpha(0.60f);
    plot.setInteriorGap(0.02);

    ChartFrame frame33 = new ChartFrame("3D Pie Chart for EMission Comparison from different sources", chart22);
    frame33.setVisible(true);
    frame33.setSize(500, 400);

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(avg, b, "curr CO2");
    dataset.setValue(avg1, b, "normal CO2");
    dataset.setValue(avg3, b, "current NOx");
    dataset.setValue(avg4, b, "normal NOx");
    //dataset.setValue(a1,b1,"current");
    JFreeChart chart = ChartFactory.createBarChart("Normal Fuel Emission Chart", "CO2 Emission", "in (g/KM)",
            dataset, PlotOrientation.VERTICAL, false, false, false);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLACK);
    ChartFrame frame = new ChartFrame("Bar Chart for Customer", chart);
    frame.setVisible(true);
    frame.setSize(500, 400);

    DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
    dataset1.setValue(avg5, b, "curr CO2");
    dataset1.setValue(avg6, b, "normal CO2");
    dataset1.setValue(avg7, b, "current NOx");
    dataset1.setValue(avg8, b, "normal NOx");
    //dataset.setValue(a1,b1,"current");
    JFreeChart chart2 = ChartFactory.createBarChart("Solar Emission Chart", "CO2 Emission", "in (g/KM)",
            dataset1, PlotOrientation.VERTICAL, false, false, false);
    CategoryPlot p1 = chart.getCategoryPlot();
    p1.setRangeGridlinePaint(Color.BLACK);
    ChartFrame frame1 = new ChartFrame("Bar Chart for Customer", chart2);
    frame1.setVisible(true);
    frame1.setSize(500, 400);
}

From source file:userInteface.Patient.ManageVitalSignsJPanel.java

private void createChart() {
    DefaultCategoryDataset vitalSignDataset = new DefaultCategoryDataset();
    int selectedRow = viewPatientsJTable.getSelectedRow();
    Person person = (Person) viewPatientsJTable.getValueAt(selectedRow, 0);
    Patient patient = person.getPatient();
    if (patient == null) {
        JOptionPane.showMessageDialog(this, "Patient not created, Please create Patient first.", "Error",
                JOptionPane.ERROR_MESSAGE);
        return;/*from   ww w .  j  a v a2s  . com*/
    }

    ArrayList<VitalSign> vitalSignList = patient.getVitalSignHistory().getHistory();
    /*At least 2 vital sign records needed to show chart */
    if (vitalSignList.isEmpty() || vitalSignList.size() == 1) {
        JOptionPane.showMessageDialog(this,
                "No vital signs or only one vital sign found. At least 2 vital sign records needed to show chart!",
                "Warning", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    for (VitalSign vitalSign : vitalSignList) {
        vitalSignDataset.addValue(vitalSign.getRespiratoryRate(), "RR", vitalSign.getTimestamp());
        vitalSignDataset.addValue(vitalSign.getHeartRate(), "HR", vitalSign.getTimestamp());
        vitalSignDataset.addValue(vitalSign.getBloodPressure(), "BP", vitalSign.getTimestamp());
        vitalSignDataset.addValue(vitalSign.getWeight(), "WT", vitalSign.getTimestamp());
    }

    JFreeChart vitalSignChart = ChartFactory.createBarChart3D("Vital Sign Chart", "Time Stamp", "Rate",
            vitalSignDataset, PlotOrientation.VERTICAL, true, false, false);
    vitalSignChart.setBackgroundPaint(Color.white);
    CategoryPlot vitalSignChartPlot = vitalSignChart.getCategoryPlot();
    vitalSignChartPlot.setBackgroundPaint(Color.lightGray);

    CategoryAxis vitalSignDomainAxis = vitalSignChartPlot.getDomainAxis();
    vitalSignDomainAxis
            .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    NumberAxis vitalSignRangeAxis = (NumberAxis) vitalSignChartPlot.getRangeAxis();
    vitalSignRangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    ChartFrame chartFrame = new ChartFrame("Chart", vitalSignChart);
    chartFrame.setVisible(true);
    chartFrame.setSize(500, 500);

}