堆疊柱狀圖
以下是堆疊柱狀圖示例。
我們在 Google Charts 配置語法 一章中已經瞭解了繪製圖表時使用的配置。現在,讓我們看一個堆疊柱狀圖示例。
配置
我們使用了 isStacked 選項將基於柱的圖表顯示為堆疊。
options = {
isStacked:true,
}
示例
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'Population (in millions)';
type = 'BarChart';
data = [
["2012", 900, 390],
["2013", 1000, 400],
["2014", 1170, 440],
["2015", 1250, 480],
["2016", 1530, 540]
];
columnNames = ['Year', 'Asia','Europe'];
options = {
hAxis: {
title: 'Year'
},
vAxis:{
minValue:0
},
isStacked:true
};
width = 550;
height = 400;
}
結果
驗證結果。
angular_googlecharts_column_charts.htm
廣告