[英]Error in implementing chart.js in AngularJS
I followed steps given in the link Angular chart JS But unable to draw a graph(Bar graph) from the data. 我按照链接Angular chart JS中给出的步骤进行操作,但是无法从数据中绘制图形(条形图)。
My dashboard.html is 我的dashboard.html是
<div class="md-padding" flex layout-sm="column" >
<md-card class="text-center">
<md-card-content>
<canvas id="bar" class="chart chart-bar" ng-controller="DashboardCtrl"chart-data="data" chart-labels="labels" chart-series="series">
</canvas>
</md-card-content>
</md-card>
</div>
My dashboardctrl.js is 我的dashboardctrl.js是
(function () {
'use strict';
angular.module("home", ["chart.js"])
.config(['ChartJsProvider', function (ChartJsProvider) {
ChartJsProvider.setOptions({
chartColors: ['#FF5252', '#FF8A80'],
responsive: false
});
// Configure all line charts
ChartJsProvider.setOptions('line', {
datasetFill: false
});
}])
.controller("DashboardCtrl", ['$scope', function ($scope) {
$scope.labels = ['2006', '2007', '2008', '2009', '2010', '2011', '2012'];
$scope.series = ['Series A', 'Series B'];
$scope.data = [
[65, 59, 80, 81, 56, 55, 40],
[28, 48, 40, 19, 86, 27, 90]
];
console.log("done");
}]);
})();
I am getting error 我遇到错误
Multiple directives [ngController, chartBar] asking for new/isolated scope on:`
多个指令[ngController,chartBar]在以下位置请求新的/隔离的作用域:
Thanks for your help in advance. 感谢您的帮助。 `
`
<div class="md-padding" flex layout-sm="column" ng-controller="DashboardCtrl">
<md-card class="text-center">
<md-card-content>
<canvas id="bar" class="chart chart-bar" chart-data="data" chart-labels="labels" chart-series="series"></canvas>
</md-card-content>
</md-card>
</div>
You need to move ng-controller
to another element. 您需要将
ng-controller
移动到另一个元素。 Both the controller and the chartBar directive try to register a new isolated scope as the error message says 控制器和chartBar指令都尝试注册新的隔离范围,因为错误消息显示
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.