Search results

Getting started with Angular Accumulation Chart component

14 Apr 2021 / 3 minutes to read

This section explains you the steps required to create a simple Chart and demonstrate the basic usage of the AccumulationChart component in an Angular environment.

Setup Angular Environment

You can use Angular CLI to setup your Angular applications. To install Angular CLI use the following command.

Copied to clipboard
npm install -g @angular/cli

Create an Angular Application

Start a new Angular application using below Angular CLI command.

Copied to clipboard
ng new my-app
cd my-app

Adding Syncfusion Chart package

All the available Essential JS 2 packages are published in registry.

To install AccumulationChart component, use the following command.

Copied to clipboard
npm install @syncfusion/ej2-angular-charts --save

The —save will instruct NPM to include the chart package inside of the dependencies section of the package.json.

Registering AccumulationChart Module

Import AccumulationChart module into Angular application(app.module.ts) from the package @syncfusion/ej2-angular-charts [src/app/app.module.ts].

Copied to clipboard
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
// import the AccumulationChartModule for the AccumulationChart component
import { AccumulationChartModule } from '@syncfusion/ej2-angular-charts';
import { AppComponent }  from './app.component';

  //declaration of AccumulationChartModule into NgModule
  imports:      [ BrowserModule, AccumulationChartModule ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
export class AppModule { }
  • Modify the template in app.component.ts file to render the ej2-angular-charts component [src/app/app.component.ts].
Copied to clipboard
import { Component, ViewEncapsulation } from '@angular/core';

  selector: 'app-container',
  // specifies the template string for the Accumulation Charts component
  template: `<ejs-accumulationchart id="pie-container">
  encapsulation: ViewEncapsulation.None
export class AppComponent  { }

Now use the app-container in the index.html instead of default one.

Copied to clipboard
  • Now run the application in the browser using the below command.
Copied to clipboard
npm start

Pie Series

By default pie series will be rendered on assigning JSON data to the series by using dataSource property. Map the field names in the JSON data to the xName and yName properties of the series.

Copied to clipboard
import { Component, OnInit } from '@angular/core';

selector: 'app-container',
`<ejs-accumulationchart id="chart-container" [legendSettings]='legendSettings'>
        <e-accumulation-series [dataSource]='piedata' xName='x' yName='y'></e-accumulation-series>
export class AppComponent implements OnInit {
public piedata: Object[];
public legendSettings: Object;
ngOnInit(): void {
    this.piedata = [
            { x: 'Jan', y: 3, text: 'Jan: 3' }, { x: 'Feb', y: 3.5, text: 'Feb: 3.5' },
            { x: 'Mar', y: 7, text: 'Mar: 7' }, { x: 'Apr', y: 13.5, text: 'Apr: 13.5' },
            { x: 'May', y: 19, text: 'May: 19' }, { x: 'Jun', y: 23.5, text: 'Jun: 23.5' },
            { x: 'Jul', y: 26, text: 'Jul: 26' }, { x: 'Aug', y: 25, text: 'Aug: 25' },
            { x: 'Sep', y: 21, text: 'Sep: 21' }, { x: 'Oct', y: 15, text: 'Oct: 15' },
            { x: 'Nov', y: 9, text: 'Nov: 9' }, { x: 'Dec', y: 3.5, text: 'Dec: 3.5' }];

    this.legendSettings = {
        visible: false

Copied to clipboard
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { AccumulationChartModule } from '@syncfusion/ej2-angular-charts';
import { PieSeriesService, AccumulationLegendService, AccumulationTooltipService, AccumulationAnnotationService,
  AccumulationDataLabelService } from '@syncfusion/ej2-angular-charts';

 * Module
    imports: [
        BrowserModule, AccumulationChartModule
    declarations: [AppComponent],
    bootstrap: [AppComponent],
    providers: [PieSeriesService, AccumulationLegendService, AccumulationTooltipService, AccumulationDataLabelService,
export class AppModule { }
Copied to clipboard
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';