private void btnPictorialViewActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnPictorialViewActionPerformed
    // TODO add your handling code here:
    DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset();

    for (Product product : supplier.getProductCatalog().getProductCatalog()) {
      categoryDataset.setValue(product.getSoldQuantity(), "Units", product.getProdName());
    }
    JFreeChart freeChart =
        ChartFactory.createBarChart(
            "Sales Report",
            "Product",
            "Units",
            categoryDataset,
            PlotOrientation.VERTICAL,
            false,
            true,
            false);

    CategoryPlot categoryPlot = freeChart.getCategoryPlot();
    categoryPlot.setRangeGridlinePaint(Color.BLACK);
    ChartFrame cf = new ChartFrame("Sales Report", freeChart);
    cf.setVisible(true);
    cf.setSize(450, 300);
  } // GEN-LAST:event_btnPictorialViewActionPerformed
  private void populateProducts() {

    //        Collections.sort(supplier.getProductCatalog().getProductCatalog(), new
    // Comparator<Product>(){
    //
    //            public int compare(Product o1, Product o2) {
    //                if(o1.getSoldQuantity() < o2.getSoldQuantity())
    //                    return 1;
    //                else if(o1.getSoldQuantity() > o2.getSoldQuantity())
    //                    return -1;
    //                return 0;
    //            }
    //        });
    DefaultTableModel dtm = (DefaultTableModel) salestbl.getModel();
    dtm.setRowCount(0);
    for (Product p : supplier.getProductCatalog().getProductCatalog()) {
      Object row[] = new Object[4];
      row[0] = p;
      row[1] = p.getSoldQuantity();
      row[2] = p.getPrice();
      row[3] = (p.getSoldQuantity() * p.getPrice());
      dtm.addRow(row);
    }
  }
 /** Creates new form ReviewProductPerformance */
 public ProductReportJPanel(JPanel userProcessContainer, Supplier supplier) {
   initComponents();
   this.userProcessContainer = userProcessContainer;
   this.supplier = supplier;
   supplierName.setText(supplier.getName() + "-- Sales Performance");
   try {
     Product product = supplier.getProductsSorted(supplier);
     productName.setText(product.getProdName());
     quanitytxt.setText(String.valueOf(product.getSoldQuantity()));
     populateProducts();
   } catch (IndexOutOfBoundsException ai) {
     errorMsg.setText("Sales Report Not Generated...!!!");
     JOptionPane.showMessageDialog(
         null, "The Sales Report will only be generated after the customer's checkout");
   }
 }