2

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.

ezanker
  • 24,628
  • 1
  • 20
  • 35
Came19xx
  • 72
  • 7

1 Answers1

2

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

ezanker
  • 24,628
  • 1
  • 20
  • 35
  • Now more difficult... it were asked to me to sort chart by num values... There is a way to sort it only by suspended value and get the corresponding open value on the same "line"? Updated [FIDDLE](http://jsfiddle.net/Came19xx/g6rdnk7q/3/) @ezanker – Came19xx Aug 24 '17 at 07:14
  • This is perfect! Thank you so much! – Came19xx Aug 25 '17 at 08:25