Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Products pie chart--using arrays
- //product_values is an array containing y-axis values
- //product_labelz is an array ontaining x-axis values or labels
- //product_label_to_truncate is a string variable containing totals and name of product
- //product_totals is an array containing product totals only
- //product_names is an array containing product names only
- if (product_values.size() < 10) {
- String productName = sale_obj.getString("name");
- index = product_names.indexOf(productName);
- product_label_to_truncate = String.valueOf(priceFormat.format(total)) + " " + productName;
- if (index < 0) {
- // product doesnt exist in product_labelz
- product_names.add(productName);
- product_labelz.add(product_label_to_truncate);
- product_values.add(new Entry((float) total, product_labelz.size() - 1));
- } else {
- // read the current total
- double current_total = groupedProducts.getDouble(productName);
- // increment by the total
- total = current_total + total;
- product_values.set(index, new Entry((float) total, index));
- product_label_to_truncate = String.valueOf(priceFormat.format(total)) + " " + productName;
- product_labelz.set(index, product_label_to_truncate);
- }
- product_totals.add(sale_obj.getString(variant));
- groupedProducts.put(productName, total);
- Log.d("array_report_products", groupedProducts.toString());
- }
Add Comment
Please, Sign In to add comment