1

我已经安装了所有依赖项,并且我的代码似乎是正确的,但仍然无法指出为什么代码根本没有呈现。

提前致谢。

<!DOCTYPE html> 
<html>
<head>
<link rel="stylesheet" href="bower_components/angular-chart.js/dist/angular-chart.css"> 
<script src="bower_components/angular-chart.js/dist/angular-chart.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
</head> 
<body>
<div ng-app="app" ng-controller="PolarAreaCtrl">
<canvas id="polar-area" class="chart chart-polar-area"
  chart-data="data" chart-labels="labels">
</canvas>
</div> 
<script>
angular.module("app", ["chart.js"]).controller("PolarAreaCtrl", function ($scope) {
  $scope.labels = ["Download Sales", "In-Store Sales", "Mail-Order Sales", "Tele Sales", "Corporate Sales"];
  $scope.data = [300, 500, 100, 40, 120];
});
</script>
</body>
</html>  
4

1 回答 1

0

According to here - angular-chart.js doesn't support version 2 of Chart.js. Below is a snippet, that shows a working chart. It includes v1.1.1 of chart.js

I used the following and its working:

<!DOCTYPE html>
<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.1.1/Chart.min.js"></script>
    <script src="http://jtblin.github.io/angular-chart.js/dist/angular-chart.js"></script>
    <link rel="stylesheet" href="https://raw.githubusercontent.com/jtblin/angular-chart.js/master/dist/angular-chart.min.css" />
</head>
<body>
<div ng-app="app" ng-controller="PolarAreaCtrl">
    <canvas id="polar-area" class="chart chart-polar-area"
            chart-data="data" chart-labels="labels">
    </canvas>
</div>
<script>
    angular.module("app", ["chart.js"]).controller("PolarAreaCtrl", function ($scope) {
        $scope.labels = ["Download Sales", "In-Store Sales", "Mail-Order Sales", "Tele Sales", "Corporate Sales"];
        $scope.data = [300, 500, 100, 40, 120];
    });
</script>
</body>
</html>
于 2016-05-31T23:37:55.557 回答