我正在尝试按照此处的指南显示一个简单的图表:http: //jtblin.github.io/angular-chart.js/
我正在使用sails.js、angular、bootstrap 和angular-chart.js
当我加载应用程序时,我得到一个空白图像,图表应该在哪里。我在 chrome 开发工具中看到了这个错误:
TypeError: (intermediate value)[type] is not a function
at createChart (angular-chart.js:175)
at Object.fn (angular-chart.js:118)
at Scope.$get.Scope.$digest (angular.js:14308)
at Scope.$get.Scope.$apply (angular.js:14571)
at bootstrapApply (angular.js:1455)
at Object.invoke (angular.js:4203)
at doBootstrap (angular.js:1453)
at bootstrap (angular.js:1473)
at angularInit (angular.js:1367)
at angular.js:26304
请原谅我,但我不知道为什么会出现这个错误。
我已经尝试了下面代码的无数变体,并且觉得这个版本是我得到的最接近工作示例的版本。
看法:
<head>
<link rel="stylesheet" href="/styles/angular-chart.css">
</head>
<body ng-app="DashboardModule" ng-controller="BarCtrl">
<canvas id="bar" class="chart chart-bar" data="data" labels="labels"></canvas>
<script src="/js/dependencies/sails.io.js"></script>
<script src="/js/dependencies/angular.js"></script>
<script src="/js/dependencies/Chart.Core.js"></script>
<script src="/js/dependencies/angular-chart.js"></script>
<script src="/js/private/dashboard/DashboardModule.js"></script>
<script src="/js/private/dashboard/DashboardController.js"></script>
</body>
模块:
angular.module('DashboardModule', ['chart.js']);
控制器:
angular.module('DashboardModule').controller("BarCtrl", 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]
];
});