Angular Google Charts - Stacked Bar Chart



Following is an example of a Stacked Bar Chart.

We have already seen the configurations used to draw a chart in Google Charts Configuration Syntax chapter. Now, let us see an example of a Stacked Bar Chart.

Configurations

We've used isStacked option to show bar based chart as stacked.

options = { 
   isStacked:true,
}

Example - Usage of Grouped Bar Chart

app.ts

import { Component, signal } from '@angular/core';
import { ChartType, GoogleChart } from 'angular-google-charts';

@Component({
   selector: 'app-root',
   imports: [GoogleChart],
   templateUrl: './app.html',
   styleUrl: './app.css'
})
export class App {
   protected readonly title = signal('google-charts-app');
   type: ChartType = ChartType.BarChart;
   data = [
      ["2012", 900, 390],
      ["2013", 1000, 400],
      ["2014", 1170, 440],
      ["2015", 1250, 480],
      ["2016", 1530, 540]
   ];
   columnNames = ['Year', 'Asia','Europe'];
   options = {   
      title: 'Population (in millions)',
	  hAxis: {
         title: 'Year'
      },
      vAxis:{
         minValue:0
      },
      isStacked:true	
   };
   width = 550;
   height = 400;
}

Result

Verify the result.

Stacked Bar Chart
angular_googlecharts_bar_charts.htm
Advertisements