Example usage for org.jfree.chart ChartFactory createBarChart3D

List of usage examples for org.jfree.chart ChartFactory createBarChart3D

Introduction

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

Prototype

public static JFreeChart createBarChart3D(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset) 

Source Link

Document

Creates a bar chart with a 3D effect.

Usage

From source file:CalcoloRitardiLotti.java

public static void main(String[] args) {
    String id_ref = "cbededce-269f-48d2-8c25-2359bf246f42";
    String requestString = "http://dati.openexpo2015.it/catalog/api/action/datastore_search?resource_id="
            + id_ref;/*w ww. ja va 2s .c om*/
    HttpClient client = HttpClientBuilder.create().build();
    HttpGet request = new HttpGet(requestString);
    try {

        HttpResponse response = client.execute(request);
        BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
        String result = "";
        String resline = "";
        Calendar c = Calendar.getInstance();
        Date current = Date.valueOf(
                c.get(Calendar.YEAR) + "-" + (c.get(Calendar.MONTH) + 1) + "-" + c.get(Calendar.DAY_OF_MONTH));
        while ((resline = rd.readLine()) != null)
            result += resline;

        //System.out.println(jsonObject.toString());
        if (result != null) {
            JSONObject jsonObject = new JSONObject(result);
            JSONObject resultJson = (JSONObject) jsonObject.get("result");
            JSONArray records = (JSONArray) resultJson.get("records");
            Date temp1, temp2;
            //System.out.printf(records.toString());
            long diffInizioFineLavori;
            long ritardo;
            long den = (24 * 60 * 60 * 1000);
            JSONObject temp;

            DefaultCategoryDataset cdata = new DefaultCategoryDataset();
            String partialQuery;
            DefaultPieDataset data = new DefaultPieDataset();

            String totalQuery = "";
            int countSospesi = 0;
            int countConclusi = 0;
            int countVerifica = 0;
            int countInCorso = 0;
            int countCollaudo = 0;
            String stato;
            for (int i = 0; i < records.length(); i++) {
                temp = (JSONObject) records.get(i);
                temp1 = Date.valueOf((temp.getString("Data Consegna Lavori")).substring(0, 10));
                temp2 = Date.valueOf((temp.getString("Data Fine lavori")).substring(0, 10));
                diffInizioFineLavori = (long) (temp2.getTime() - temp1.getTime()) / den;
                stato = temp.getString("STATO");
                if (stato.equals("Concluso"))
                    countConclusi++;
                else if (stato.equals("In corso"))
                    countInCorso++;
                else if (stato.contains("Verifiche"))
                    countVerifica++;
                else if (stato.contains("Collaudo sospeso") || stato.contains("sospeso"))
                    countSospesi++;
                else
                    countCollaudo++;

                if (!temp.getString("STATO").equals("Concluso") && temp2.getTime() < current.getTime())
                    ritardo = (long) (current.getTime() - temp2.getTime()) / den;
                else
                    ritardo = 0;

                cdata.setValue(ritardo, String.valueOf(i + 1), String.valueOf(i + 1));
                System.out.println(
                        "Opera: " + temp.getString("Oggetto del lotto") + " | id: " + temp.getInt("_id"));
                System.out.println("Data consegna lavoro: " + temp.getString("Data Consegna Lavori")
                        + " | Data fine lavoro: " + temp.getString("Data Fine lavori"));
                System.out.println("STATO: " + temp.getString("STATO"));
                System.out.println("Differenza in giorni: " + diffInizioFineLavori
                        + " | Numero giorni contrattuali: " + temp.getString("numero di giorni contrattuali"));
                System.out.println("Ritardo accumulato: " + ritardo);

                System.out.println("----------------------------------");

                partialQuery = "\nid: " + temp.getInt("_id") + "\nOpera:" + temp.getString("Oggetto del lotto")
                        + "\n" + "Data consegna lavoro: " + temp.getString("Data Consegna Lavori")
                        + "Data fine lavoro: " + temp.getString("Data Fine lavori") + "\n" + "STATO: "
                        + temp.getString("STATO") + "\n" + "Differenza in giorni: " + diffInizioFineLavori
                        + " - Numero giorni contrattuali: " + temp.getString("numero di giorni contrattuali")
                        + "\n" + "Ritardo accumulato: " + ritardo + "\n"
                        + "----------------------------------\n";
                totalQuery = totalQuery + partialQuery;

            }

            JFreeChart chart1 = ChartFactory.createBarChart3D("RITARDI AL " + current, "Id lotto",
                    "ritardo(in giorni)", cdata);
            ChartRenderingInfo info = null;
            ChartUtilities.saveChartAsPNG(
                    new File(System.getProperty("user.dir") + "/istogramma" + current + ".png"), chart1, 1500,
                    1500, info, true, 10);
            FileUtils.writeStringToFile(new File(current + "_1.txt"), totalQuery);

            data.setValue("Conclusi: " + countConclusi, countConclusi);
            data.setValue("Sospeso: " + countSospesi, countSospesi);
            data.setValue("In Corso: " + countInCorso, countInCorso);
            data.setValue("Verifica: " + countVerifica, countVerifica);
            data.setValue("Collaudo: " + countCollaudo, countCollaudo);
            JFreeChart chart2 = ChartFactory.createPieChart3D("Statistiche del " + current, data, true, true,
                    true);
            ChartUtilities.saveChartAsPNG(new File(System.getProperty("user.dir") + "/pie" + current + ".png"),
                    chart2, 800, 450);

        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:erpsystem.chart.Charts.java

/**Gafico criado para mostrar 
o faturamento considerando o // w w w  . j  a  v  a  2  s .c  o m
valor bruto das sadas das compras R$
e valor bruto das entradas das vendas R$
realizadas no perodo especificado
Tambm  de responsabilidade do grfico
monstrar graficamente o valor do lucro.
*/

public static BufferedImage create001(int w, int h, Calendar initialCalendar, Calendar finalCalendar) {
    DefaultCategoryDataset ds = new DefaultCategoryDataset();
    String COMPRA = "Compra R$";
    String VENDA = "Venda R$";
    String LUCRO = "Lucro R$";

    long initialDate = initialCalendar.getTime().getTime();
    long finalDate = finalCalendar.getTime().getTime();

    //toString para depurao.
    String s1 = toString(initialCalendar);
    String s2 = toString(finalCalendar);

    double compra = erpsystem.db.chart.Chart001.getValorCompraEm(initialDate, finalDate);
    double venda = erpsystem.db.chart.Chart001.getValorVendaEm(initialDate, finalDate);
    double lucro = erpsystem.db.chart.Chart001.getValorLucroEm(initialDate, finalDate);

    ds.addValue(compra, COMPRA, COMPRA);
    ds.addValue(venda, VENDA, VENDA);
    ds.addValue(lucro, LUCRO, LUCRO);

    JFreeChart chart = ChartFactory.createBarChart3D("Faturamento", "Faturamento", "Valor R$", ds);

    return chart.createBufferedImage(w, h);
}

From source file:id.aas.apps.mvc.view.barChart.java

public void setChart() throws SQLException {
    double Lunas = 0;
    double Casbon = 0;
    String queryLunas = "SELECT SUM(total_tagihan) from transaksi where keterangan='Lunas'";
    String queryCasbon = "SELECT SUM(total_tagihan) from transaksi where keterangan='Cash Bon'";
    ConnectionDB.InstanceDB.openConnection();
    ResultSet rs = ConnectionDB.InstanceDB.RunSelectQuery(queryLunas);
    while (rs.next()) {
        Lunas = rs.getDouble(1);//from  w w w  . j  av  a  2  s .com
    }
    System.out.println(Lunas);

    ResultSet rs1 = ConnectionDB.InstanceDB.RunSelectQuery(queryCasbon);
    while (rs1.next()) {
        Casbon = rs1.getDouble(1);
    }
    System.out.println(Casbon);

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(Lunas, "Lunas", "Catatan Uang Pendapatan");
    dataset.setValue(Casbon, "Cash Bon", "Catatan Uang Pendapatan");

    JFreeChart chart = ChartFactory.createBarChart3D("Catatan Uang Pendapatan dan Piutang",
            "Keterangan Pembayaran", "Jumlah Uang", dataset);
    ChartPanel cPanel = new ChartPanel(chart);
    this.setContentPane(cPanel);
}

From source file:id.aas.apps.mvc.view.chartFrame.java

void bar() {
    try {/*from  w w w  .  j a va 2 s .  co  m*/
        double Lunas = 0;
        double Casbon = 0;

        String queryLunas = "SELECT SUM(total_tagihan) from transaksi where keterangan='Lunas'";
        String queryCasbon = "SELECT SUM(total_tagihan) from transaksi where keterangan='Cash Bon'";
        ConnectionDB.InstanceDB.openConnection();
        ResultSet rs = ConnectionDB.InstanceDB.RunSelectQuery(queryLunas);
        while (rs.next()) {
            Lunas = rs.getDouble(1);
        }
        System.out.println(Lunas);

        ResultSet rs1 = ConnectionDB.InstanceDB.RunSelectQuery(queryCasbon);
        while (rs1.next()) {
            Casbon = rs1.getDouble(1);
        }
        System.out.println(Casbon);
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.setValue(Lunas, "Lunas", "Catatan Uang Pendapatan");
        dataset.setValue(Casbon, "Cash Bon", "Catatan Uang Pendapatan");

        JFreeChart chart = ChartFactory.createBarChart3D("Catatan Uang Pendapatan dan Piutang Laundry",
                "Keterangan Pembayaran", "Jumlah Uang", dataset);
        chart.setBorderVisible(false);
        chart.setBackgroundPaint(null);

        //            BufferedImage image = chart.createBufferedImage(500, 300);
        //            jLabel1.setIcon(new ImageIcon(image));
        ChartPanel cPanel = new ChartPanel(chart);
        setBounds(100, 100, 685, 429);
        jPanel2 = new JPanel();
        jPanel2.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(jPanel2);
        jPanel2.setLayout(null);
        jPanel2.add(cPanel);
        jTabbedPane1.add(jPanel2);
        setVisible(true);
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

From source file:de.h_da.fbi.rfid.gui.UHF_GUI.java

private JFreeChart createChart(CategoryDataset dataset, String title) {

    /* JFreeChart chart = ChartFactory.createPieChart3D(title,          // chart title
     dataset,                // data/*from  ww w  .ja  v  a  2 s.  c  om*/
     true,                   // include legend
     true,
     false);*/
    JFreeChart chart = ChartFactory.createBarChart3D(title, "Zeit", "Anzahl an Personen", dataset);

    return chart;

}

From source file:id.aas.apps.mvc.view.frameChart.java

public void setChartBar() throws SQLException {
    double Lunas = 0;
    double Casbon = 0;

    String queryLunas = "SELECT SUM(total_tagihan) from transaksi where keterangan='Lunas'";
    String queryCasbon = "SELECT SUM(total_tagihan) from transaksi where keterangan='Cash Bon'";
    ConnectionDB.InstanceDB.openConnection();
    ResultSet rs = ConnectionDB.InstanceDB.RunSelectQuery(queryLunas);
    while (rs.next()) {
        Lunas = rs.getDouble(1);//from w  w w. ja v  a 2 s  .co m
    }
    System.out.println(Lunas);

    ResultSet rs1 = ConnectionDB.InstanceDB.RunSelectQuery(queryCasbon);
    while (rs1.next()) {
        Casbon = rs1.getDouble(1);
    }
    System.out.println(Casbon);

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(Lunas, "Lunas", "Catatan Uang Pendapatan");
    dataset.setValue(Casbon, "Cash Bon", "Catatan Uang Pendapatan");

    JFreeChart chart = ChartFactory.createBarChart3D("Catatan Uang Pendapatan dan Piutang",
            "Keterangan Pembayaran", "Jumlah Uang", dataset);
    ChartPanel cPanel = new ChartPanel(chart);
    panel1.add(cPanel);
}

From source file:cz.muni.fi.nbs.utils.Helpers.java

private static void exportToPNG(Map<String, Collection<Result>> results) {

    for (Entry<String, Collection<Result>> entry : results.entrySet()) {
        double number = 0;
        String key = entry.getKey();
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        Iterator<Result> resultsIterator = results.get(key).iterator();
        while (resultsIterator.hasNext()) {
            Result r = resultsIterator.next();
            dataset.addValue(r.getScore(), r.getLabel(), "");
            number += 0.8;/*from  w  ww .  j  a  va2 s.com*/
        }
        double width = number > 1 ? number * 200 : 300;
        String unit = entry.getValue().iterator().next().getScoreUnit();
        String[] splitKey = key.split("_");

        JFreeChart chart = ChartFactory.createBarChart3D(splitKey[0], null, unit, dataset);

        int len = splitKey.length / 2;
        for (int i = 0; i < len; i++) {
            String subtitle = splitKey[i * 2 + 1] + ":" + splitKey[i * 2 + 2];
            TextTitle title = new TextTitle(subtitle);
            Font oldFont = title.getFont();
            int fontSize = (int) Math.round(oldFont.getSize() * 1.2);
            int fontStyle = oldFont.getStyle();
            String fontName = oldFont.getName();

            title.setFont(new Font(fontName, fontStyle, fontSize));
            chart.addSubtitle(title);
        }
        try {
            ChartUtilities.saveChartAsPNG(new File(resultsDir + "/charts/" + key + "Chart.png"), chart,
                    (int) Math.round(width), 800);
        } catch (IOException ex) {
            Logger.getLogger(Helpers.class.getName()).log(Level.SEVERE,
                    "Could not export chart to PNG file for " + key, ex);
        }
    }
}

From source file:UserInterface.DonorRole.DonorRecordsJPanel.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    int selectedRow = donorHormoneLevelsJTbl.getSelectedRow();
    if (selectedRow >= 0) {
        double lHLevel = 0.0;
        double FSH = 0.0;
        double hcg = 0.0;
        for (Employee donor : organization.getEmployeeDirectory().getEmployeeList()) {
            if (donor.getName().equalsIgnoreCase(userAccount.getEmployee().getName())) {
                for (HormonalRecords hr : donor.getHormonalRecordsHistory().getHormonalRecordsList()) {
                    //hr = (HormonalRecords)donorHormoneLevelsJTbl.getValueAt(selectedRow,0);

                    lHLevel = hr.getLeutinizingHormoneLevels();
                    FSH = hr.getFollicleStimulatingHormoneLevels();
                    hcg = hr.gethCGLevels();

                }//from  w  w w  . j a va 2  s. c om
                DefaultCategoryDataset data = new DefaultCategoryDataset();
                data.setValue(lHLevel, "Value", "LH level");
                data.setValue(FSH, "Value", "FSH level");
                data.setValue(hcg, "Value", "HCG level");

                JFreeChart chart = ChartFactory.createBarChart3D("Hormonal Level Stats", "Hormonal Parameters",
                        "Values", data);
                chart.setBackgroundPaint(Color.WHITE);
                chart.getTitle().setPaint(Color.BLUE);
                CategoryPlot p = chart.getCategoryPlot();
                p.setRangeGridlinePaint(Color.RED);
                ChartFrame frame = new ChartFrame("Bar Chart for Donor", chart);
                frame.setVisible(true);
                frame.setSize(450, 350);
            }
        }

    }

    else {
        JOptionPane.showMessageDialog(null, "Please select a row from the table", "Warning",
                JOptionPane.WARNING_MESSAGE);
    }

}

From source file:UserInterface.ReciepientRole.RecepientRecordJPanel.java

private void viewStatsJBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewStatsJBtnActionPerformed
    int selectedRow = recHormonalRecordsJTbl.getSelectedRow();
    if (selectedRow >= 0) {
        double lHLevel = 0.0;
        double FSH = 0.0;
        double hcg = 0.0;
        for (Employee donor : organization.getEmployeeDirectory().getEmployeeList()) {
            if (donor.getName().equalsIgnoreCase(userAccount.getEmployee().getName())) {
                for (HormonalRecords hr : donor.getHormonalRecordsHistory().getHormonalRecordsList()) {
                    //hr = (HormonalRecords)donorHormoneLevelsJTbl.getValueAt(selectedRow,0);

                    lHLevel = hr.getLeutinizingHormoneLevels();
                    FSH = hr.getFollicleStimulatingHormoneLevels();
                    hcg = hr.gethCGLevels();

                }//  w w w. jav  a2  s .  c o m
                DefaultCategoryDataset data = new DefaultCategoryDataset();
                data.setValue(lHLevel, "Value", "LH level");
                data.setValue(FSH, "Value", "FSH level");
                data.setValue(hcg, "Value", "HCG level");

                JFreeChart chart = ChartFactory.createBarChart3D("Hormonal Level Stats", "Hormonal Parameters",
                        "Values", data);
                chart.setBackgroundPaint(Color.WHITE);
                chart.getTitle().setPaint(Color.BLUE);
                CategoryPlot p = chart.getCategoryPlot();
                p.setRangeGridlinePaint(Color.RED);
                ChartFrame frame = new ChartFrame("Bar Chart for Donor", chart);
                frame.setVisible(true);
                frame.setSize(450, 350);
            }
        }

    }

    else {
        JOptionPane.showMessageDialog(null, "Please select a row from the table", "Warning",
                JOptionPane.WARNING_MESSAGE);

    }
}

From source file:my.estadistico.Grafica.java

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
    // JFreeChart chart = ChartFactory.createBarChart3D(null, null, null, dataset); //Barras vertical 3d
    //JFreeChart chart = ChartFactory.createLineChart(null, null, null, dataset); //Grafico de linea
    try {//from w ww.  j  a v  a  2s. c  o m
        this.datos();//Obtiene los datos
        JFreeChart chart = ChartFactory.createBarChart3D(null, null, null, dataset); //Barras vertical 3d
        CategoryPlot catPlot = chart.getCategoryPlot();
        catPlot.setRangeGridlinePaint(Color.BLACK);
        this.mostrar(chart);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(rootPane, "FAVOR DE INGRESAR DATOS");

    }
    // TODO add your handling code here:
}