The problem

When grouping the results (i.e., in Charts lingo, having more than one series) and some series don't have all the data points, the output will be wrong, since values per series will just be added sequentially from the "right", through the following line (which doesn't take the "label key" into account at all):

            $chart[$series_key]['#data'][] = $value;

An example

You want to show a column chart of the GPD of two countries, A and B, for the years 2012–2014, but country B hasn't reported a value for the year 2013:

Country | Year | GPD
---------------------
A       | 2012 |  8 T$
A       | 2013 |  9 T$
A       | 2014 | 10 T$
B       | 2012 |  3 T$
B       | 2014 |  5 T$

This will lead to the following output:

As you can see, the value for B/2014 ends up as the 2013 value instead.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey created an issue. See original summary.

drunken monkey’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
2.55 KB

The attached patch fixes the problem for me, and will also correct the group labels if the first series doesn't have all values.
Please tell me what you think!

drunken monkey’s picture

Empty values should default to NULL, not '', otherwise Highcharts will produce weird results (line diagrams with unconnected points, for example).

herd45’s picture

I've tested and this works as expected

davidkp’s picture

Thanks for posting this patch but alas it did not work for me with the latest dev version released a couple of days ago.

After applying the patch I get the following error 'Data column(s) for axis #0 cannot be of type string'.

Please see the attached before and after images of my column chart including a table with the data.

Elin Yordanov’s picture

Priority: Normal » Major
FileSize
2.76 KB

Thank you drunken monkey, re-rolled the patch to the current dev version. It works for me. Please review.

I also go ahead and put the priority of this issue to major.

Elin Yordanov’s picture

FileSize
2.71 KB

The previous patch has broken the sorting. Removing the line with ksort() fixes this too. Please review the attached patch.

joseph.olstad’s picture

Related issues: +#3078113: Fix grouped labels

This issue has a duplicate issue:
#3078113: Fix grouped labels

I am not sure which solution is better, 3078113 or this one

In either case, it would be nice to have one of the two solutions committed and released.

Thanks!