salesagility / SuiteCRM

SuiteCRM - Open source CRM for the world
https://www.suitecrm.com
GNU Affero General Public License v3.0
4.41k stars 2.06k forks source link

AOR: Grouped Bar Chart Doesn't Group Total Amount #5572

Open pstevens71 opened 6 years ago

pstevens71 commented 6 years ago

Issue

When creating a grouped report. For example, Opportunities by sales stage. If you list all the opportunities and then group them by sales stage, and sum the sales stage, the report works fine. However, when you try to graph it, by selecting a grouped bar chart, with x axis as the stage and the y axis as the opportunity amount, the graph looks like it's formatted properly but seems to be only pulling one value from each sales stage and not the total of all the opportunity amounts in the group.

image

image

image

image

I've checked the error logs and didn't find anything useful.

Expected Behavior

Each bar should be the sum total of the group.

Actual Behavior

The grouped chart only graphs the value of one record from the group. Kind of randomly, at least I haven't figured out why only one record's value or why that record. It's not adding up the total of the group.

Possible Fix

Steps to Reproduce

  1. Create a report for grouped records with a total value
  2. Create a grouped bar chart for that data
  3. The report works, but the chart does not

Context

This pretty much makes it impossible to graph grouped bar charts.

Should be medium priority, this is a key reporting feature.

Your Environment

As an add on.... I also tested it on the Demo version on SuiteCRM site and same problem.

artjomsmorscakovs commented 6 years ago

I don`t know if this will beak anything, but if I change modules/AOR_Charts/AOR_Chart.php file line starting at 681

from this

$_data = array(); foreach($data as $label => $values) { foreach($values as $key => $value) { $_data[$label][$tooltips[$label][$key]] = $value; } } $data = $_data;

to this

$_data = array(); foreach($data as $label => $values) { $totalvalue = 0; foreach($values as $key => $value) { //T2I AM 10.08.18 changed to count totals //$_data[$label][$tooltips[$label][$key]] = $value; $totalvalue += doubleval($value); } $_data[$label][$tooltips[$label][0]] = $totalvalue; } $data = $_data;

Then grouped chart becomes more informative. IMPORTANT: This is NOT tested for all other chart types and can lead to unexpected results!

rdolishny commented 5 years ago

This code update worked for us. Version 7.11.6 Sugar Version 6.5.25 (Build 344)

rdolishny commented 5 years ago

We're working on a fix to get pie charts working, too. We'll post our results.

pstevens71 commented 5 years ago

Nice!