Chart events in JavaScript Chart Component
Chart events are callback functions that the Syncfusion EJ2 Chart component triggers at different stages of its life cycle. They allow developers to respond to user interactions, customize rendering, control behavior, and extend chart functionality without modifying the core component. These events enable developers to implement custom logic, enhance interactivity, and tailor the chart’s behavior to specific requirements, thereby providing a more dynamic and responsive user experience.
For a full list of supported JavaScript and Syncfusion package versions, see the Getting Started page. The examples below use the global ej.charts namespace from the EJ2 CDN bundle, so no module injection is needed (Chart.Inject is only required when consuming the individual ES5 modules, for example, ej.charts.Chart.Inject(ej.charts.Tooltip)).
Available events
| Group | Events |
|---|---|
| Animation | animationComplete |
| Labels and Axes |
axisLabelRender, axisLabelClick, axisRangeCalculated, axisMultiLabelRender, multiLevelLabelClick
|
| Series and Points |
seriesRender, pointClick, pointDoubleClick, pointMove, pointRender, textRender
|
| Data Editing (Drag) |
dragStart, drag, dragEnd
|
| Tooltip |
tooltipRender, sharedTooltipRender
|
| Legend |
legendRender, legendClick
|
| Annotations | annotationRender |
| Zooming and Scrolling |
onZooming, zoomComplete, scrollChanged, scrollStart, scrollEnd
|
| Selection and Drag |
dragComplete, selectionComplete
|
| Mouse Events |
chartMouseDown, chartMouseMove, chartMouseUp, chartMouseLeave, chartMouseClick, chartDoubleClick
|
| Life cycle and Layout |
load, loaded, beforeResize, resized, beforePrint, beforeExport, afterExport
|
Animation
animationComplete
Triggered after a series animation completes. Use this event to chain additional UI work, run custom transitions, or release a loading indicator. The series must have animation.enable = true for this event to fire. To know more about the arguments of this event, refer here.
// animationComplete event: fires when the chart series animation finishes rendering.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: {
valueType: 'Category'
},
primaryYAxis: {
labelFormat: '${value}K'
},
legendSettings: {
visible: true
},
title: 'Sales Analysis',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales',
// Data label for chart series
marker: {
dataLabel: {
visible: true
}
},
animation: {
enable: true,
duration: 1000, // ms
delay: 0
}
}],
// Trigger when series animation finishes rendering
animationComplete: function (args) {
console.log('Chart animation complete event was triggered');
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>Labels and Axes
axisLabelRender
Triggered before an axis label is rendered so you can customize its text and style. Set args.cancel = true to hide an individual label. To know more about the arguments of this event, refer here.
// axisLabelRender event: customize or cancel axis labels before they render.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: {
valueType: 'Category'
},
primaryYAxis: {
labelFormat: '${value}K'
},
legendSettings: { visible: true },
title: 'Sales Analysis',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales',
// Data label for chart series
marker: {
dataLabel: {
visible: true
}
}
}],
// Axis label render handler
axisLabelRender: function (args) {
console.log('Chart axis label render event was triggered');
// Example 1: Uppercase category X-axis labels
if (args.axis.valueType === 'Category' && typeof args.text === 'string') {
// Hide a specific label (e.g., 'Aug')
if (args.text === 'Aug') {
args.cancel = true;
return;
}
args.text = args.text.toUpperCase();
}
// Example 2: Custom format for Y-axis numeric labels
if (args.axis.valueType !== 'Category' && typeof args.value === 'number') {
// Format as currency with 'K' suffix
args.text = '$' + args.value + 'K';
}
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>axisLabelClick
Triggered when an axis label is clicked. Use it to drill into a category, toggle an axis-level filter, or open a side panel for the clicked label. To know more about the arguments of this event, refer here.
// axisLabelClick event: fires when an axis label is clicked.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: {
valueType: 'Category'
},
primaryYAxis: {
labelFormat: '${value}K'
},
legendSettings: {
visible: true
},
title: 'Sales Analysis',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales',
// Data label for chart series
marker: {
dataLabel: {
visible: true
}
}
}],
// Axis label click handler
axisLabelClick: function (args) {
console.log('Chart axis label click event was triggered');
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>axisRangeCalculated
Triggered after the axis range (minimum, maximum, and interval) is calculated, allowing you to override the values. For category axes, minimum and maximum apply to category index positions rather than labels. To know more about the arguments of this event, refer here.
// axisRangeCalculated event: modify the computed min/max/interval for axes.
var chartData = [
{ country: 'USA', gold: 50, silver: 70, bronze: 45 },
{ country: 'China', gold: 40, silver: 60, bronze: 55 },
{ country: 'Japan', gold: 70, silver: 60, bronze: 50 },
{ country: 'Australia', gold: 60, silver: 56, bronze: 40 },
{ country: 'France', gold: 50, silver: 45, bronze: 35 },
{ country: 'Germany', gold: 40, silver: 30, bronze: 22 },
{ country: 'Italy', gold: 40, silver: 35, bronze: 37 },
{ country: 'Sweden', gold: 30, silver: 25, bronze: 27 }
];
var chart = new ej.charts.Chart({
// Keep X axis as Category; let the event adjust min/max/interval
primaryXAxis: {
valueType: 'Category',
title: 'Countries'
},
// Basic Y axis; event will add padding and adjust interval
primaryYAxis: {
title: 'Gold Medals'
},
title: 'Olympic Medals',
series: [{
dataSource: chartData,
type: 'Column',
xName: 'country',
yName: 'gold',
name: 'Gold'
}],
// axisRangeCalculated: modify the computed min/max/interval for axes
axisRangeCalculated: function (args) {
console.log('Axis range calculated event was triggered');
if (args.axis.valueType === 'Category' && args.axis.name === 'primaryXAxis') {
args.minimum = 1;
args.maximum = 5;
args.interval = 2;
return;
}
// For Y axis (numeric), add 10% headroom and compute a clean interval
if (args.axis.orientation === 'Vertical') {
var currentMin = Number(args.minimum != null ? args.minimum : 0);
var currentMax = Number(args.maximum != null ? args.maximum : 0);
var range = Math.max(0, currentMax - currentMin);
var pad = range * 0.1; // 10% headroom
// Ensure baseline at 0 and padded max rounded to a nice step
var newMin = 0;
var newMax = Math.ceil((currentMax + pad) / 5) * 5;
args.minimum = newMin;
args.maximum = newMax;
// Choose about 5 ticks
var approxTicks = 5;
var rawInterval = (newMax - newMin) / approxTicks || 1;
// Snap interval to 1/2/5 multiples for readability
var snap = function (val) {
var pow = Math.pow(10, Math.floor(Math.log10(val)));
var norm = val / pow;
var m = 1;
if (norm > 5) { m = 10; }
else if (norm > 2) { m = 5; }
else if (norm > 1) { m = 2; }
return m * pow;
};
args.interval = snap(rawInterval);
}
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>axisMultiLabelRender
Triggered before multi-level axis labels are rendered so you can customize their text and style. Multi-level labels must be configured on the axis via the multiLevelLabels property; injecting the MultiLevelLabel module is also required when consuming individual ES5 modules. To know more about the arguments of this event, refer here.
// axisMultiLabelRender event: customize or cancel multi-level axis labels at render time.
var chartData = [
{ country: 'USA', gold: 50, silver: 70, bronze: 45 },
{ country: 'China', gold: 40, silver: 60, bronze: 55 },
{ country: 'Japan', gold: 70, silver: 60, bronze: 50 },
{ country: 'Australia', gold: 60, silver: 56, bronze: 40 },
{ country: 'France', gold: 50, silver: 45, bronze: 35 },
{ country: 'Germany', gold: 40, silver: 30, bronze: 22 },
{ country: 'Italy', gold: 40, silver: 35, bronze: 37 },
{ country: 'Sweden', gold: 30, silver: 25, bronze: 27 }
];
var chart = new ej.charts.Chart({
primaryXAxis: {
valueType: 'Category',
// Multi-level labels: two groups by index range
multiLevelLabels: [{
categories: [
// Start and end accept number, date, or string values
{ start: -0.5, end: 3.5, text: 'Half Yearly 1' },
{ start: 3.5, end: 7.5, text: 'Half Yearly 2' }
],
border: { type: 'Rectangle', color: '#BDBDBD', width: 1 },
alignment: 'Center'
}]
},
primaryYAxis: {
title: 'Gold Medals'
},
legendSettings: { visible: false },
title: 'Olympic Medals',
series: [{
dataSource: chartData,
type: 'Column',
xName: 'country',
yName: 'gold',
name: 'Gold'
}],
// axisMultiLabelRender: customize or cancel multi-level labels at render time
axisMultiLabelRender: function (args) {
console.log('Axis MultiLabel Render Event was triggered');
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>multiLevelLabelClick
Triggered when a multi-level axis label segment is clicked. Requires the MultiLevelLabel module (when consuming individual ES5 modules) and multiLevelLabels to be configured on the axis. To know more about the arguments of this event, refer here.
// multiLevelLabelClick: fires when a multi-level label segment is clicked.
var chartData = [
{ country: 'USA', gold: 50, silver: 70, bronze: 45 },
{ country: 'China', gold: 40, silver: 60, bronze: 55 },
{ country: 'Japan', gold: 70, silver: 60, bronze: 50 },
{ country: 'Australia', gold: 60, silver: 56, bronze: 40 },
{ country: 'France', gold: 50, silver: 45, bronze: 35 },
{ country: 'Germany', gold: 40, silver: 30, bronze: 22 },
{ country: 'Italy', gold: 40, silver: 35, bronze: 37 },
{ country: 'Sweden', gold: 30, silver: 25, bronze: 27 }
];
var chart = new ej.charts.Chart({
primaryXAxis: {
valueType: 'Category',
// Multi-level labels: two groups by index range
multiLevelLabels: [{
categories: [
// Start and end accept number, date, or string values
{ start: -0.5, end: 3.5, text: 'Half Yearly 1' },
{ start: 3.5, end: 7.5, text: 'Half Yearly 2' }
],
border: { type: 'Rectangle', color: '#BDBDBD', width: 1 },
alignment: 'Center'
}]
},
primaryYAxis: { title: 'Gold Medals' },
legendSettings: { visible: false },
title: 'Olympic Medals',
series: [{
dataSource: chartData,
type: 'Column',
xName: 'country',
yName: 'gold',
name: 'Gold'
}],
// Fires when a multi-level label segment is clicked
multiLevelLabelClick: function (args) {
console.log('MultiLevel label click event was triggered');
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>Series and Points
seriesRender
Triggered before a series is rendered so you can customize its appearance and properties (for example, fill, opacity, border, width, or columnWidth). To know more about the arguments of this event, refer here.
// seriesRender: customize series appearance before rendering.
var chartData = [
{ country: 'USA', gold: 50, silver: 70, bronze: 45 },
{ country: 'China', gold: 40, silver: 60, bronze: 55 },
{ country: 'Japan', gold: 70, silver: 60, bronze: 50 },
{ country: 'Australia', gold: 60, silver: 56, bronze: 40 },
{ country: 'France', gold: 50, silver: 45, bronze: 35 },
{ country: 'Germany', gold: 40, silver: 30, bronze: 22 },
{ country: 'Italy', gold: 40, silver: 35, bronze: 37 },
{ country: 'Sweden', gold: 30, silver: 25, bronze: 27 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Countries' },
primaryYAxis: { title: 'Medals' },
title: 'Olympic Medals',
selectionMode: 'Point',
series: [
{ dataSource: chartData, type: 'Column', xName: 'country', yName: 'gold', name: 'Gold' },
{ dataSource: chartData, type: 'Column', xName: 'country', yName: 'silver', name: 'Silver' },
{ dataSource: chartData, type: 'Column', xName: 'country', yName: 'bronze', name: 'Bronze' }
],
// Customize series appearance before rendering
seriesRender: function (args) {
console.log('Series render event was triggered');
var palette = ['#f9c74f', '#90be6d', '#577590'];
args.series.fill = palette[args.series.index] || '#7f8c8d';
args.series.opacity = 0.9;
args.series.border = { width: 1, color: '#ffffff' };
args.series.columnWidth = 0.6;
args.series.cornerRadius = { topLeft: 6, topRight: 6 };
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>pointClick
Triggered when a data point or its symbol is clicked. Use this event to perform actions such as highlighting, drilling down, or showing custom details for the selected point. Inspect args.point, args.series, args.pointIndex, and args.seriesIndex for details. To know more about the arguments of this event, refer here.
// pointClick: fires when a data point is clicked.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales',
series: [{
dataSource: chartData,
type: 'Column',
xName: 'month',
yName: 'sales',
name: 'Sales'
}],
// Handle point click actions
pointClick: function (args) {
console.log('Point click event was triggered', {
x: args.point && args.point.x,
y: args.point && args.point.y,
seriesIndex: args.seriesIndex,
pointIndex: args.pointIndex
});
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>pointDoubleClick
Triggered when a data point or its symbol is double-clicked. Use this event for quick-edit workflows, navigation, or toggling detailed views for the target point. To know more about the arguments of this event, refer here.
// pointDoubleClick: fires when a data point is clicked.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales',
series: [{
dataSource: chartData,
type: 'Column',
xName: 'month',
yName: 'sales',
name: 'Sales'
}],
// Handle point click actions
pointDoubleClick: function (args) {
console.log('Point double click event was triggered', {
x: args.point && args.point.x,
y: args.point && args.point.y,
seriesIndex: args.seriesIndex,
pointIndex: args.pointIndex
});
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>pointMove
Triggered when the pointer moves over a data point. Use this event to show contextual UI, update external indicators, or track the hovered point dynamically. To know more about the arguments of this event, refer here.
// pointMove: fires when the pointer moves over a data point.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales',
series: [{
dataSource: chartData,
type: 'Column',
xName: 'month',
yName: 'sales',
name: 'Sales'
}],
// Fires when the pointer moves over a data point
pointMove: function (args) {
console.log('Point Move event was triggered', {
x: args.point && args.point.x,
y: args.point && args.point.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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>pointRender
Triggered before an individual data point is rendered so you can customize its visual properties such as fill, border, shape, size, and corner radius. To know more about the arguments of this event, refer here.
// pointRender: customize each point's appearance before rendering.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales',
series: [{
dataSource: chartData,
type: 'Column',
xName: 'month',
yName: 'sales',
name: 'Sales'
}],
// Highlight the highest value in red and the lowest in green
pointRender: function (args) {
if (typeof args.point.y === 'number') {
var yValues = chartData.map(function (d) { return d.sales; });
var max = Math.max.apply(null, yValues);
var min = Math.min.apply(null, yValues);
if (args.point.y === max) {
args.fill = '#e74c3c';
} else if (args.point.y === min) {
args.fill = '#27ae60';
}
}
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>textRender (Data Labels)
Triggered before a data label is rendered so you can customize label text, style, template, or position. You can also set args.font and args.color to format the label. To know more about the arguments of this event, refer here.
// textRender: customize data labels before they are rendered.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category' },
primaryYAxis: { labelFormat: '${value}K' },
legendSettings: { visible: true },
title: 'Sales Analysis',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales',
// Enable data labels for the series
marker: { visible: true, dataLabel: { visible: true } }
}],
// Axis label render handler
axisLabelRender: function (args) {
if (args.axis.valueType === 'Category' && typeof args.text === 'string') {
if (args.text === 'Aug') {
args.cancel = true; // hide a specific X-axis label
return;
}
args.text = args.text.toUpperCase();
}
if (args.axis.valueType !== 'Category' && typeof args.value === 'number') {
args.text = '$' + args.value + 'K';
}
},
// Customize data labels before they are rendered
textRender: function (args) {
// Example 1: Format label text as currency with K suffix
if (typeof args.point.y === 'number') {
args.text = '$' + args.point.y + 'K';
}
// Example 2: Highlight a particular month's label (e.g., 'Aug')
if (args.point.x === 'Aug') {
args.text = args.text + ' ★';
args.color = '#e74c3c';
args.font = { fontWeight: '700', size: '14px' };
}
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>Data Editing (Drag)
dragStart
Triggered when a data point drag operation begins on a series with dragging enabled (via dragSettings). Requires the DataEditing module (when consuming individual ES5 modules) and the series to have dragSettings.enable = true. Use this event to validate the drag action, apply constraints, or cancel the drag before it proceeds. To know more about the arguments of this event, refer here.
// dragStart event: fires when the user starts dragging a data point.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales (Drag a point to edit)',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales',
// drag along Y only
dragSettings: { enable: true, type: 'Y' }
}],
// Fires when user starts dragging a data point
dragStart: function (args) {
// Inspect available details
console.log('dragStart event was triggered');
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>drag
Triggered continuously while a data point is being dragged. Use this event to provide live feedback, enforce boundaries, or update the UI as the point’s position changes. Requires the DataEditing module when consuming individual ES5 modules. To know more about the arguments of this event, refer here.
// drag event: fires while a data point is being dragged (continuous).
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales (Drag a point to edit)',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales',
// drag along Y only
dragSettings: { enable: true, type: 'Y' }
}],
// Fires while a point is being dragged (continuous)
drag: function (args) {
console.log('Drag event was triggered');
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>dragEnd
Triggered when a data point drag operation completes (pointer released) and the new value is committed. Use this event to persist changes, refresh related UI, or perform post-edit actions. Requires the DataEditing module when consuming individual ES5 modules. To know more about the arguments of this event, refer here.
// dragEnd event: fires when the drag operation completes and the final value is committed.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales (Drag a point to edit)',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales',
// drag along Y only
dragSettings: { enable: true, type: 'Y' }
}],
// Fires when the drag operation completes and the final value is committed
dragEnd: function (args) {
// Persist or process the final value here
console.log('Drag end event was triggered');
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>Tooltip
tooltipRender
Triggered before a tooltip for a point in a single-series tooltip is shown so you can customize content and style. Requires the Tooltip module (when consuming individual ES5 modules) and tooltip.enable = true. To know more about the arguments of this event, refer here.
// tooltipRender: customize the tooltip before it renders.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales',
// Enable tooltip; event will customize the content/style
tooltip: { enable: true, enableAnimation: true, shared: false },
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales'
}],
// Customize tooltip before it renders
tooltipRender: function (args) {
// Append currency formatting to the tooltip text
if (typeof args.text === 'string' && args.point && typeof args.point.y === 'number') {
args.text = args.point.x + ' : $' + args.point.y + 'K';
}
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>sharedTooltipRender
Triggered before a shared tooltip is shown (aggregating multiple series at the same x-value) so you can customize the aggregated content. Requires the Tooltip module (when consuming individual ES5 modules) and tooltip.shared = true. To know more about the arguments of this event, refer here.
// sharedTooltipRender: customize the shared tooltip before it renders.
var chartData = [
{ x: new Date(1975, 0, 1), y: 16, y1: 10, y2: 4.5 },
{ x: new Date(1980, 0, 1), y: 12.5, y1: 7.5, y2: 5 },
{ x: new Date(1985, 0, 1), y: 19, y1: 11, y2: 6.5 },
{ x: new Date(1990, 0, 1), y: 14.4, y1: 7, y2: 4.4 },
{ x: new Date(1995, 0, 1), y: 11.5, y1: 8, y2: 5 },
{ x: new Date(2000, 0, 1), y: 14, y1: 6, y2: 1.5 },
{ x: new Date(2005, 0, 1), y: 10, y1: 3.5, y2: 2.5 },
{ x: new Date(2010, 0, 1), y: 16, y1: 7, y2: 3.7 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'DateTime' },
primaryYAxis: { title: 'Rate (%)' },
title: 'Unemployment Rates 1975-2010',
// Enable shared tooltip
tooltip: { enable: true, shared: true },
series: [
{
dataSource: chartData, type: 'StepLine', xName: 'x', yName: 'y',
width: 2, name: 'China',
marker: { visible: true, width: 10, height: 10 }
},
{ dataSource: chartData, type: 'Column', xName: 'x', yName: 'y1', name: 'USA' }
],
// Customize the shared tooltip before it renders
sharedTooltipRender: function (args) {
console.log('Shared tooltip rendered event was triggered');
// Update the header text
args.headerText = 'Shared Tooltip';
// Customize each line of the shared tooltip text
if (args.text && args.text.length) {
// Example transformation: "China : 16" -> "China value: 16%"
args.text = args.text.map(function (line) {
return line.replace(':', ' value:') + '%';
});
}
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>Legend
legendRender
Triggered before a legend item is rendered so you can customize the legend text, shape, and fill. The shape value must be a valid LegendShape enum value (for example, Circle, Rectangle, Diamond). To know more about the arguments of this event, refer here.
// legendRender: customize legend items before they are rendered.
var chartData = [
{ country: 'USA', gold: 50, silver: 70, bronze: 45 },
{ country: 'China', gold: 40, silver: 60, bronze: 55 },
{ country: 'Japan', gold: 70, silver: 60, bronze: 50 },
{ country: 'Australia', gold: 60, silver: 56, bronze: 40 },
{ country: 'France', gold: 50, silver: 45, bronze: 35 },
{ country: 'Germany', gold: 40, silver: 30, bronze: 22 },
{ country: 'Italy', gold: 40, silver: 35, bronze: 37 },
{ country: 'Sweden', gold: 30, silver: 25, bronze: 27 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Countries' },
primaryYAxis: { minimum: 0, maximum: 80, interval: 20, title: 'Medals' },
legendSettings: { visible: true, position: 'Top' },
title: 'Olympic Medals',
series: [
{ dataSource: chartData, type: 'Column', xName: 'country', yName: 'gold', name: 'Gold' },
{ dataSource: chartData, type: 'Column', xName: 'country', yName: 'silver', name: 'Silver' },
{ dataSource: chartData, type: 'Column', xName: 'country', yName: 'bronze', name: 'Bronze' }
],
// Customize legend items before they are rendered
legendRender: function (args) {
console.log('Legend render event was triggered');
switch (args.text) {
case 'Gold':
args.text = 'Gold (Au)';
args.fill = '#FFC107';
args.shape = 'Circle';
break;
case 'Silver':
args.fill = '#9E9E9E';
args.shape = 'Rectangle';
break;
case 'Bronze':
args.fill = '#CD7F32';
args.shape = 'Diamond';
break;
}
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>legendClick
Triggered when a legend item is clicked. Use this event to filter, isolate, or highlight related data in response to the selection. To know more about the arguments of this event, refer here.
// legendClick: fires when a legend item is clicked.
var chartData = [
{ country: 'USA', gold: 50, silver: 70, bronze: 45 },
{ country: 'China', gold: 40, silver: 60, bronze: 55 },
{ country: 'Japan', gold: 70, silver: 60, bronze: 50 },
{ country: 'Australia', gold: 60, silver: 56, bronze: 40 },
{ country: 'France', gold: 50, silver: 45, bronze: 35 },
{ country: 'Germany', gold: 40, silver: 30, bronze: 22 },
{ country: 'Italy', gold: 40, silver: 35, bronze: 37 },
{ country: 'Sweden', gold: 30, silver: 25, bronze: 27 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Countries' },
primaryYAxis: { minimum: 0, maximum: 80, interval: 20, title: 'Medals' },
legendSettings: { visible: true, position: 'Top' },
title: 'Olympic Medals',
series: [
{ dataSource: chartData, type: 'Column', xName: 'country', yName: 'gold', name: 'Gold' },
{ dataSource: chartData, type: 'Column', xName: 'country', yName: 'silver', name: 'Silver' },
{ dataSource: chartData, type: 'Column', xName: 'country', yName: 'bronze', name: 'Bronze' }
],
// Fires when a legend item is clicked
legendClick: function (args) {
console.log('legendClick:', {
legendText: args.legendText,
seriesIndex: args.series && args.series.index,
isVisible: args.series && args.series.visible
});
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>Annotations
annotationRender
Triggered before each chart annotation is rendered so you can customize or cancel it. Requires the ChartAnnotation module (when consuming individual ES5 modules) and an annotations configuration on the chart. To know more about the arguments of this event, refer here.
// annotationRender event: customize or cancel annotations before they render.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category' },
primaryYAxis: { labelFormat: '${value}K' },
title: 'Sales Analysis',
// Define an annotation at the peak data point (Aug, 55)
annotations: [{
content: '<div class="anno">Peak</div>',
x: 'Aug',
y: 55,
coordinateUnits: 'Point',
region: 'Chart'
}],
series: [{
type: 'Line',
name: 'Sales',
xName: 'month',
yName: 'sales',
marker: { visible: true },
dataSource: chartData
}],
// Customize or cancel annotation before it renders
annotationRender: function (args) {
console.log('Annotation render event was triggered');
if (args.content instanceof HTMLElement) {
args.content.style.padding = '4px 8px';
args.content.style.background = '#ffeb3b';
args.content.style.color = '#000';
args.content.style.borderRadius = '4px';
args.content.style.boxShadow = '0 1px 3px rgba(0,0,0,0.2)';
args.content.style.fontWeight = '600';
}
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>Zooming and Scrolling
onZooming
Triggered during zoom or pan interactions, providing per-axis zoom information that can be modified or canceled. Requires the Zoom module (when consuming individual ES5 modules) and zoomSettings to be configured on the chart. To know more about the arguments of this event, refer here.
// onZooming: fires when the zoom selection starts.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category' },
primaryYAxis: { labelFormat: '${value}K' },
legendSettings: { visible: true },
title: 'Sales Analysis',
// Enable zooming (selection zooming on X-axis)
zoomSettings: { enableSelectionZooming: true, enablePan: true, mode: 'X' },
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales',
marker: { dataLabel: { visible: true } }
}],
// Fires when the zoom selection starts
onZooming: function (args) {
console.log('Zoom selection started event was triggered', args);
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>zoomComplete
Triggered after a zoom or pan action completes for an axis. Requires the Zoom module (when consuming individual ES5 modules) and zoomSettings to be configured on the chart. To know more about the arguments of this event, refer here.
// zoomComplete: fires after the zoom selection is completed.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category' },
primaryYAxis: { labelFormat: '${value}K' },
legendSettings: { visible: true },
title: 'Sales Analysis',
// Enable zooming (selection zooming on X-axis)
zoomSettings: { enableSelectionZooming: true, enablePan: true, mode: 'X' },
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales',
marker: { dataLabel: { visible: true } }
}],
// Fires after the zoom selection is completed
zoomComplete: function (args) {
console.log('Zoom complete event was triggered');
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>scrollChanged
Triggered during scrollbar interactions to indicate visible range or zoom changes. Requires the ScrollBar module (when consuming individual ES5 modules) and scrollbarSettings.enable = true on the axis. To know more about the arguments of this event, refer here.
// scrollChanged: fires whenever the axis scrollbar position or range changes.
// Generate enough points so the scrollbar is useful
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
var chartData = [];
for (var i = 0; i < 60; i++) {
chartData.push({
month: months[i % 12] + ' ' + (2022 + Math.floor(i / 12)),
sales: Math.floor(20 + Math.random() * 40)
});
}
var chart = new ej.charts.Chart({
// Enable axis scrollbar
primaryXAxis: {
valueType: 'Category',
scrollbarSettings: { enable: true },
labelIntersectAction: 'Rotate45'
},
primaryYAxis: { labelFormat: '${value}K' },
legendSettings: { visible: true },
title: 'Sales Analysis',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales',
marker: { dataLabel: { visible: true } }
}],
// Fires whenever the axis scrollbar position/range changes
scrollChanged: function (args) {
console.log('scroll changed event was triggered');
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>scrollStart
Triggered when a scrollbar interaction begins. Use this event to capture the previous range before the user changes the viewport, or to apply initial constraints when scrolling starts. Requires the ScrollBar module (when consuming individual ES5 modules) and scrollbarSettings.enable = true on the axis. To know more about the arguments of this event, refer here.
// scrollStart: fires when the scrollbar interaction starts.
var chartData = [
{ 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 }
];
function rangeInfo(args) {
var c = args.currentRange || {};
var p = args.previousRange || {};
return {
axis: args.axis && args.axis.name,
current: { start: c.minimum, end: c.maximum },
previous: { start: p.minimum, end: p.maximum }
};
}
var chart = new ej.charts.Chart({
// Enable scrollbar on the X axis
primaryXAxis: {
valueType: 'Category',
scrollbarSettings: { enable: true }
},
primaryYAxis: { labelFormat: '${value}K' },
legendSettings: { visible: true },
title: 'Sales Analysis',
// Enable zooming (selection, mouse wheel, pinch) on X-axis
zoomSettings: {
enableSelectionZooming: true,
enableMouseWheelZooming: true,
enablePinchZooming: true,
enableDeferredZooming: false,
mode: 'X' // Zoom horizontally; use 'XY' to allow both axes
},
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales',
marker: { dataLabel: { visible: true } }
}],
// Fires when the scrollbar interaction starts
scrollStart: function (args) {
console.log('Scroll started:', rangeInfo(args));
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>scrollEnd
Triggered when a scrollbar interaction ends and the new viewport range is committed. Use this event to persist the visible range or to refresh related UI. Requires the ScrollBar module (when consuming individual ES5 modules) and scrollbarSettings.enable = true on the axis. To know more about the arguments of this event, refer here.
// scrollEnd: fires when the scrollbar interaction ends.
var chartData = [
{ 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 }
];
function rangeInfo(args) {
var c = args.currentRange || {};
var p = args.previousRange || {};
return {
axis: args.axis && args.axis.name,
current: { start: c.minimum, end: c.maximum },
previous: { start: p.minimum, end: p.maximum }
};
}
var chart = new ej.charts.Chart({
// Enable scrollbar on the X axis
primaryXAxis: {
valueType: 'Category',
scrollbarSettings: { enable: true }
},
primaryYAxis: { labelFormat: '${value}K' },
legendSettings: { visible: true },
title: 'Sales Analysis',
// Enable zooming (selection, mouse wheel, pinch) on X-axis
zoomSettings: {
enableSelectionZooming: true,
enableMouseWheelZooming: true,
enablePinchZooming: true,
enableDeferredZooming: false,
mode: 'X' // Zoom horizontally; use 'XY' to allow both axes
},
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales',
marker: { dataLabel: { visible: true } }
}],
// Fires when the scrollbar interaction ends
scrollEnd: function (args) {
console.log('Scroll end', rangeInfo(args));
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>Selection and Drag
dragComplete
Triggered after a drag-selection area or zoom region is completed. Requires the Selection module (when consuming individual ES5 modules) and selectionMode to be set to a drag-based value (for example, DragXY, DragX, or DragY). To know more about the arguments of this event, refer here.
// dragComplete event: fires when the drag selection operation completes.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales',
selectionMode: 'DragXY',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales'
}],
// Handler for drag selection completion
dragComplete: function (args) {
console.log('onDragComplete event was triggered');
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>selectionComplete
Triggered after a selection action (by click or drag) completes. Requires the Selection module (when consuming individual ES5 modules) and selectionMode to be set to a value that enables selection (for example, Point, Series, Cluster, DragXY). To know more about the arguments of this event, refer here.
// selectionComplete: fires after the selection is completed.
var chartData = [
{ country: 'USA', gold: 50, silver: 70, bronze: 45 },
{ country: 'China', gold: 40, silver: 60, bronze: 55 },
{ country: 'Japan', gold: 70, silver: 60, bronze: 50 },
{ country: 'Australia', gold: 60, silver: 56, bronze: 40 },
{ country: 'France', gold: 50, silver: 45, bronze: 35 },
{ country: 'Germany', gold: 40, silver: 30, bronze: 22 },
{ country: 'Italy', gold: 40, silver: 35, bronze: 37 },
{ country: 'Sweden', gold: 30, silver: 25, bronze: 27 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Countries' },
title: 'Olympic Medals',
selectionMode: 'Point',
series: [
{ dataSource: chartData, type: 'Column', xName: 'country', yName: 'gold', name: 'Gold' },
{ dataSource: chartData, type: 'Column', xName: 'country', yName: 'silver', name: 'Silver' },
{ dataSource: chartData, type: 'Column', xName: 'country', yName: 'bronze', name: 'Bronze' }
],
// Fires after the selection is completed
selectionComplete: function (args) {
console.log('Selection Complete event was triggered');
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>Mouse Events
chartMouseDown
Triggered when a mouse down action occurs over the chart area. To know more about the arguments of this event, refer here.
// chartMouseDown event: fires on mouse down within the chart area.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales'
}],
// chartMouseDown: fires on mouse down within the chart area
chartMouseDown: function (args) {
console.log('chartMouseDown:', {
target: args.target,
x: args.x,
y: args.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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>chartMouseMove
Triggered when the mouse moves over the chart area. To know more about the arguments of this event, refer here.
// chartMouseMove event: fires on mouse move within the chart area.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales'
}],
// chartMouseMove: fires on mouse move within the chart area
chartMouseMove: function (args) {
console.log('chartMouseMove:', {
target: args.target,
x: args.x,
y: args.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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>chartMouseUp
Triggered when a mouse up action occurs over the chart area. To know more about the arguments of this event, refer here.
// chartMouseUp event: fires on mouse up within the chart area.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales'
}],
// chartMouseUp: fires on mouse up within the chart area
chartMouseUp: function (args) {
console.log('chartMouseUp:', { target: args.target, x: args.x, y: args.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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>chartMouseLeave
Triggered when the mouse leaves the chart area. To know more about the arguments of this event, refer here.
// chartMouseLeave event: fires when the mouse leaves the chart area.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales'
}],
// chartMouseLeave: fires when the mouse leaves the chart area
chartMouseLeave: function (args) {
console.log('chartMouseLeave:', {
target: args.target,
x: args.x,
y: args.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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>chartMouseClick
Triggered when a mouse click occurs within the chart area (axes, series, legend, tooltip, etc.). To know more about the arguments of this event, refer here.
// chartMouseClick event: fires on any click within the chart area.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales'
}],
// chartMouseClick: fires on any click within the chart area (axes, series, legend, tooltip, etc.)
chartMouseClick: function (args) {
console.log('chartMouseClick:', {
target: args.target,
x: args.x,
y: args.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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>chartDoubleClick
Triggered when a double-click occurs within the chart area. Use this event to reset zoom, toggle modes, or open detailed panels based on the double-click location. To know more about the arguments of this event, refer here.
// chartDoubleClick event: fires on a double-click within the chart area.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales'
}],
// chartDoubleClick: fires on a double-click within the chart area
chartDoubleClick: function (args) {
console.log('chartDoubleClick:', {
target: args.target,
x: args.x,
y: args.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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>Life cycle and Layout
load
Triggered before the chart starts initial rendering. Use this event to set themes, localization, palettes, or modify chart/series properties programmatically prior to rendering. To know more about the arguments of this event, refer here.
// load: fires before the chart is rendered in the DOM.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales'
}],
// Fires before the chart is rendered
load: function (args) {
console.log('Chart load event triggered');
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>loaded
Triggered after the chart is fully loaded and initial rendering is complete. To know more about the arguments of this event, refer here.
// loaded: fires after the chart is rendered in the DOM.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category', title: 'Month' },
primaryYAxis: { title: 'Sales' },
title: 'Monthly Sales',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales'
}],
// Fires after the chart is rendered in the DOM
loaded: function (args) {
var element = args.chart && args.chart.element;
var bbox = element && element.getBoundingClientRect();
console.log('Chart loaded:', {
title: args.chart && args.chart.title,
width: bbox && bbox.width,
height: bbox && bbox.height
});
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>beforeResize
Triggered before a resize is performed; you can cancel the subsequent resize by setting args.cancel = true. To know more about the arguments of this event, refer here.
// beforeResize event: fires before the chart starts its resize re-layout.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: {
valueType: 'Category'
},
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales'
}],
// beforeResize event: fires before the chart starts its resize re-layout
beforeResize: function (args) {
console.log('beforeResize:', {
currentSize: args.currentSize,
previousSize: args.previousSize
});
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>resized
Triggered after the chart has been resized. To know more about the arguments of this event, refer here.
// resized: fires after the chart completes resizing.
var chartData = [
{ 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 }
];
var chart = new ej.charts.Chart({
primaryXAxis: { valueType: 'Category' },
primaryYAxis: { labelFormat: '${value}K' },
legendSettings: { visible: true },
title: 'Sales Analysis',
series: [{
dataSource: chartData,
type: 'Line',
xName: 'month',
yName: 'sales',
name: 'Sales',
marker: { dataLabel: { visible: true } }
}],
// Fires after the chart completes resizing
resized: function (args) {
console.log('Chart resized:', {
currentSize: args.currentSize,
previousSize: args.previousSize
});
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>beforePrint
Triggered before the chart is printed, providing access to the HTML content being printed via args.htmlContent. Use this to add watermarks, headers/footers, or to modify the cloned chart element before printing. To know more about the arguments of this event, refer here.
// beforePrint event: customize what gets printed.
var chartData = [
{ x: 2005, y: 28 }, { x: 2006, y: 25 }, { x: 2007, y: 26 }, { x: 2008, y: 27 },
{ x: 2009, y: 32 }, { x: 2010, y: 35 }, { x: 2011, y: 30 }
];
var chart = new ej.charts.Chart({
title: 'Efficiency of oil-fired power production',
primaryXAxis: {
title: 'Year',
coefficient: 90,
minimum: 2004,
maximum: 2012,
interval: 1
},
primaryYAxis: {
minimum: 20,
maximum: 40,
interval: 5,
title: 'Efficiency',
labelFormat: '{value}%'
},
series: [{
dataSource: chartData,
type: 'Radar',
xName: 'x',
yName: 'y',
drawType: 'Line'
}],
// beforePrint: customize what gets printed
beforePrint: function (args) {
// Clone the chart element so we can safely modify the print content
console.log('before print event was triggered');
var chartElement = document.getElementById('element');
var cloned = chartElement ? chartElement.cloneNode(true) : undefined;
if (!cloned) { return; }
// Example: add a simple watermark to the print content
var watermark = document.createElement('div');
watermark.textContent = 'CONFIDENTIAL';
Object.assign(watermark.style, {
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%) rotate(-30deg)',
color: 'rgba(0,0,0,0.15)',
fontSize: '48px',
fontWeight: '700',
pointerEvents: 'none',
zIndex: '1',
whiteSpace: 'nowrap'
});
// Wrap cloned chart and overlay watermark
var wrapper = document.createElement('div');
Object.assign(wrapper.style, { position: 'relative' });
wrapper.appendChild(cloned);
wrapper.appendChild(watermark);
args.htmlContent = wrapper;
}
}, '#element');
// Trigger print via the Print button in the page
var printBtn = document.getElementById('print');
if (printBtn) {
printBtn.addEventListener('click', function () {
chart.print();
});
}<!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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<button id="print">Print</button>
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>beforeExport
Triggered before a chart export operation begins (such as exporting to PNG, JPEG, SVG, or PDF), allowing you to customize fileName, export type, page settings, theme, or cancel the export. Requires the Export module when consuming individual ES5 modules. To know more about the arguments of this event, refer here.
// beforeExport event: customize export settings before the export happens.
var chartData = [
{ x: 2005, y: 28 }, { x: 2006, y: 25 }, { x: 2007, y: 26 },
{ x: 2008, y: 27 }, { x: 2009, y: 32 }, { x: 2010, y: 35 }, { x: 2011, y: 30 }
];
var chart = new ej.charts.Chart({
title: 'Efficiency of oil-fired power production',
primaryXAxis: {
title: 'Year',
coefficient: 90,
minimum: 2004,
maximum: 2012,
interval: 1
},
primaryYAxis: {
minimum: 20,
maximum: 40,
interval: 5,
title: 'Efficiency',
labelFormat: '{value}%'
},
series: [{
dataSource: chartData,
type: 'Radar',
xName: 'x',
yName: 'y',
drawType: 'Line'
}],
loaded: function (args) {
// Trigger an export after chart load (for demo)
// Exports as PNG; beforeExport will be raised just before this export executes
args.chart.exportModule.export('PNG', 'export');
},
// beforeExport event handler to customize export settings
beforeExport: function (args) {
console.log('before export event was triggered');
// Customize export settings before the export happens
args.fileName = 'custom-export';
args.width = 800; // exported image/PDF width
args.height = 600; // exported image/PDF height
args.orientation = 'Landscape'; // for PDF exports
args.theme = 'MaterialDark'; // apply export theme
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>afterExport
Triggered after a chart export operation completes. Use this event to perform post-export actions such as notifications, logging, or initiating downloads in custom flows. Requires the Export module when consuming individual ES5 modules. To know more about the arguments of this event, refer here.
// afterExport event: fires after a chart export operation completes.
var chartData = [
{ x: 2005, y: 28 }, { x: 2006, y: 25 }, { x: 2007, y: 26 },
{ x: 2008, y: 27 }, { x: 2009, y: 32 }, { x: 2010, y: 35 }, { x: 2011, y: 30 }
];
var chart = new ej.charts.Chart({
// Chart title
title: 'Efficiency of oil-fired power production',
primaryXAxis: {
title: 'Year',
coefficient: 90,
minimum: 2004,
maximum: 2012,
interval: 1
},
primaryYAxis: {
minimum: 20,
maximum: 40,
interval: 5,
title: 'Efficiency',
labelFormat: '{value}%'
},
series: [{
dataSource: chartData,
type: 'Radar',
xName: 'x',
yName: 'y',
drawType: 'Line'
}],
loaded: function (args) {
// Trigger an export after the chart loads (for demo)
args.chart.exportModule.export('PNG', 'export');
},
// afterExport event handler - invoked after export completes
afterExport: function (args) {
// Common post-export tasks: notify user, log, or use returned data
console.log('Chart after export event was triggered', args);
}
}, '#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://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>Troubleshooting
-
Event does not fire — Make sure the relevant module is available; when loading individual ES5 modules instead of the full CDN bundle, inject the module with
Chart.Inject(for example,Tooltipfor tooltip events,Zoomfor zoom events,Selectionfor selection events,DataEditingfor drag-to-edit events). -
args.cancelhas no effect — Only events that explicitly mention cancellation in the API reference supportargs.cancel. For example,beforeResizesupports cancellation, butloadeddoes not. -
tooltipRenderdoes not fire — Tooltip events only fire whentooltip.enable = true.sharedTooltipRenderadditionally requirestooltip.shared = true. -
onZooming/zoomCompletedo not fire — ConfigurezoomSettingsand ensureenableSelectionZooming,enableMouseWheelZooming, orenablePinchZoomingis set totrue. -
selectionComplete/dragCompletedo not fire — SetselectionModeto a value other thanNone(for example,Point,Series,Cluster,DragXY). -
dragStart/drag/dragEnddo not fire — The series must havedragSettings.enable = trueand theDataEditingmodule must be available (inject it withChart.Injectwhen loading individual ES5 modules). -
scrollChanged/scrollStart/scrollEnddo not fire — Enable the scrollbar on the axis (scrollbarSettings.enable = true) and make sure theScrollBarmodule is available (inject it withChart.Injectwhen loading individual ES5 modules).