Bar Chart in Angular Charts

27 Aug 202524 minutes to read

Bar

Bar charts are ideal for comparing values across different categories, displaying data horizontally where the length of each bar represents the value.

To render a bar series in your chart:

  1. Set the series type: Define the series type as Bar in your chart configuration. This indicates that the data should be represented as a bar chart, which makes it easy to compare values across categories.

  2. Inject the BarSeries module: Use the @NgModule.providers method to inject the BarSeriesService module into your chart. This step is essential, as it ensures that the necessary functionalities for rendering bar series are available in your chart.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: 226.4 },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: 104.8 }
];

Data binding for bar series

Connect your data to the chart using the dataSource property within the series configuration. This property supports JSON datasets and remote data sources. Map the data fields to the chart series using xName and yName properties to ensure proper data visualization.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: 226.4 },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: 104.8 }
];

Series customization

Customize the appearance of bar series using various styling properties to match your application’s design requirements.

Fill

The fill property determines the color applied to the series.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' fill='#1f77b4' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' fill='#ff7f0e' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' fill='#2ca02c' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: 226.4 },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: 104.8 }
];

Gradient fill

Apply gradient colors to create visually appealing bar series with smooth color transitions by configuring the fill property with gradient values.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' fill='url(#appleGradient)' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' fill='url(#xiaomiGradient)' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' fill='url(#oppoGradient)' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: 226.4 },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: 104.8 }
];

Opacity

Control the transparency level of the bar fill using the opacity property. Values range from 0 (completely transparent) to 1 (completely opaque).

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius' opacity=0.5></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius' opacity=0.5></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius' opacity=0.5></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: 226.4 },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: 104.8 }
];

Border

Customize the bar series border using the border property to adjust width, color, and dash pattern.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius' [border]='border'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius' [border]='border'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius' [border]='border'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    public border?: Object;
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
        this.border = {
            width: 2, 
            color: '#ff4251', 
            dashArray: '2,5' 
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: 226.4 },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: 104.8 }
];

Bar spacing and dimensions

Bar spacing

Use the columnSpacing property in the series to adjust the space between bars.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: 226.4 },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: 104.8 }
];

Bar width

Use the columnWidth property in the series to adjust the width of the bars.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' columnSpacing=0.3 columnWidth=0.5 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' columnSpacing=0.3 columnWidth=0.75 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' columnSpacing=0.3 columnWidth=0.4 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: 226.4 },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: 104.8 }
];

Bar width in pixels

Use the columnWidthInPixel property in the series to define the exact width of the bars in pixels. This property ensures that each bar maintains the specified width, providing a uniform appearance throughout the chart.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' columnSpacing=0.3 columnWidthInPixel=5 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: 226.4 },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: 104.8 }
];

Grouped bar charts

Use the groupName property to group the data points in bar type charts. Data points with the same group name will be grouped together in the chart, making it easy to compare different sets of data.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius' groupName='AppleandOppo'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' columnSpacing=0.6 legendShape='Rectangle' [cornerRadius]='cornerRadius' groupName='AppleandOppo'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: 226.4 },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: 104.8 }
];

Cylindrical bar chart

To render a cylindrical bar chart, set the columnFacet property to Cylinder in the chart series. This property transforms the regular bars into cylindrical shapes, enhancing the visual representation of the data.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius' columnFacet='Cylinder'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius' columnFacet='Cylinder'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius' columnFacet='Cylinder'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: 226.4 },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: 104.8 }
];

Empty points

Data points with null or undefined values are considered empty points. These points are handled according to the specified mode and can be customized for better visual representation.

Mode

Use the mode property to define how empty or missing data points are handled in the series. The default mode for empty points is Gap.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius' [emptyPointSettings]='appleEmptyPointSettings'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius' [emptyPointSettings]='oopoEmptyPointSettings'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    public appleEmptyPointSettings?: Object;
    public oopoEmptyPointSettings?: Object;
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
        this.appleEmptyPointSettings = { mode: 'Gap' };
        this.oopoEmptyPointSettings = { mode: 'Average' };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: null },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: null }
];

Fill

Customize the fill color of empty points using the fill property to maintain visual consistency or highlight missing data.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius' [emptyPointSettings]='appleEmptyPointSettings'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius' [emptyPointSettings]='oopoEmptyPointSettings'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    public appleEmptyPointSettings?: Object;
    public oopoEmptyPointSettings?: Object;
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
        this.appleEmptyPointSettings = { mode: 'Gap' };
        this.oopoEmptyPointSettings = { mode: 'Average', fill: 'red' };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: null },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: null }
];

Border

Customize the border appearance of empty points using the border property to adjust width and color.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius' [emptyPointSettings]='appleEmptyPointSettings'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius' [emptyPointSettings]='oopoEmptyPointSettings'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    public appleEmptyPointSettings?: Object;
    public oopoEmptyPointSettings?: Object;
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
        this.appleEmptyPointSettings = { mode: 'Gap' };
        this.oopoEmptyPointSettings = { mode: 'Average', fill: 'red', border: { width: 2, color: 'green' } };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: null },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: null }
];

Corner radius customization

Series corner radius

The cornerRadius property in the chart series is used to customize the corner radius for bar series. This allows you to create bars with rounded corners, giving your chart a more polished appearance. You can customize each corner of the bars using the topLeft, topRight, bottomLeft, and bottomRight properties.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: 226.4 },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: 104.8 }
];

Individual point corner radius

The corner radius can be customized for individual points in the chart series using the pointRender event by setting the cornerRadius property in its event argument.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { IPointRenderEventArgs } from '@syncfusion/ej2-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea' (pointRender)='pointRender($event)'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' columnSpacing=0.3 legendShape='Rectangle'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' columnSpacing=0.3 legendShape='Rectangle'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' columnSpacing=0.3 legendShape='Rectangle'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    public pointRender(args: IPointRenderEventArgs): void {
        if (args.series.index !== 1) {
            if (args.point.index === 0) {
                args.cornerRadius = { topLeft: 0, bottomLeft: 0, topRight: 10, bottomRight: 10 };
            }
            if (args.point.index === 2) {
                args.cornerRadius = { topLeft: 0, bottomLeft: 0, topRight: 10, bottomRight: 10 };
            }
        }
    };
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: 226.4 },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: 104.8 }
];

Events

Series render

The seriesRender event allows customization of series properties, such as data, fill, and name, before rendering on the chart.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { ISeriesRenderEventArgs } from '@syncfusion/ej2-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea' (seriesRender)='seriesRender($event)'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    public seriesRender(args: ISeriesRenderEventArgs): void {
        if (args.series.name === 'Apple') {
            args.fill = '#007AFF';
        } else if (args.series.name === 'Xiaomi') {
            args.fill = '#FF6900';
        } else {
            args.fill = '#1BA784';
        }
    };
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let appleSalesData: Object[] = [
  { year: '2022', count: 226.4 },
  { year: '2023', count: 234.6 },
  { year: '2024', count: 232.1 }
];

export let xiaomiSalesData: Object[] = [
  { year: '2022', count: 153.1 },
  { year: '2023', count: 145.9 },
  { year: '2024', count: 168.5 }
];

export let oppoSalesData: Object[] = [
  { year: '2022', count: 103.3 },
  { year: '2023', count: 103.1 },
  { year: '2024', count: 104.8 }
];

Point render

The pointRender event allows customization of each data point before rendering on the chart.

import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts';
import { BarSeriesService, TooltipService, CategoryService, LegendService } from '@syncfusion/ej2-angular-charts';
import { IPointRenderEventArgs } from '@syncfusion/ej2-charts';
import { Component, OnInit } from '@angular/core';
import { appleSalesData, xiaomiSalesData, oppoSalesData } from './datasource';

@Component({
    imports: [ChartModule, ChartAllModule],
    providers: [BarSeriesService, CategoryService, LegendService, TooltipService],
    standalone: true,
    selector: 'app-container',
    template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis'[primaryYAxis]='primaryYAxis' [title]='title' [legendSettings]='legendSettings' [tooltip]='tooltip' [chartArea]='chartArea' (pointRender)='pointRender($event)'>
        <e-series-collection>
            <e-series [dataSource]='appleChartData' type='Bar' xName='year' yName='count' name='Apple' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='xiaomiChartData' type='Bar' xName='year' yName='count' name='Xiaomi' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
            <e-series [dataSource]='oppoChartData' type='Bar' xName='year' yName='count' name='Oppo' columnSpacing=0.3 legendShape='Rectangle' [cornerRadius]='cornerRadius'></e-series>
        </e-series-collection>
    </ejs-chart>`
})
export class AppComponent implements OnInit {
    public primaryXAxis?: Object;
    public appleChartData?: Object[];
    public xiaomiChartData?: Object[];
    public oppoChartData?: Object[];
    public title?: string;
    public primaryYAxis?: Object;
    public legendSettings?: Object;
    public tooltip?: Object;
    public cornerRadius?: Object;
    public chartArea?: Object;
    public pointRender(args: IPointRenderEventArgs): void {
        if (args.series.index === 0) {
            if (args.point.index === 0) {
                args.fill = '#BB8FCE';
            } else if (args.point.index === 1) {
                args.fill = '#4ECDC4';
            } else if (args.point.index === 2) {
                args.fill = '#45B7D1';
            }
        }
        if (args.series.index === 1) {
            if (args.point.index === 0) {
                args.fill = '#F1948A';
            } else if (args.point.index === 1) {
                args.fill = '#5DADE2';
            } else if (args.point.index === 2) {
                args.fill = '#DDA0DD';
            }
        }
        if (args.series.index === 2) {
            if (args.point.index === 0) {
                args.fill = '#98D8C8';
            } else if (args.point.index === 1) {
                args.fill = '#F7DC6F';
            } else if (args.point.index === 2) {
                args.fill = '#82E0AA';
            }
        }
    };
    ngOnInit(): void {
        this.appleChartData = appleSalesData;
        this.xiaomiChartData = xiaomiSalesData;
        this.oppoChartData = oppoSalesData;
        this.primaryXAxis = {
            valueType: 'Category',
            majorTickLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.primaryYAxis = {
            labelFormat: '{value}M',
            title: 'Units Sold (in Millions)',
            maximum: 300,
            edgeLabelPlacement: 'Shift',
            majorTickLines: { width: 0 },
            majorGridLines: { width: 0 },
            lineStyle: { width: 0 }
        };
        this.title = 'Global Smartphone Sales Trends by Brand (2022-2024)';
        this.legendSettings = {
            visible: true,
            enableHighlight: true,
            shapeWidth: 9,
            shapeHeight: 9
        };
        this.tooltip = {
            enable: true,
            enableHighlight: true,
            header: '<b>${series.name}</b>',
            format: '${point.x} : <b>${point.y}</b>'
        };
        this.cornerRadius = {
            topRight: 4,
            bottomRight: 4
        };
        this.chartArea = {
            border: {
                width: 0
            },
            margin: {
                bottom: 12
            }
        };
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let barData: Object[] = [
             { x: 2006, y: 7.8 }, 
             { x: 2007, y: 7.2},
             { x: 2008, y: 6.8 }, 
             { x: 2009, y: 10.7 },
             { x: 2010, y: 10.8}, 
             { x: 2011, y: 9.8 }
];

See also