Angular 图表未显示
Angular charts is not displayed
我使用 angular 图表和 chart.js 创建了一个基本图表。但是当我打开 html 文件时,我看不到任何图表表示。当我检查浏览器时,我可以看到 canvas 布局但没有显示图表。我做错了什么,如何改正。
HTML:
<head>
<title>CHART</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
<script src=Chart.js></script>
<script src="angular-chart.js"></script>
<script src="chartExmp.js"></script>
</head>
<body>
<div ng-app="app" ng-controller="PolarAreaCtrl">
<canvas chart-data="data" chart-labels="labels" chart-options="options">
</canvas>
</body>
控制器:
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];
});
您需要在html、
中指定图表类型
<canvas id="bar" class="chart chart-bar" chart-data="data" chart-series="series" chart-labels="labels"></canvas>
我使用 angular 图表和 chart.js 创建了一个基本图表。但是当我打开 html 文件时,我看不到任何图表表示。当我检查浏览器时,我可以看到 canvas 布局但没有显示图表。我做错了什么,如何改正。
HTML:
<head>
<title>CHART</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
<script src=Chart.js></script>
<script src="angular-chart.js"></script>
<script src="chartExmp.js"></script>
</head>
<body>
<div ng-app="app" ng-controller="PolarAreaCtrl">
<canvas chart-data="data" chart-labels="labels" chart-options="options">
</canvas>
</body>
控制器:
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];
});
您需要在html、
中指定图表类型<canvas id="bar" class="chart chart-bar" chart-data="data" chart-series="series" chart-labels="labels"></canvas>