Example shows Angular Waterfall Chart which helps in understanding the cumulative effect of positive and negative values to its initial value.
/* app.component.ts */ import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { chartOptions = { theme: "light1", // "light1", "ligh2", "dark1", "dark2" animationEnabled: true, title: { text: "Company Finance Report" }, axisY: { title: "Amount (in USD)", prefix: "$", suffix: "K", lineThickness: 0, includeZero: true }, data: [{ type: "waterfall", yValueFormatString: "$#,##0K", dataPoints: [ { label: "Sales", y: 3273 }, { label: "Service", y: 1623 }, { label: "Total Revenue", isIntermediateSum: true}, { label: "Research", y: -250 }, { label: "Marketing", y: -210 }, { label: "Salaries", y: -432 }, { label: "Operating Income", isCumulativeSum: true }, { label: "Taxes", y: -264 }, { label: "Net Income", isCumulativeSum: true } ] }] } }
/* app.module.ts */ import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { AppComponent } from './app.component'; import * as CanvasJSAngularChart from '../assets/canvasjs.angular.component'; var CanvasJSChart = CanvasJSAngularChart.CanvasJSChart; @NgModule({ declarations: [ AppComponent, CanvasJSChart ], imports: [ BrowserModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }
<div> <canvasjs-chart [options]="chartOptions" [styles]="{width: '100%', height:'360px'}"></canvasjs-chart> </div>
You can change the color of column representing positive and negative values in waterfall chart using risingColor and fallingColor property respectively. You can also customize the color of any column. In the above example, color of cumulative has been customized by setting color property in datapoint level. Other commonly customization option includes lineColor, lineThickness, showInLegend, etc.