您好我试图将数据绑定到kendochart,但图表上没有出现任何条形图。如果我在Web浏览器中获取URL,则返回以下字符串。
[{"AreaName":"Rondebosch","NumberOfIncidents":2}, {"AreaName":"Claremont","NumberOfIncidents":2}, {"AreaName":"Athlone","NumberOfIncidents":2}]
代码如下
var Reports = {};
$.ajax({
url: "Home/getIncidentPerArea",
async: false,
dataType: 'json',
success: function (json) {
Reports = json;
$("#Chart").kendoChart({ title: { text: "Incidents Per Area" },
DataSource: {
data: Reports
},
series: [{ name: "Incidents Per Area", field:"NumberOfIncidents"}]
});
}
});
请帮忙......
答案 0 :(得分:2)
dataSource选项拼写为Camel case。
此外,data source可以直接请求数据:
dataSource: {
transport: {
read: "Home/getIncidentPerArea"
}
}