This is a migrated thread and some comments may be shown as answers.

Grouped data not charted correctly when group values happen to be unique

4 Answers 475 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Fred
Top achievements
Rank 1
Fred asked on 09 Dec 2013, 10:55 PM
Through experimentation, I have found that the data source grouping feature does not seem to work correctly in cases where the group values in the input data happen to be unique.  I have a simple bar chart with a category field 'product_group' and another field 'site' used for grouping within product group.  It works OK with some data sets, but in cases where each data item happens to have a unique site value, only the first category encountered in the data is being displayed in the category label.

While grouping is meaningless when performed on a unique field, for those special cases where it might happen, the chart should still display correctly.

I have recreated the problem in a jsfiddle showing two data sets, one that displays incorrectly and the other correctly: http://jsfiddle.net/W29KF/

Also, I am new to KendoUI, so please let me know if I am doing something wrong.

4 Answers, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 11 Dec 2013, 07:50 PM
Hello Fred,

I checked the example and the groups are rendered correctly - keep in mind the groups are actually the series in a grouped Kendo UI Chart (online demo). In order to assist you best and provide concrete recommendations I would like to ask you to provide more detailed information about the expected outcome? 

Regards,
Iliana Nikolova
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Fred
Top achievements
Rank 1
answered on 11 Dec 2013, 10:32 PM
Hi Iliana,

Thanks for the reply.  I checked the on-line example which works exactly as I would expect, but it still seems to me that my sample does not.

My understanding of the datasource.group.field property is that it references a field within the series that will be used to group the charted data within each category.  The categoryAxis.field property references the field defining the category, which is an implied top-level grouping.  In effect, when groups are used, the displayed bars are grouped by <group field> within <category field>.  Each member of the series contains both a <group field> value and a <category field> value, used by DataViz at runtime to make the decision.

All members of my sample series include both a product_group (category) and site (group) field value.  However, my first chart shows all the groups under a single category ''Automotive Mfg".   The data making up each of the 16 bars actually fall into one of two categories, either "Automotive Mfg" or "Food &amp; Bev Mfg site".
Why does the first chart not show both of the categories, in the way they are shown in the second chart?

To be specific, consider the fifth entry in the first series:

{"site": "30-200", "product_group": "Food &amp; Bev Mfg site", "inventory_turns": 20.243573}

 I would have expected this to display inside a category "Food &amp; Bev Mfg site" in the first chart, but instead it displays in the category "Automotive Mfg".  In fact, the category "Food &amp; Bev Mfg site" is not shown at all.

What am I missing here?


0
Iliana Dyankova
Telerik team
answered on 13 Dec 2013, 03:00 PM
Hi again Fred,

The observed behaviour is expected and is due to the following:
  • By design on the categoryAxis of a grouped Kendo UI Chart are displayed the categories for the first group (in the particular example for my-chart-1 this is "Automotive Mfg");
  • Categorical charts (line, bar, column, etc.) require a matching set of data points (note the value can be null but the record needs to be presented in the data). I.e. if you wish to have "Automotive Mfg" and "Food &amp; Bev Mfg site" fields on the categoryAxis you should have data for each "site" field for both "Automotive Mfg" and "Food &amp; Bev Mfg site" "product_group". This is due to the fact that series.data is an array. For your convenience I updated the jsFiddle example (with null values). Another option is to use the series.categoryField option instead of categoryAxis.field (updated example).

Regards,
Iliana Nikolova
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Accepted
Fred
Top achievements
Rank 1
answered on 13 Dec 2013, 04:23 PM
Hi Iliana,

Thanks for the clarification.  To summarize (mainly for myself): As the group feature partitions the data by group and category, there must be a single record present for each combination of group and category.  This also affects the display, because DataViz will assume that the category values it finds for the first group is a comprehensive set, and will place only those categories on the chart at all.

I suggest that you add these points to the on-line documentation, which is very sketchy at the moment.

Thanks again,
Fred
Tags
Charts
Asked by
Fred
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Fred
Top achievements
Rank 1
Share this question
or