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

Stacked Column Chart problem

1 Answer 26 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Baldvin
Top achievements
Rank 1
Baldvin asked on 13 Oct 2015, 05:05 PM

Hi,

 I'm having a problem with stacked column chart. Here is a working fiddle http://jsfiddle.net/jokullie/pvtvLfvy/ that demonstrates the problem.

What I want to do is, I want all objects with the same CHARTGROUP value to be stacked on top of each other and then all the different years should be grouped together on each month.

 So, I want the first two records stacked on top of each other at month:1 or "jan", then I want records 9 and 10 to be stacked on top of each other also at month:1 or "jan".

 The same should happen for all other months. I hope this makes sense, if not, please ask for clarification.

 Thank you,
B.

 

1 Answer, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 16 Oct 2015, 06:56 AM
Hi,

Please accept my apologies for the delayed response. I've got little trouble getting this to work, but things went smoothly once I've upgraded to a more recent version of Kendo UI.

First, you need to make each data point into its own series. This will allow us to associate it to the needed category and stack.
We can do this by assigning an unique ID and grouping by it.
    dataSource: {
        data: data,
        group: {
            field: "UID",
            dir: "asc"
        }
    }
 
Categories can be mapped out through the categoryField binding. In this case we want to display monthly data so we'll bind it to "THEMONTH".
    field: "KRLAMOUNTTOTAL",
    categoryField: "THEMONTH"

What's left is to associate the series with the respective stack. There is no binding for this, but we can do it in the dataBound event:
Notice that the stack name must be a string.
    dataBound: function(e) {
        var series = e.sender.options.series;
        for (var i = 0; i < series.length; i++) {
            series[i].stack = series[i].data[0].THEYEAR.toString();
        }
    }

This is the updated snippet. I hope this helps.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Charts
Asked by
Baldvin
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Share this question
or