我是角度 js 的新手。当我尝试执行以下代码时。它在控制台中显示一些错误。ReferenceError:图表未定义。我无法理解错误。所以任何人请帮助我。如果问题不正确,请更正问题
我的 HTML 代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>school</title>
<link rel="stylesheet" href="style.css" type="text/css"/>
<link rel="stylesheet" href="fonts/text-font/css/font_icon.css" type="text/css"/>
<meta name="viewport" content="width=device-width; initial-scale=1.0" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<!-- angular -->
<script type="text/javascript" src="js/angular/angular.min.js"></script>
<!-- angular chart -->
<link rel="stylesheet" href="js/angular/angular-chart.css" type="text/css"/>
<script type="text/javascript" src="js/angular/angular-chart.min.js"></script><br />
<script type="text/javascript" src="js/angular/angular.js"></script>
<script type="text/javascript" src="js/script.js"></script>
</head>
<body ng-app="app">
<div ng-controller="LineCtrl">
<canvas id="line" class="chart chart-line" chart-data="data" chart-labels="labels"
chart-legend="true" chart-series="series" chart-click="onClick"></canvas>
</div>
</body >
</html>
我的 angular.js :
angular.module("app", ["chart.js"])
// Optional configuration
.config(['ChartJsProvider', function (ChartJsProvider) {
// Configure all charts
ChartJsProvider.setOptions({
colours: ['#FF5252', '#FF8A80'],
responsive: false
});
// Configure all line charts
ChartJsProvider.setOptions('Line', {
datasetFill: false
});
}])
.controller("LineCtrl", ['$scope', '$timeout', function ($scope, $timeout) {
$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);
};
// Simulate async data update
$timeout(function () {
$scope.data = [
[28, 48, 40, 19, 86, 27, 90],
[65, 59, 80, 81, 56, 55, 40]
];
}, 3000);
}]);