我有一個小型web應用程序使用angularjs,我試圖起訴angularJS library兩個圖表。我正在使用酒吧和派。他們渲染得很好,但由於某些原因,他們拒絕調整顯示器變小或變大。Angularjs圖表不調整大小
我的HTML代碼:
<div class="chartWrapper" ng-show="true" layout="row" layout-align="center center" md-whiteframe="3">
<canvas id="pie" class="chart chart-pie" chart-data="pieData" chart-labels="chartLabels" chart-legend="true"></canvas>
<canvas id="bar" class="chart chart-bar" chart-data="chartData" chart-legend="true" chart-labels="chartLabels" chart-series="series"></canvas>
</div>
我對包裝
.chartWrapper{
margin: 0 auto;
text-align: center;
vertical-align: top;
width: 80% !important;
}
我的JavaScript代碼
angular.module('app')
.config(['ChartJsProvider', function (ChartJsProvider) {
// Configure all charts
ChartJsProvider.setOptions({
colours: ['#FF0000', '#0000FF'],
responsive: true
});
// Configure all pie charts
ChartJsProvider.setOptions('Pie', {
datasetFill: true,
chartLegend: true
});
// Configure all bar charts
ChartJsProvider.setOptions('Bar', {
datasetFill: true,
chartLegend: true
});
}])
.controller('mainCtrl', function($scope){
var main = this;
$scope.answered = answered;
$scope.quAnswered = false;
$scope.pieData = [30,50];
$scope.chartData = [[30,60],[50,20]];
$scope.chartLabels = [ 'Female', 'Male'];
$scope.series = ['Pepsi', 'Coca-Cola'];
Chart.defaults.global.responsive = true;
function answered(){
}
})
您可以添加[plunker](https://plnkr.co/edit)鏈接嗎? –