Working with Data in TypeScript Charts
The TypeScript Chart control supports multiple data binding approaches to suit different application scenarios. Data can be bound from local JSON arrays, dynamically loaded on demand with lazy loading, or fetched from remote services using various adaptor patterns. This guide covers all available data binding methods, helping you choose the right approach for your use case based on data size, performance requirements, and back end architecture.
Choosing a data binding approach
| Method | Best for | Advantages | Considerations |
|---|---|---|---|
| Local data | Small to medium datasets | Simple setup, no network latency, instant rendering | All data must be in memory |
| Common data source | Multiple series sharing data | Reduces redundancy, single update point | Limited to data common across series |
| Lazy loading | Large datasets with scrolling | Loads only visible data, better performance | Requires server-side pagination |
| Remote data (OData / Web API) | Backend-driven data | Scalable, centralized data management, server-managed retrieval | Network latency, requires service setup |
| Custom adaptor | Non-standard backend responses | Full request and response control | More code to maintain |
| Offline mode | Data caching with client-side actions | Avoids repeated requests after the initial load | Initial load time and memory constraints |
| Empty points | Missing values within a dataset | Configurable handling of gaps and substituted values | Behavior varies by series type |
| No-data template | Empty or loading states | Displays explanatory content when no records are available | Requires an explicit data update and Chart refresh |
Local data
Bind an array of data objects to a series using the dataSource property in the series configuration. Map the JSON fields to the xName and yName properties to specify which fields represent the X-axis and Y-axis values.
import { Chart, ColumnSeries, Category } from '@syncfusion/ej2-charts';
Chart.Inject(ColumnSeries, Category);
let chartData: Object[] = [
{ month: 'Jan', sales: 35 }, { month: 'Feb', sales: 28 },
{ month: 'Mar', sales: 34 }, { month: 'Apr', sales: 32 },
{ month: 'May', sales: 40 }, { month: 'Jun', sales: 32 },
{ month: 'Jul', sales: 35 }, { month: 'Aug', sales: 55 },
{ month: 'Sep', sales: 38 }, { month: 'Oct', sales: 30 },
{ month: 'Nov', sales: 25 }, { month: 'Dec', sales: 32 }
];
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'Category'
},
series: [{
dataSource: chartData,
xName: 'month',
yName: 'sales',
type: 'Column'
}]
}, '#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>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>Local dataSource values can be arrays of objects or other local structures supported by the series. Financial series require open, high, low, and close mappings, while Bubble series also require a size mapping.
Remote data
Bind remote data from a web service by using the DataManager class. The ej.data.DataManager class retrieves data from REST and OData endpoints. Configure the service URL and an adaptor that matches the endpoint protocol and response format. Assign the DataManager instance to the dataSource property in the series, and map the response fields to xName and yName. Use the optional query property with an ej.data.Query instance to request filtering, sorting, or paging supported by the server.
import { Chart, ColumnSeries, Category } from '@syncfusion/ej2-charts';
import { DataManager, Query } from '@syncfusion/ej2-data';
Chart.Inject(ColumnSeries, Category);
let dataManager: DataManager = new DataManager({
url: 'https://services.syncfusion.com/js/production/api/orders'
});
let query: Query = new Query().take(5).where('Estimate', 'lessThan', 3, false);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'Category'
},
primaryYAxis:
{
title: 'Freight rate in U.S. dollars'
},
series: [
{
type: 'Column',
dataSource: dataManager,
xName: 'CustomerID', yName: 'Freight', query: query
}
],
title: 'Container freight rate'
}, '#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>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>The endpoint must allow requests from the application origin. A basic endpoint can return an array; adaptor-based endpoints can require a result-and-count wrapper. Handle rejected requests and invalid responses before updating the Chart.
var manager = new ej.data.DataManager({
url: 'https://example.com/api/sales',
adaptor: new ej.data.WebApiAdaptor()
});
manager.executeQuery(new ej.data.Query()).then(function (result) {
chart.series[0].dataSource = result.result || [];
chart.refresh();
}).catch(function (error) {
console.error('Unable to load chart data.', error);
});Remote-data adaptors
ODataAdaptor
OData is a standardized protocol for creating and consuming data via REST APIs. Use the ODataAdaptor with DataManager to retrieve data from OData services. The adaptor automatically constructs the correct query syntax and handles standard OData conventions.
Example use case: Querying a product sales service that implements OData v3.0 filtering, sorting, and pagination.
import { Chart, ColumnSeries, Category } from '@syncfusion/ej2-charts';
import { DataManager, Query, ODataAdaptor } from '@syncfusion/ej2-data';
Chart.Inject(ColumnSeries, Category);
let dataManager: DataManager = new DataManager({
url: 'https://services.odata.org/V3/Northwind/Northwind.svc/Orders/',
adaptor: new ODataAdaptor(),
crossDomain: true
});
let query: Query = new Query();
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'Category'
},
//Initializing Chart Sample
series: [
{
type: 'Column',
dataSource: dataManager,
xName: 'CustomerID', yName: 'Freight', query: query
}
],
title: 'Sprint Task Analysis'
}, '#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>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>ODataV4Adaptor
OData v4 is a later protocol version with conventions and capabilities that differ from OData v3. Use the ODataV4Adaptor to consume ODataV4 services. For more information on ODataV4 specifications, refer to the OData v4 documentation.
When to use ODataV4Adaptor: If your backend service implements OData v4.0, use this adaptor so requests and responses follow the service protocol.
import { Chart, ColumnSeries, Category } from '@syncfusion/ej2-charts';
import { DataManager, Query, ODataV4Adaptor } from '@syncfusion/ej2-data';
Chart.Inject(ColumnSeries, Category);
let dataManager: DataManager = new DataManager({
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Orders',
adaptor: new ODataV4Adaptor()
});
let query: Query = new Query();
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'Category'
},
//Initializing Chart Sample
series: [
{
type: 'Column',
dataSource: dataManager,
xName: 'CustomerID', yName: 'Freight', query: query
}
],
title: 'Sprint Task Analysis'
}, '#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>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>Web API adaptor
Use the WebApiAdaptor to consume custom REST APIs that follow a standard response format. This adaptor is ideal for back ends that do not implement OData but provide REST endpoints returning JSON data.
Expected response format
The response shape must match the selected adaptor and server implementation. If the service returns an Items and Count wrapper, transform it in a custom adaptor when the built-in adaptor expects a different result-and-count structure.
import { Chart, ColumnSeries, Category } from '@syncfusion/ej2-charts';
import { DataManager, Query, WebApiAdaptor } from '@syncfusion/ej2-data';
Chart.Inject(ColumnSeries, Category);
let dataManager: DataManager = new DataManager({
url: 'https://services.syncfusion.com/js/production/api/orders',
adaptor: new WebApiAdaptor()
});
let query: Query = new Query();
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'Category'
},
//Initializing Chart Sample
series: [
{
type: 'Column',
dataSource: dataManager,
xName: 'CustomerID', yName: 'Freight', query: query
}
],
title: 'Sprint Task Analysis'
}, '#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>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>Example response
The Web API should structure its response as shown below. The Items array contains the actual data records, and Count indicates the total available records (supporting server-side pagination).
{
Items": [
{ "month": "Jan", "sales": 35 },
{ "month": "Feb", "sales": 28 }
],
"Count": 2
}
In this example, Items contains the records and Count contains the total record count. Map or transform these keys as required by the configured adaptor.
Custom adaptor
Create a custom adaptor by extending the built-in adaptor that matches the endpoint protocol and response format to add custom logic for request/response handling. Override the processResponse method to transform or enrich the response data. The signature is processResponse(data, ds, query, xhr, request, changes). Common use cases include adding serial numbers, reformatting dates, or adding computed fields before the chart renders the data.
import { Chart, ColumnSeries, Category } from '@syncfusion/ej2-charts';
import { DataManager, Query, ODataAdaptor } from '@syncfusion/ej2-data';
Chart.Inject(ColumnSeries, Category);
class SerialNoAdaptor extends ODataAdaptor {
processResponse(): Object {
let i: number = 0;
// calling base class processResponse function
let original: {result: Object[], count: number} = super.processResponse.apply(this, arguments);
// adding serial number
original.result.forEach((item: Object) => item['Sno'] = ++i);
return { result: original.result, count: original.count };
}
}
let dataManager: DataManager = new DataManager({
url: 'https://services.syncfusion.com/js/production/api/orders',
adaptor: new SerialNoAdaptor()
});
let query: Query = new Query();
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'Category'
},
//Initializing Chart Sample
series: [
{
type: 'Column',
dataSource: dataManager,
xName: 'CustomerID', yName: 'Sno', query: query
}
],
title: 'Sprint Task Analysis'
}, '#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>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>Lazy loading
Configure a scrollbar or zoomed axis range before relying on scrollEnd. Use the event range values to request server-side pages, cancel obsolete requests when possible, and ignore out-of-order responses.
Lazy loading enables on-demand data retrieval, requesting data for the visible range instead of loading the complete dataset at initialization. The Chart raises the scrollEnd event when the user scrolls near the edge of the visible data range. In this event handler, retrieve the minimum and maximum values from the scrolled axis, request the corresponding data from your server, and either replace or merge the series data according to the application caching strategy. This approach is ideal for large datasets that would be expensive to load entirely into memory.
How lazy loading works:
- The user scrolls the Chart to a different data range.
- The
scrollEndevent provides the current axis range. - Request the corresponding range from the server and show a loading state.
- Merge or replace the series data while preventing duplicate and stale responses.
- Assign the updated data source and call
chart.refresh().
import { Chart, ScrollBar, Zoom, IScrollEventArgs, LineSeries, Tooltip, DateTime } from '@syncfusion/ej2-charts';
import { Internationalization, DateFormatOptions } from '@syncfusion/ej2-base';
Chart.Inject(DateTime, ScrollBar, Zoom, LineSeries, Tooltip);
let intl: Internationalization = new Internationalization();
let chart: Chart = new Chart({
primaryXAxis: {
title: 'Day',
valueType: 'DateTime',
edgeLabelPlacement: 'Shift',
skeleton: 'yMMM',
skeletonType: 'Date',
scrollbarSettings: {
range: {
minimum: new Date(2009, 0, 1),
maximum: new Date(2014, 0, 1)
},
enable: true,
}
},
primaryYAxis: {
title: 'Server Load',
labelFormat: '{value}MB'
},
series: [{
dataSource: GetDateTimeData(new Date(2009, 0, 1), new Date(2009, 8, 1)),
xName: 'x', yName: 'y',
type: 'Line', animation: { enable: false },
}],
height: '450',
title: 'Network Load',
crosshair: { enable: true, lineType: 'Vertical' },
tooltip: { enable: true, shared: true },
legendSettings: { visible: true },
scrollEnd: (args: IScrollEventArgs) => {
if (lazymode.value === 'Range') {
chart.series[0].dataSource = GetDateTimeData(args.currentRange.minimum as Date, args.currentRange.maximum as Date);
}
chart.dataBind();
},
}, '#element');
function GetDateTimeData(start: Date, end: Date): { x: Date, y: number }[] {
let series1: { x: Date, y: number }[] = [];
let date: number;
let value: number = 30;
let option: DateFormatOptions = {
skeleton: 'full',
type: 'dateTime'
};
let dateParser: Function = intl.getDateParser(option);
let dateFormatter: Function = intl.getDateFormat(option);
for (let i: number = 0; start <= end; i++) {
date = Date.parse(dateParser(dateFormatter(start)));
if (Math.random() > .5) {
value += (Math.random() * 10 - 5);
} else {
value -= (Math.random() * 10 - 5);
}
if (value < 0) {
value = getRandomInt(20, 40);
}
let point1: { x: Date, y: number } = { x: new Date(date), y: Math.round(value) };
new Date(start.setDate(start.getDate() + 1));
series1.push(point1);
}
return series1;
} function getRandomInt(min: number, max: number): number {
return Math.floor(Math.random() * (max - min + 1)) + min;
}<!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>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>Offline mode
When using remote data binding, filtering, sorting, and pagination can be performed on the server depending on the adaptor and query. To improve responsiveness and reduce server load, enable offline mode so DataManager fetches and caches the complete dataset before the Chart consumes it. Subsequent DataManager operations can run against the local cache. Set the offline property of DataManager to true to activate this behavior.
Use offline mode when:
- The dataset can be held within the application’s browser-memory limits.
- Filtering and sorting should run without additional server requests.
- Network latency affects repeated requests.
- The application can tolerate the larger initial download.
Caution: Offline mode fetches the complete dataset initially. Provide an explicit refresh path when the server data changes, and avoid this mode for datasets that exceed browser-memory limits.
import { Chart, ColumnSeries, Category } from '@syncfusion/ej2-charts';
import { DataManager, Query, ODataAdaptor } from '@syncfusion/ej2-data';
Chart.Inject(ColumnSeries, Category);
let dataManager: DataManager = new DataManager({
url: 'https://services.syncfusion.com/js/production/api/orders',
adaptor: new ODataAdaptor(),
offline: true
});
let query: Query = new Query();
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'Category'
},
//Initializing Chart Sample
series: [
{
type: 'Column',
dataSource: dataManager,
xName: 'CustomerID', yName: 'Freight', query: query
}
],
title: 'Sprint Task Analysis'
}, '#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>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>Empty points
A point whose mapped Y value is null or undefined is treated as an empty point. Configure emptyPointSettings in the series regardless of whether the data comes from dataSource or individual points. The visual result depends on the series type and selected mode.
Empty-point modes
-
Gap: Leaves a break in line-like series and omits the empty category value in discrete series. -
Zero: Replaces the missing Y value with zero. -
Average: Replaces the missing Y value with an average calculated from neighboring values.
Verify any additional modes against the installed Chart version.
import { Chart, ColumnSeries, LineSeries, Category } from '@syncfusion/ej2-charts';
Chart.Inject(ColumnSeries, LineSeries, Category);
let chartData: Object[] = [
{ month: 'Jan', sales: 35 }, { month: 'Feb', sales: 28 },
{ month: 'Mar', sales: null }, { month: 'Apr', sales: 32 },
{ month: 'May', sales: 40 }, { month: 'Jun', sales: 32 },
{ month: 'Jul', sales: 35 }, { month: 'Aug', sales: undefined },
{ month: 'Sep', sales: 38 }, { month: 'Oct', sales: 30 },
{ month: 'Nov', sales: 25 }, { month: 'Dec', sales: 32 }
];
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'Category'
},
series:[{
dataSource: chartData,
xName: 'month',
yName: 'sales',
type: 'Column',
emptyPointSettings: {
mode: 'Gap'
}
},
{
dataSource: chartData,
xName: 'month',
yName: 'sales',
type: 'Line',
marker: { visible: true},
emptyPointSettings: {
mode: 'Average'
}
}]
}, '#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>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>Customize empty points
Set a renderable empty-point mode, and then use emptyPointSettings.fill to apply a color to the substituted point. A Gap does not render a point that can receive a fill.
import { Chart, ColumnSeries, LineSeries Category } from '@syncfusion/ej2-charts';
Chart.Inject(ColumnSeries, LineSeries, Category);
let chartData: Object[] = [
{ month: 'Jan', sales: 35 }, { month: 'Feb', sales: 28 },
{ month: 'Mar', sales: null }, { month: 'Apr', sales: 32 },
{ month: 'May', sales: 40 }, { month: 'Jun', sales: 32 },
{ month: 'Jul', sales: 35 }, { month: 'Aug', sales: undefined },
{ month: 'Sep', sales: 38 }, { month: 'Oct', sales: 30 },
{ month: 'Nov', sales: 25 }, { month: 'Dec', sales: 32 }
];
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'Category'
},
series:[{
dataSource: chartData,
xName: 'month',
yName: 'sales',
type: 'Column',
emptyPointSettings: {
mode: 'Average',
fill: 'green',
border: { color: 'black', width: 2}
}
},
{
dataSource: chartData,
xName: 'month',
yName: 'sales',
type: 'Line',
marker: { visible: true},
emptyPointSettings: {
mode: 'Zero',
fill: 'pink'
}
}]
}, '#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>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>Handling no data
Use the Chart noDataTemplate property to display explanatory content when no renderable records are available. The template can be a supported string, selector, or function according to the installed Chart version. Encode or sanitize untrusted values before rendering HTML. Empty points represent missing values inside a dataset; a no-data template represents an empty dataset or loading state. After data arrives, assign the data to the series and call chart.refresh() to replace the template with the visualization.
chart.series[0].dataSource = loadedData;
chart.refresh();import {
Chart, LineSeries, Category, ChartTheme,
Tooltip, ILoadedEventArgs
} from '@syncfusion/ej2-charts';
import { Button } from '@syncfusion/ej2-buttons';
/**
* Sample for No Data Template
*/
Chart.Inject(LineSeries, Category, Tooltip);
const chartData: Object[] = [
{ Month: 'January', Value: 19173 },
{ Month: 'February', Value: 17726 },
{ Month: 'March', Value: 19874 },
{ Month: 'April', Value: 19391 },
{ Month: 'May', Value: 20072 },
{ Month: 'June', Value: 19233 }
];
let checked: boolean = false;
const chart: Chart = new Chart({
title: 'Milk Production in US - 2025',
subTitle: 'Source: nass.usda.gov',
primaryXAxis: {
valueType: 'Category',
majorGridLines: { width: 0 },
majorTickLines: { width: 0 },
},
primaryYAxis: {
title: 'Production (in million pounds)',
titleStyle: { fontWeight: '600' },
majorTickLines: { width: 0 },
lineStyle: { width: 0 }
},
chartArea: {
border: { width: 0 },
},
series: [{
dataSource: [],
xName: 'Month',
yName: 'Value',
type: 'Line',
width: 2,
marker: {
visible: true, width: 7, height: 7
}
}],
tooltip: {
enable: true,
header: 'Milk Production',
format: '${point.x} : <b>${point.y}M</b>'
},
noDataTemplate: `
<div id="noDataTemplateContainer" class="light-bg">
<div class="template-align">
<img src="no-data.png" alt="No Data"/>
</div>
<div class="template-align">
<p style="font-size: 15px; margin: 10px 0 0;"><strong>No data available to display.</strong></p>
</div>
<div class="template-align">
<button id="loadDataBtn" style="margin-top: 15px;"></button>
</div>
</div>
`,
loaded: (args: ILoadedEventArgs) => {
const btnElem: HTMLElement | null = document.getElementById('loadDataBtn');
if (btnElem) {
const loadBtn: Button = new Button({
content: 'Load Data',
iconCss: 'e-icons e-refresh',
cssClass: 'e-outline',
isPrimary: false
});
loadBtn.appendTo(btnElem);
loadBtn.element.onclick = (): void => {
checked = !checked;
if (checked) {
chart.series[0].dataSource = chartData;
}
chart.refresh();
};
}
}
});
chart.appendTo('#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>
<style>
#noDataTemplateContainer {
height: inherit;
width: inherit;
}
.load-data-btn {
border-radius: 4px !important;
text-transform: none !important;
}
.light-bg {
background-color: #fafafa;
color: #000000;
}
.template-align img {
max-width: 150px;
/* Adjust size as needed */
max-height: 150px;
margin-top: 55px;
}
.template-align {
display: flex;
align-items: center;
justify-content: center;
text-align: center;
}
</style>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>Troubleshooting
- If no points are rendered, verify that
xName,yName, and any financial or Bubble mappings exactly match the response fields. - If a remote request fails, check the endpoint URL, HTTPS usage, CORS policy, authentication, and browser network response.
- If an adaptor returns no data, confirm that the response shape matches the selected adaptor and that the expected result and count fields are present.
- If lazy-loaded data appears out of order or duplicated, cancel obsolete requests and merge records using a stable key.
- If an empty point is invisible after setting
fill, select a renderable mode such asZeroorAverage. - If the no-data template remains visible, assign a non-empty data source and call
chart.refresh().