stevekamau

Untitled

Jan 8th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.95 KB | None | 0 0
  1.  //Products pie chart--using arrays
  2.  
  3.                     //product_values is an array containing y-axis values
  4.                     //product_labelz is an array ontaining x-axis values or labels
  5.                     //product_label_to_truncate is a string variable containing totals and name of product
  6.                     //product_totals is an array containing product totals only
  7.                     //product_names is an array containing product names only
  8.                     if (product_values.size() < 10) {
  9.                         String productName = sale_obj.getString("name");
  10.                         index = product_names.indexOf(productName);
  11.                         product_label_to_truncate = String.valueOf(priceFormat.format(total)) + " " + productName;
  12.  
  13.                         if (index < 0) {
  14.                             // product doesnt exist in product_labelz
  15.                             product_names.add(productName);
  16.                             product_labelz.add(product_label_to_truncate);
  17.                             product_values.add(new Entry((float) total, product_labelz.size() - 1));
  18.                         } else {
  19.                             // read the current total
  20.                             double current_total = groupedProducts.getDouble(productName);
  21.                             // increment by the total
  22.                             total = current_total + total;
  23.                             product_values.set(index, new Entry((float) total, index));
  24.                             product_label_to_truncate = String.valueOf(priceFormat.format(total)) + " " + productName;
  25.                             product_labelz.set(index, product_label_to_truncate);
  26.                         }
  27.                         product_totals.add(sale_obj.getString(variant));
  28.                         groupedProducts.put(productName, total);
  29.                         Log.d("array_report_products", groupedProducts.toString());
  30.                     }
Add Comment
Please, Sign In to add comment