Contact Support
Animation in EJ2 TypeScript Linear Gauge control
26 Dec 20236 minutes to read
All of the elements in the Linear Gauge, such as the axis lines, ticks, labels, ranges, pointers, and annotations, can be animated sequentially by using the animationDuration property. The animation for the Linear Gauge is enabled when the animationDuration
property is set to an appropriate value in milliseconds, providing a smooth rendering effect for the control. If the animationDuration
property is set to 0, which is the default value, the animation effect is disabled. If the animation is enabled, the control will behave in the following order.
- The axis line, ticks, labels, and ranges will all be animated at the same time.
- If available, pointers will be animated in the same way as pointer animation.
- If available, annotations will be animated.
The animation of the Linear Gauge is demonstrated in the following example.
import { LinearGauge, Annotations } from '@syncfusion/ej2-lineargauge';
LinearGauge.Inject(Annotations);
let gauge: LinearGauge = new LinearGauge({
animationDuration: 3000,
orientation: 'Horizontal',
axes: [
{
pointers: [
{
value: 10,
height: 15,
width: 15,
placement: 'Near',
offset: -38,
markerType: 'Triangle',
},
],
ranges: [
{
start: 0,
end: 50,
startWidth: 10,
endWidth: 10,
color: '#F45656',
offset: 35,
},
],
majorTicks: {
interval: 10,
height: 20,
color: '#9E9E9E',
},
minorTicks: {
interval: 2,
height: 10,
color: '#9E9E9E',
},
labelStyle: {
offset: 48,
font: {
fontFamily: 'inherit',
},
},
},
],
annotations: [
{
content:
'<div id="pointer" style="width:70px;margin-left:-3%;margin-top: 21%;font-size:16px;">10 MPH</div>',
axisIndex: 0,
axisValue: 10,
x: 10,
y: -70,
zIndex: '1',
},
],
});
gauge.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>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
Only the pointer of the Linear Gauge can be animated individually, not the axis lines, ticks, labels, ranges, and annotations. You can refer this link to enable only pointer animation.