1

嗨,我正在尝试将数据绑定到 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"}]
        });
    }
});

请帮忙...

4

1 回答 1

2

dataSource 选项以 Camel 大小写拼写。

另外,数据源可以直接请求数据:

dataSource: {
    transport: {
        read: "Home/getIncidentPerArea"
    }
}
于 2012-06-14T07:37:07.720 回答