如何使用带有本地数据绑定的AngularJS图表实现KendoUI?
我的本地数据:
var blogComments = [ {
"blog": "My blog",
"day": "1",
"value": 3,
"userColor": "#ffd600"
}, {
"blog": "My blog",
"day": "2",
"value": 7,
"userColor": "#ffd600"
}, {
"blog": "My blog",
"day": "11",
"value": 14,
"userColor": "#ffd600"
}, {
"blog": "My blog",
"day": "12",
"value": 15,
"userColor": "#ffd600"
}, {
"blog": "My blog",
"day": "30",
"value": 6,
"userColor": "#ffd600"
} ];
我想将其用作我的数据源:
$scope.theBlog = new kendo.data.DataSource({
dataSource: {
data: blogComments
}
});
这是我的HTML:
<div kendo-chart
k-legend="{ position: 'bottom' }"
k-series-defaults="{ type: 'bar', labels: {
visible: true,
background: 'transparent' } }"
k-data-source="theBlog"
k-series-hover="onSeriesHover"
k-series="[{name:'Value', field:'value'}]">
</div>
好像它没有从数据源中获取k系列。该图表为空,并且根本不显示任何数据。与AngularJS有关的KendoUI上的所有示例都具有JSON远程数据。请帮忙。我错过了什么?
答案 0 :(得分:2)
您没有正确创建DS - 您的嵌套级别太多了:
$scope.theBlog = new kendo.data.DataSource({
data: blogComments
});