Reputation: 111
For some reason this chart won't draw when i try to do it with AngularJS. It seems to work fine if i do it without AngularJS so the problem seems to be related to it. I don't get any error in console so i need some help.
HTML:
<div ng-controller="MyCtrl">
<graph ng-repeat="graph in graphs" data="graph.data"></graph>
</div>
JS:
var myApp = angular.module('myApp',[]);
myApp.controller('MyCtrl', function($scope) {
$scope.graphs = [
{
data: [1, 2, 3, 4, 5, 6, 7,8,9],
}
];
});
myApp.directive('graph', function() {
return {
restrict: 'E',
scope: {
data: '='
},
template: "<canvas></canvas>",
link: function(scope, elem, attrs) {
console.log(scope);
var ctx = elem.children()[0].getContext("2d");
var lineChartData = {
datasets: [{
data: scope.data,
}]
};
var graph = new Chart(ctx, {
type: "bubble",
data: lineChartData,
});
}
};
});
Upvotes: 1
Views: 866