Came19xx
Came19xx

Reputation: 72

kendo ui stacked bar chart datasource grouped not in order

I've created a Stacked bar chart with Kendo ui, here: http://jsfiddle.net/Came19xx/t06zq2nr/4/

my problem is that chart put values not in order. In my Datasource, i have an "open" and a "suspended" value, like that:

var data2 = [{"name":"abc","num":1,"state":"open"},
{"name":"abc","num":1,"state":"suspended"},
{"name":"def","num":2,"state":"open"},
{"name":"def","num":5,"state":"suspended"},
{"name":"ghi","num":3,"state":"open"},
{"name":"ghi","num":21,"state":"suspended"},
{"name":"jkl","num":4,"state":"open"},
{"name":"jkl","num":9,"state":"suspended"},
{"name":"mno","num":5,"state":"open"},
{"name":"mno","num":5,"state":"suspended"},
{"name":"pqr","num":6,"state":"open"},
{"name":"pqr","num":14,"state":"suspended"},
{"name":"stu","num":7,"state":"open"},
{"name":"stu","num":6,"state":"suspended"},
{"name":"vwxyz","num":8,"state":"open"},
{"name":"vwxyz","num":5,"state":"suspended"}];

So i grouped by state the datasource, but i don't get the open value corresponding to the name on the barchart and i can't sort it by name cause it will stop working.

For example, i want that abc is in the first line, with 1 in the left side (orange) of the stacked bar and 2 on the right side (red), instead i got vwxyz with the correct suspended value (5) and the wrong open value (3 instead of 8)

the "name" field and the "num" field may can change their value.

Upvotes: 2

Views: 479

Answers (1)

ezanker
ezanker

Reputation: 24738

Try adding name as a sort field on the datasource:

dataSource: {
    data: data2,
    group: [{
        field: "state",
        dir: "desc"
    }],
    sort: {
        field: "name",
        dir: "asc"
    }
}

Updated FIDDLE

Upvotes: 2

Related Questions