Example usage for org.jfree.data.category DefaultCategoryDataset setValue

List of usage examples for org.jfree.data.category DefaultCategoryDataset setValue

Introduction

In this page you can find the example usage for org.jfree.data.category DefaultCategoryDataset setValue.

Prototype

public void setValue(double value, Comparable rowKey, Comparable columnKey) 

Source Link

Document

Adds or updates a value in the table and sends a DatasetChangeEvent to all registered listeners.

Usage

From source file:simz1.StackedBarChart.java

public void BreadGraph() {
    DefaultCategoryDataset bidata = new DefaultCategoryDataset();
    bidata.setValue(bi1, "sales", d1);
    bidata.setValue(bi2, "sales", d2);
    bidata.setValue(bi3, "sales", d3);
    bidata.setValue(bi4, "sales", d4);
    bidata.setValue(bi5, "sales", d5);
    bidata.setValue(bi6, "sales", d6);
    bidata.setValue(bi7, "sales", d7);

    JFreeChart chart3 = ChartFactory.createLineChart("Sales of Bread Items last week", "Date", "sales", bidata,
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot c3 = chart3.getCategoryPlot();
    c3.setBackgroundPaint(Color.white);
    c3.getRenderer().setSeriesPaint(0, Color.GREEN);
    //c3.setRangeGridlinePaint(Color.green);

    ChartPanel c3Panel = new ChartPanel(chart3);
    mhp.chartPanel.removeAll();//from   w  ww.  j ava 2s  .  c o  m
    mhp.chartPanel.add(c3Panel);
}

From source file:simz1.StackedBarChart.java

public void DrinksGraph() {
    DefaultCategoryDataset drdata = new DefaultCategoryDataset();
    drdata.setValue(dr1, "sales", d1);
    drdata.setValue(dr2, "sales", d2);
    drdata.setValue(dr3, "sales", d3);
    drdata.setValue(dr4, "sales", d4);
    drdata.setValue(dr5, "sales", d5);
    drdata.setValue(dr6, "sales", d6);
    drdata.setValue(dr7, "sales", d7);

    JFreeChart chart4 = ChartFactory.createLineChart("Sales of Drinks last week", "Date", "sales", drdata,
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot c4 = chart4.getCategoryPlot();
    c4.setBackgroundPaint(Color.white);
    c4.getRenderer().setSeriesPaint(0, Color.YELLOW);
    //c4.setRangeGridlinePaint(Color.yellow);

    ChartPanel c4Panel = new ChartPanel(chart4);
    mhp.chartPanel.removeAll();//from  w  w  w.j  a  v a  2 s  . com
    mhp.chartPanel.add(c4Panel);
}

From source file:simz1.StackedBarChart.java

public void SweetsGraph() {
    DefaultCategoryDataset sidata = new DefaultCategoryDataset();
    sidata.setValue(si1, "sales", d1);
    sidata.setValue(si2, "sales", d2);
    sidata.setValue(si3, "sales", d3);
    sidata.setValue(si4, "sales", d4);
    sidata.setValue(si5, "sales", d5);
    sidata.setValue(si6, "sales", d6);
    sidata.setValue(si7, "sales", d7);

    JFreeChart chart5 = ChartFactory.createLineChart("Sales of Sweet items last week", "Date", "sales", sidata,
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot c5 = chart5.getCategoryPlot();
    c5.setBackgroundPaint(Color.lightGray);
    c5.getRenderer().setSeriesPaint(0, Color.PINK);
    //c5.setRangeGridlinePaint(Color.pink);

    ChartPanel c5Panel = new ChartPanel(chart5);
    mhp.chartPanel.removeAll();/*from w  ww.  ja  v  a  2s . c o m*/
    mhp.chartPanel.add(c5Panel);
}

From source file:simz1.StackedBarChart.java

public void CakeGraph() {
    DefaultCategoryDataset ckedata = new DefaultCategoryDataset();
    ckedata.setValue(cke1, "sales", d1);
    ckedata.setValue(cke2, "sales", d2);
    ckedata.setValue(cke3, "sales", d3);
    ckedata.setValue(cke4, "sales", d4);
    ckedata.setValue(cke5, "sales", d5);
    ckedata.setValue(cke6, "sales", d6);
    ckedata.setValue(cke7, "sales", d7);

    JFreeChart chart2 = ChartFactory.createLineChart("Sales of Cakes last week", "Date", "sales", ckedata,
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot c2 = chart2.getCategoryPlot();
    c2.setBackgroundPaint(Color.white);
    c2.getRenderer().setSeriesPaint(0, Color.BLUE);
    //c2.setRangeGridlinePaint(Color.BLUE);

    ChartPanel c2Panel = new ChartPanel(chart2);
    mhp.chartPanel.removeAll();/*from  ww w  .j ava 2s  .  c o  m*/
    mhp.chartPanel.add(c2Panel);
}

From source file:com.tecnosur.view.Frm_PermisoChart.java

private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened
    try {/* www. ja v  a  2  s.  c o  m*/
        // TODO add your handling code here:

        Object valor[] = { "", oaula.getIdespecialidad(), oaula.getIdsemestre(), oaula.getIdturno(),
                oaula.getIdseccion(), oaula.getIdperiodo() };
        oc_permiso = new CPermiso();
        oc_permiso.ofiltro.setValor(valor);
        oc_permiso.ListarGraficaEntregados();
        // Creamos y rellenamos el modelo de datos
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        if (oc_permiso.size() > 0) {
            for (int x = 0; x < oc_permiso.size(); x++) {
                dataset.setValue(oc_permiso.get(x).getCuenta(), oc_permiso.get(x).getEstado(),
                        oc_permiso.get(x).getMes());
            }
        }

        oc_permiso.ListarGraficaNoEntregados();
        if (oc_permiso.size() > 0) {
            for (int x = 0; x < oc_permiso.size(); x++) {
                dataset.setValue(oc_permiso.get(x).getCuenta(), oc_permiso.get(x).getEstado(),
                        oc_permiso.get(x).getMes());
            }
        }
        // Visitas del sitio web 2            
        JFreeChart chart = ChartFactory.createBarChart("Permisos del Aula: Computacin I-A-M", "MES",
                "ALUMNOS", dataset, PlotOrientation.VERTICAL, true, true, false);
        ChartPanel panel = new ChartPanel(chart);
        jPanel2.add(panel);

    } catch (SQLException ex) {
        Logger.getLogger(Frm_PermisoChart.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:userinterface.AdministratorWorkArea.TopMedicineJPanel.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:
    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
    int i = 1;// w  ww .  ja v  a 2s  .  c  om

    for (WorkRequest request : org.getWorkQueue().getWorkRequestList()) {

        dataSet.setValue(((MedicineWorkRequest) request).getQuantityOrdered(), "Number Of Medicines Ordered",
                ((MedicineWorkRequest) request).getMedicineName());

        i++;

    }

    JFreeChart chart = ChartFactory.createBarChart("Popular Medicines in Hospital Graph", "Medicine Name",
            "Quantity", dataSet, PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLACK);
    ChartFrame frame = new ChartFrame("Bar Chart for Patient", chart);
    frame.setVisible(true);
    frame.setSize(800, 550);
}

From source file:userinterface.SystemAdminWorkArea.DisplayAllergyJPanel.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    // TODO add your handling code here:
    int selectedRow = allergyTable.getSelectedRow();

    if (selectedRow < 0) {
        JOptionPane.showMessageDialog(null, "Please select a Row!");
        return;/*  w  w w . ja v  a  2 s. c om*/
    }
    Enterprise ent = (Enterprise) allergyTable.getValueAt(selectedRow, 0);

    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
    int i = 1;

    for (Allergy a : ent.getAllergyList().getAllergyList()) {

        dataSet.setValue(a.getCount(), "Allergies", a.getAllergyName());

        i++;

    }

    JFreeChart chart = ChartFactory.createBarChart("Allergies Affecting A State", "Allergy Name", "Count",
            dataSet, PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLACK);
    ChartFrame frame = new ChartFrame("Allergies In A State", chart);
    frame.setVisible(true);
    frame.setSize(800, 550);

}

From source file:UserInterface.StoreManager.StoreReportsPanel.java

private void storeKeeperButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_storeKeeperButtonActionPerformed
    // TODO add your handling code here:
    ArrayList<Comparison> cmp1 = new ArrayList<>();
    int x = 0;//from   ww w.  ja  v a 2  s  .  com
    for (Organization org : enterprise.getOrganizationDirectory().getOrganizationList()) {
        if (org instanceof StoreKeeperOrganization) {
            System.out.println("Hi");
            for (UserAccount ua : org.getUserAccountDirectory().getUserAccountList()) {
                x = 0;
                for (WorkRequest w : ua.getWorkQueue().getWorkRequestList()) {
                    x++;
                }
                Comparison c = new Comparison(ua.getEmployee().getName(), x);
                cmp1.add(c);
            }

        }

    }

    Collections.sort(cmp1);

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    if (cmp1.size() >= 3) {
        dataset.setValue(cmp1.get(0).getNumber(), "WorkRequests", cmp1.get(0).getString());
        dataset.setValue(cmp1.get(1).getNumber(), "WorkRequests", cmp1.get(1).getString());
        dataset.setValue(cmp1.get(2).getNumber(), "WorkRequests", cmp1.get(2).getString());
    } else {
        for (Comparison c : cmp1) {
            dataset.setValue(c.getNumber(), "WorkRequests", c.getString());
        }
    }
    JFreeChart chart = ChartFactory.createBarChart("Top StoreKeepers", "Storekeepers",
            "No of Workrequests Solved", dataset, PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLUE);
    ChartFrame frame = new ChartFrame("StoreKeeper Report", chart);
    frame.setVisible(true);
    frame.setSize(600, 400);

}

From source file:Interfaces.EstadisticaGui.java

private void dibujarGraficos() {
    this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    abrirBase();/*from  ww  w . j  a va2s . c om*/
    panelGrande.removeAll();
    Integer anio = (Integer) spinnerAnio.getValue();
    // Creamos y rellenamos el modelo de datos
    LazyList<Categoria> categorias = Categoria.findAll();
    Iterator<Categoria> it = categorias.iterator();
    while (it.hasNext()) {
        Categoria c = it.next();
        if (!c.getString("nombre").equals("COMPRAS")) {
            DefaultCategoryDataset dataset = new DefaultCategoryDataset();
            float[] ingreso = calcularIngreso(c.getInteger("id"), anio);
            dataset.setValue(ingreso[0], c.getString("nombre"), "Enero");
            dataset.setValue(ingreso[1], c.getString("nombre"), "Febrero");
            dataset.setValue(ingreso[2], c.getString("nombre"), "Marzo");
            dataset.setValue(ingreso[3], c.getString("nombre"), "Abril");
            dataset.setValue(ingreso[4], c.getString("nombre"), "Mayo");
            dataset.setValue(ingreso[5], c.getString("nombre"), "Junio");
            dataset.setValue(ingreso[6], c.getString("nombre"), "Julio");
            dataset.setValue(ingreso[7], c.getString("nombre"), "Agosto");
            dataset.setValue(ingreso[8], c.getString("nombre"), "Septiembre");
            dataset.setValue(ingreso[9], c.getString("nombre"), "Octubre");
            dataset.setValue(ingreso[10], c.getString("nombre"), "Noviembre");
            dataset.setValue(ingreso[11], c.getString("nombre"), "Diciembre");
            JFreeChart chart = ChartFactory.createBarChart3D(
                    "Ingresos en la categoria " + c.getString("nombre"), "mes", "Pesos", dataset,
                    PlotOrientation.VERTICAL, true, true, false);
            // Creacin del panel con el grfico
            ChartPanel panelGrafico = new ChartPanel(chart);
            CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
            org.jfree.chart.axis.CategoryAxis categoryaxis = categoryplot.getDomainAxis();
            categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(0.2D));
            CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer();
            categoryitemrenderer.setBaseItemLabelsVisible(true);
            JPanel panelParaGrafico = new JPanel();
            panelParaGrafico.setLayout(new BorderLayout());
            panelGrande.add(panelParaGrafico);
            panelParaGrafico.add(panelGrafico);
        }
    }
    this.pack();
    this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

}

From source file:userinterface.SystemAdminWorkArea.DisplayOperationJPanel.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    // TODO add your handling code here:
    int selectedRow = treatmentTable.getSelectedRow();

    if (selectedRow < 0) {
        JOptionPane.showMessageDialog(null, "Please select a Row!");
        return;/* w ww .ja  v  a  2 s  .c o  m*/
    }
    Enterprise ent = (Enterprise) treatmentTable.getValueAt(selectedRow, 0);

    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
    int i = 1;

    for (TreatedFor t : ent.getTreatmentCatalog().getTreatmentList()) {

        dataSet.setValue(t.getCount(), "Treatments", t.getTreatment());

        i++;

    }

    JFreeChart chart = ChartFactory.createBarChart("Treatment Count In A State", "Treatment Name", "Count",
            dataSet, PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLACK);
    ChartFrame frame = new ChartFrame("Patients Treated For", chart);
    frame.setVisible(true);
    frame.setSize(800, 550);

}