Angular Google Charts - Candlestick Chart with Custom Colors



Following is an example of a customized Candlestick 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 basic Candlestick Chart.

Configurations

We've used options to customized color of Candlestick Chart.

options = {
   legend:'none', 
   candlestick: {
      fallingColor: { strokeWidth: 2, stroke:'#a52714' }, // red
      risingColor: { strokeWidth: 2, stroke: '#0f9d58' }   // green
   }
};

Example - Usage of Candlestick 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.CandlestickChart;
   data = [
      ["Mon", 20, 28, 38, 45],
      ["Tue", 31, 38, 55, 66],
      ["Wed", 50, 55, 77, 80],
      ["Thu", 77, 77, 66, 50],
      ["Fri", 68, 66, 22, 15]
   ];
   columnNames = ['Date', 'A','B','C','D'];
   options = {
      legend:'none', 
      candlestick: {
         fallingColor: { strokeWidth: 2, stroke:'#a52714' }, // red
         risingColor: { strokeWidth: 2, stroke: '#0f9d58' }   // green
      }
   };
   width = 550;
   height = 400;
}

Result

Verify the result.

Customized Candlestick Chart
angular_googlecharts_candlestick_charts.htm
Advertisements