TypeError :(中间值)[type]不是函数错误

时间:2016-05-04 12:59:53

标签: angularjs ionic-framework

我想在我的离子应用程序中使用折线图,但我得到的只是空白屏幕。

我也收到错误:

 TypeError: (intermediate value)[type] is not a function
 at createChart (angular-chart.js:197)
 at Object.fn (angular-chart.js:150)
 at Scope.$digest (ionic.bundle.js:28995)
 at Scope.$apply (ionic.bundle.js:29263)
 at done (ionic.bundle.js:23676)
 at completeRequest (ionic.bundle.js:23848)
 at XMLHttpRequest.requestLoaded (ionic.bundle.js:23789)

app.js:

angular.module('starter', ['ionic', 'starter.controllers', 'chart.js'])

controller.js:

angular.module('starter.controllers',[])
.controller('AspDashController', ['$scope', '$state', function($scope, $state) {
$scope.labels = ["January", "February", "March", "April", "May", "June", "July"];
$scope.series = ['Series A', 'Series B'];
$scope.data = [
  [65, 59, 80, 81, 56, 55, 40],
  [28, 48, 40, 19, 86, 27, 90]
];
$scope.onClick = function (points, evt) {
  console.log(points, evt);
};
}])

HTML:

<div class="card">
    <div class="item item-divider">
        A line chart
    </div>
    <canvas id="line" class="chart chart-line" chart-data="data" chart-labels="labels" chart-legend="true" chart-series="series" chart-click="onClick"></canvas> 
</div>

的index.html:

<link rel="stylesheet" href="css/angular-chart.css">
<link href="css/style.css" rel="stylesheet">
<script src="js/Chart.js"></script>
<script src="js/angular-chart.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>

1 个答案:

答案 0 :(得分:13)

可能您使用的是最新版本的图表,但尚未在ng-charts中支持。尝试使用以前版本的Chart.js在此处查找 - &gt; https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.1.1/Chart.js