Example usage for org.jfree.chart ChartFrame ChartFrame

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

Introduction

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

Prototype

public ChartFrame(String title, JFreeChart chart) 

Source Link

Document

Constructs a frame for a chart.

Usage

From source file:snackbar2.BebidaReport.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:
    String m = "1";
    for (int i = 2; i < 32; i++) {
        m += "," + i;

    }//from ww  w  . j  a  va  2s  .c o m
    String range = "";
    String x = "";
    String y = "quantidade";
    String[] dias = m.split(",");
    String[] dias_semana = { "Seg", "Ter", "Qua", "Qui", "Sex", "Sab", "Dom" };
    String[] meses = "Jan,Fev,Mar,Abr,Mai,Jun,Jul,Ag,Set,Out,Nov,Dez".split(",");

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    JFreeChart chart = null;
    //se seleccionar semana
    if (jComboBox1.getSelectedIndex() == 1) {
        for (int i = 0; i < 7; i++) {
            dataset.setValue(listas.nrBebidasVendidosSemana(i), "Quantidade", dias_semana[i]);

        }
        x = "semana";
        chart = ChartFactory.createBarChart("Quantidade de bebidas vendidas durante a semana " + range, x, y,
                dataset, PlotOrientation.VERTICAL, false, true, false);
    }
    //se seleccionar mes
    else if (jComboBox1.getSelectedIndex() == 2) {
        for (int i = 0; i < listas.nrDaysOfMonth(new Date()); i++) {
            dataset.setValue(listas.nrBebidasVendidosMes(i), "Quantidade", i + 1);

        }
        x = "diss";
        chart = ChartFactory.createBarChart("Quantidade de bebidas vendidas durante o corrente mes " + range,
                x, y, dataset, PlotOrientation.VERTICAL, false, true, false);

    }
    //seleccionar ano
    else if (jComboBox1.getSelectedIndex() == 3) {
        for (int i = 0; i < 12; i++) {
            dataset.setValue(50 + i, "Quantidade", meses[i]);

        }
        x = "ano";
        chart = ChartFactory.createBarChart("Quantidade de bebidas vendidas durante o corrente ano " + range, x,
                y, dataset, PlotOrientation.VERTICAL, false, true, false);
    }
    //otherwise
    else {
        return;
    }

    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLACK);
    ChartFrame frame = new ChartFrame("Grfico de vendas de bebidas", chart);
    frame.setVisible(true);
    frame.setSize(600, 600);

}

From source file:Gui.admin.NouveauStatistique.java

private void StatistiquesBouttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StatistiquesBouttonActionPerformed

    int size = tablemesEvaluation.getRowCount();

    List<Double> notes = new ArrayList<Double>();
    List<Integer> ids = new ArrayList<Integer>();
    List<String> noms = new ArrayList<String>();
    EvaluationDAO evaluationDAO = new EvaluationDAO();
    System.out.println("ouh ouh  " + size);
    //System.out.println(evaluationDAO.getMoyenneByAdherent(8));
    int idadh;/*from   ww  w .j  a  v a 2 s . c o  m*/
    float ess;
    for (int i = 0; i < size; i++) {

        System.out.println(tablemesEvaluation.getValueAt(i, 4).toString());
        idadh = Integer.parseInt(tablemesEvaluation.getValueAt(i, 1).toString());
        String nom = (tablemesEvaluation.getValueAt(i, 2).toString());
        // notes.add((new Double (tablemesEvaluation.getValueAt(i,2).toString())));
        System.out.println(" id adherent " + idadh);
        // System.out.println("moyenne "+);
        ess = evaluationDAO.getMoyenneByAdherent(idadh);
        System.out.println(ess);
        // notes.add((new Double (evaluationDAO.getMoyenneByAdherent((int) tablemesEvaluation.getValueAt(i,1)))));
        notes.add((new Double(ess)));
        ids.add((int) tablemesEvaluation.getValueAt(i, 1));
        noms.add(nom);

    }

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int i = 0; i < size; i++) {

        dataset.setValue(new Double(notes.get(i)), "notes", new String(noms.get(i)));

    }

    //dataset.setValue(evaluationTable);

    JFreeChart chart = ChartFactory.createBarChart3D("Notes Adhrents", "Noms des 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(700, 800);
    ValueMarker marker = new ValueMarker(15);
    marker.setLabel(" seuil de l'valuation ");
    marker.setLabelAnchor(RectangleAnchor.CENTER);
    marker.setPaint(Color.YELLOW);
    p.addRangeMarker(marker);
    p.setRangeGridlinePaint(Color.RED);

    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:AirplaneSettings.java

public void planeGraph(List<Double> gp, List<Double> pp) {
    // Create XY series for the ground
    XYSeries ground = new XYSeries("Ground Height");
    for (int i = 0; i < gp.size(); i++)
        ground.add(i, gp.get(i));// w  w  w.  java 2  s  .  com

    // Create XY series for the plane
    XYSeries plane = new XYSeries("Plane Height");
    for (int i = 0; i < pp.size(); i++)
        plane.add(i, pp.get(i));

    // Add the series to the data set
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(ground);
    dataset.addSeries(plane);

    // Generate the graph
    JFreeChart memFunction = ChartFactory.createXYLineChart("Plane Flight", // Title
            "Time", // x-axis Label
            "Height", // 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("Plane Flight", memFunction);
    frame.pack();
    frame.setVisible(true);
}

From source file:snackbar2.FacturamentoReport.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:
    String m = "1";
    for (int i = 2; i < 32; i++) {
        m += "," + i;

    }//w  ww .  j ava 2 s  .com
    String range = "";
    String x = "";
    String y = "Valor";
    String[] dias = m.split(",");
    String[] dias_semana = { "Seg", "Ter", "Qua", "Qui", "Sex", "Sab", "Dom" };
    String[] meses = "Jan,Fev,Mar,Abr,Mai,Jun,Jul,Ag,Set,Out,Nov,Dez".split(",");

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    JFreeChart chart = null;
    //se seleccionar semana
    if (jComboBox1.getSelectedIndex() == 0) {
        for (Balconista b : listas.listaBalconista())
            dataset.setValue(listas.totalPorUsuario(b), "Quantidade", b.getNome());

        x = "Balconista";
        chart = ChartFactory.createBarChart("Total facturado durante o dia" + range, x, y, dataset,
                PlotOrientation.VERTICAL, false, true, false);
        System.out.println("Dadosss" + dataset.getColumnCount());

    }

    else if (jComboBox1.getSelectedIndex() == 1) {
        for (int i = 0; i < 7; i++) {
            dataset.setValue(listas.facturamentoSemanal(i), "Valor", dias_semana[i]);

        }
        x = "semana";
        chart = ChartFactory.createBarChart("Total facturado durante a semana " + range, x, y, dataset,
                PlotOrientation.VERTICAL, false, true, false);
    }
    //se seleccionar mes
    else if (jComboBox1.getSelectedIndex() == 2) {
        for (int i = 0; i < listas.nrDaysOfMonth(new Date()); i++) {
            dataset.setValue(listas.facturamentoMensal(i), "Valor", i + 1);

        }
        x = "diss";
        chart = ChartFactory.createBarChart("Total facturado durante o corrente ms " + range, x, y, dataset,
                PlotOrientation.VERTICAL, false, true, false);

    }
    //seleccionar ano
    else if (jComboBox1.getSelectedIndex() == 3) {
        for (int i = 0; i < 12; i++) {
            dataset.setValue(50 + i, "Valor", meses[i]);

        }
        x = "ano";
        chart = ChartFactory.createBarChart("Total facturado durante o corrente ano " + range, x, y, dataset,
                PlotOrientation.VERTICAL, false, true, false);
    }
    //otherwise
    else {
        return;
    }
    System.out.println("bla bla");
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLACK);
    ChartFrame frame = new ChartFrame("Grfico de vendas de pratos", chart);
    frame.setVisible(true);
    frame.setSize(600, 600);
}

From source file:library.ChartGUI.java

private void btBar2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btBar2ActionPerformed
    try {/*w ww .j a  v  a2  s.  c  om*/
        // TODO add your handling code here:
        JDBCCategoryDataset dataset = new JDBCCategoryDataset(da.getConnection(), sql1);
        JFreeChart chart = ChartFactory.createBarChart3D("Sum New Readers", "Month", "Count", dataset,
                PlotOrientation.VERTICAL, false, true, true);
        BarRenderer renderer = null;
        CategoryPlot plot = null;
        renderer = new BarRenderer();
        ChartFrame frame = new ChartFrame("Sum New Readers Chart", chart);
        frame.setVisible(true);
        frame.setSize(1250, 700);
        frame.setResizable(false);
    } catch (SQLException ex) {
        JOptionPane.showMessageDialog(null, ex);
    }
}

From source file:userInterface.doctor.ReportingPatientVitalHistJPanel.java

private void weightJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_weightJButtonActionPerformed
    // TODO add your handling code here:
    // TODO add your handling code here:
    DefaultTableModel dtm = (DefaultTableModel) vitalJTable.getModel();
    DefaultCategoryDataset weightbarChartSet = new DefaultCategoryDataset();
    for (VitalSignInfo vhl : patient.getVitalHistory().getVitalHistory()) {
        weightbarChartSet.setValue(vhl.getWeight(), "Weight", vhl.getCurrentTime());
    }/*from  w  w w . j  a  v a  2  s  .c  o m*/
    JFreeChart respChart = ChartFactory.createBarChart3D("Vital History", "Time", "Weight", weightbarChartSet,
            PlotOrientation.VERTICAL, false, true, false);
    respChart.setBackgroundPaint(Color.WHITE);
    respChart.getTitle().setPaint(Color.BLACK);
    CategoryPlot p = respChart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLUE);
    ChartFrame frame = new ChartFrame("Bar Chart for Vital Information: Weight", respChart);
    frame.setVisible(true);
    frame.setSize(450, 350);
}

From source file:swing.PrincipalMDI.java

private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
    // TODO add your handling code here:

    List<Ticket> serviceList = new ArrayList<>();

    for (Ticket t : list) {
        System.out.println(t.getSousService().getNom());
        if (t.getSousService().getNom().equals("Malpropret")) {
            serviceList.add(t);//  w ww .  j  a v a2  s.  co  m
        }
    }

    DefaultPieDataset pieDataSet = new DefaultPieDataset();

    for (Ticket ticket : serviceList) {
        pieDataSet.setValue(ticket.getSousService().getNom(), 1);
    }

    JFreeChart chart = ChartFactory.createPieChart3D("Camembert", pieDataSet, true, true, true);
    PiePlot3D p = (PiePlot3D) chart.getPlot();
    //p.setForegroundAlpha(TOP_ALIGNMENT);
    ChartFrame frame = new ChartFrame("camembert", chart);
    frame.setVisible(true);
    frame.setSize(600, 500);

}

From source file:UserInterface.CustomerRole.CustomerTaxJPanel.java

public void displayChart(Date date1) {
    int total = 0;
    int k;/*from  ww  w  .j a  va2 s . co 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:org.jfree.chart.demo.SymbolicXYPlotDemo.java

/**
 * Vertically combined sample1 and sample2 and display it.
 * /*from   w  w  w.  j  a  v a 2 s.  c o m*/
 * @param frameTitle
 *           the frame title.
 * @param data1
 *           the dataset 1.
 * @param data2
 *           the dataset 2.
 */
private static void displayXYSymbolicCombinedVertically(final String frameTitle, final XYDataset data1,
        final XYDataset data2) {

    final String title = "Pollutant Vertically Combined";
    final String xAxisLabel = "Contamination and Type";
    final String yAxisLabel = "Pollutant";

    // combine the x symbolic values of the two data sets
    final String[] combinedXSymbolicValues = SampleXYSymbolicDataset
            .combineXSymbolicDataset((XisSymbolic) data1, (XisSymbolic) data2);

    // make master dataset...
    final CombinedDataset data = new CombinedDataset();
    data.add(data1);
    data.add(data2);

    // decompose data...
    final XYDataset series0 = new SubSeriesDataset(data, 0);
    final XYDataset series1 = new SubSeriesDataset(data, 1);

    // common horizontal and vertical axes
    final SymbolicAxis hsymbolicAxis = new SymbolicAxis(xAxisLabel, combinedXSymbolicValues);

    final SymbolicAxis vsymbolicAxis0 = new SymbolicAxis(yAxisLabel,
            ((YisSymbolic) data1).getYSymbolicValues());

    final SymbolicAxis vsymbolicAxis1 = new SymbolicAxis(yAxisLabel,
            ((YisSymbolic) data2).getYSymbolicValues());

    // create the main plot...
    final CombinedDomainXYPlot mainPlot = new CombinedDomainXYPlot(hsymbolicAxis);

    // add the sub-plots...
    final XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null);
    final XYPlot subplot0 = new XYPlot(series0, null, vsymbolicAxis0, renderer);
    final XYPlot subplot1 = new XYPlot(series1, null, vsymbolicAxis1, renderer);

    mainPlot.add(subplot0, 1);
    mainPlot.add(subplot1, 1);

    // make the chart...
    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, mainPlot, true);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));

    // and present it in a frame...
    final JFrame frame = new ChartFrame(frameTitle, chart);
    frame.pack();
    RefineryUtilities.positionFrameRandomly(frame);
    frame.show();

}

From source file:userInterface.SystemAdmin.PovertyAnalysisJPanel.java

private void crimeAnalysisJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_crimeAnalysisJButtonActionPerformed
    JFreeChart pieChart = ChartFactory.createPieChart("Crminal Incidents", pireChartDataset, true, true, true);
    PiePlot plot = (PiePlot) pieChart.getPlot();
    ChartFrame perFrame = new ChartFrame("Crminal Incidents By Network ", pieChart);
    perFrame.setVisible(true);//from   w  w  w.java  2  s  .  c  o  m
    perFrame.setSize(500, 500);
}