How can I help you?
Getting started with EJ2 TypeScript Accumulation Chart control
19 Feb 20266 minutes to read
This document explains how to create a simple Accumulation Chart and configure its features in TypeScript using the Essential JS 2 webpack quickstart seed repository.
This application is integrated with the
webpack.config.jsconfiguration and uses the latest version of the webpack-cli. It requires nodev14.15.0or higher. For more information about webpack and its features, refer to the webpack getting-started guide.
Dependencies
Below is the list of minimum dependencies required to use the Accumulation Chart.
|-- @syncfusion/ej2-charts
|-- @syncfusion/ej2-base
|-- @syncfusion/ej2-data
|-- @syncfusion/ej2-pdf-export
|-- @syncfusion/ej2-file-utils
|-- @syncfusion/ej2-compression
|-- @syncfusion/ej2-svg-base
Set up development environment
Open the command prompt from the required directory, and run the following command to clone the Syncfusion JavaScript (Essential JS 2) quickstart project from GitHub.
git clone https://github.com/SyncfusionExamples/ej2-quickstart-webpack ej2-quickstartAfter cloning the application in the ej2-quickstart folder, run the following command line to navigate to the ej2-quickstart folder.
cd ej2-quickstartAdd Syncfusion JavaScript packages
Syncfusion JavaScript (Essential JS 2) packages are available on the npmjs.com public registry. You can install all Syncfusion JavaScript (Essential JS 2) controls in a single @syncfusion/ej2 package or individual packages for each control.
The quickstart application is preconfigured with the dependent @syncfusion/ej2 package in the ~/package.json file. Use the following command to install the dependent npm packages from the command prompt.
npm installAdd accumulation chart to the project
Open the project in Visual Studio Code and add the Accumulation Chart to the application.
Add the HTML div tag with its id attribute as element in your ~/src/index.html file to initialize the Accumulation Chart.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Essential JS 2 Accumulation Chart</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="TypeScript UI Controls" />
<meta name="author" content="Syncfusion" />
....
....
</head>
<body>
<!--container which is going to render the Accumulation chart-->
<div id='element'>
</div>
</body>
</html>Import the Accumulation Chart component into src/app/app.ts to instantiate and render the Accumulation Chart.
import { AccumulationChart } from '@syncfusion/ej2-charts';
// initialize Accumulation Chart component
let chart: AccumulationChart = new AccumulationChart();
// render initialized Accumulation Chart
chart.appendTo('#element');Pie Series
By default, a pie series is rendered when JSON data is assigned to the series dataSource property. Map JSON fields to the series xName and yName properties to bind data correctly.
import { AccumulationChart } from '@syncfusion/ej2-charts';
let piechart: AccumulationChart = new AccumulationChart({
series: [
{
dataSource: [{ x: 'Jan', y: 3 }, { x: 'Feb', y: 3.5 }, { x: 'Mar', y: 7 }, { x: 'Apr', y: 13.5 },
{ x: 'May', y: 19 }, { x: 'Jun', y: 23.5 }, { x: 'Jul', y: 26 }, { x: 'Aug', y: 25 },
{ x: 'Sep', y: 21 }, { x: 'Oct', y: 15 }],
xName: 'x',
yName: 'y'
}
]
}, '#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>Now use the npm run start command to run the application in the browser.
npm run start