I am using k-data-source on a pie chart using Kendo DataViz and the Angular directives. When I change the datasource object on the $scope, it doesn't update and throws errors. Were the angular directives intended to be used this way?
Here's a JSBin showing the problem: http://jsbin.com/OSudIzEH/9/edit
Angular Code
var app = angular.module('chart-example', ['kendo.directives']);
function ChartController($scope) {
$scope.pie = {
title: {
position: "bottom",
text: "Share of Internet Population Growth, 2007 - 2012"
},
legend: {
visible: false
},
chartArea: {
background: ""
},
seriesDefaults: {
labels: {
visible: true,
background: "transparent",
template: "#= category #: #= value#%"
}
},
series: [{
type: "pie",
field: "value",
categoryField: "category"
}],
tooltip: {
visible: true,
format: "{0}%"
}
};
$scope.updatePie = function() {
$scope.countries = {
data: [
{
category: "Asia2",
value: 53.8,
color: "#9de219"
}, {
category: "Europe2",
value: 16.1,
color: "#90cc38"
}, {
category: "Latin America2",
value: 11.3,
color: "#068c35"
}, {
category: "Africa2",
value: 9.6,
color: "#006634"
}, {
category: "Middle East2",
value: 5.2,
color: "#004d38"
}, {
category: "North America2",
value: 3.6,
color: "#033939"
}
]
};
};
$scope.countries = {
data: [
{
category: "Asia",
value: 53.8,
color: "#9de219"
}, {
category: "Europe",
value: 16.1,
color: "#90cc38"
}, {
category: "Latin America",
value: 11.3,
color: "#068c35"
}, {
category: "Africa",
value: 9.6,
color: "#006634"
}, {
category: "Middle East",
value: 5.2,
color: "#004d38"
}, {
category: "North America",
value: 3.6,
color: "#033939"
}
]
};
}
HTML
<div ng-controller="ChartController">
<button ng-click="updatePie()">update</button>
<div kendo-chart k-options="pie" k-data-source="countries" />
</div>
You need to create a kendo datasource and then update the data object for it to work. JSBin has been updated with working code.
That looks like a bug in angular-kendo to me. One problem is that the params for
toDataSource
are in the wrong order. However, even after fixing that, the widget is not updated with the new datasource. I made a few changes to the kendo-angular script to make this work (however I have no idea whether this fits in with the rest of its features):demo here