问题
I have an MVC app and my controller is passing the following json data to my view
data:
{
"Category":"Q1 2013",
"Name":"Female",
"Count":5000
},
{
"Category":"Q1 2013",
"Name":"Male",
"Count":5000
}
{
"Category":"Q1 2012",
"Name":"Female",
"Count":3500
},
{
"Category":"Q1 2012",
"Name":"Male",
"Count":5000
}
I need to know how to configure my Kendo stacked bar chart to display the data like this http://jsfiddle.net/ihatemash/B6LSX/
I can't figure out how to configure the series and category to show the stacked bar chart correctly.
回答1:
here is working example http://jsfiddle.net/idhasitha/F2TQ8/
try with like this
var data = [
{"Name":1,"Year":2011,"Expense":200.00},
{"Name":1,"Year":2012,"Expense":274.91},
{"Name":5,"Year":2011,"Expense":100.00},
{"Name":5,"Year":2012,"Expense":315.84},
];
$(document).ready(function() {
$("#chart").kendoChart({
theme: "silver",
title: {
text: "Total records processed"
},
legend: {
position: "bottom"
},
dataSource: {
data: data,
group: {
field: "Name"
}
},
transitions: false,
series: [{
type: "column",
stack: "true",
field: "Expense"
}],
categoryAxis: {
field: "Year"
}
});
});
来源:https://stackoverflow.com/questions/24988632/kendo-stacked-bar-chart-configuration