Angular Google Charts - Stacked Area Chart



Following is an example of a Stacked Area 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 Area Chart.

Configurations

We've used isStacked configuration to show stacked chart.

options = { 
   isStacked:true, hAxis: {
      title: 'Year'
   }  
};

Example - Usage of Stacked Area 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.AreaChart;
   data = [
      ["2013", 1000, 400],
      ["2014", 1170, 460],
      ["2015", 660, 1120],
      ["2016", 1030, 540]
   ];
   columnNames = ['Year', 'Sales','Expenses'];
   options = {   
      title: 'Area Chart',
	  isStacked:true,
      hAxis: {
         title: 'Year'
      }
   };
   width = 550;
   height = 400;
}

Result

Verify the result.

Stacked Area Chart
angular_googlecharts_area_charts.htm
Advertisements