Reputation: 51
Hi I'm trying to bind data to a kendochart, but no bars are appearing on the chart. If I get the url in a web browser, the following string is returned.
[{"AreaName":"Rondebosch","NumberOfIncidents":2}, {"AreaName":"Claremont","NumberOfIncidents":2}, {"AreaName":"Athlone","NumberOfIncidents":2}]
The code is as follows
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"}]
});
}
});
Please help...
Upvotes: 1
Views: 663
Reputation: 106544
The dataSource option is spelled in Camel case.
In addition, the data source can request the data directly:
dataSource: {
transport: {
read: "Home/getIncidentPerArea"
}
}
Upvotes: 2