Angular 谷歌圖表 - 堆積柱狀圖



以下是堆積柱狀圖的示例。

我們在 谷歌圖表配置語法 章節中已經瞭解了用於繪製圖表的配置。現在,我們來看一下堆積柱狀圖的示例。

配置

我們使用 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;
}

結果

驗證結果。

Stacked Bar Chart
angular_googlecharts_bar_charts.htm
廣告
© . All rights reserved.