Contact Support
Animation in Circular Gauge component
19 Jun 20243 minutes to read
All of the elements in the Circular 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 Circular Gauge is enabled when the AnimationDuration
property is set to an appropriate value in milliseconds, providing a smooth rendering effect for the component. If the AnimationDuration
property is set to 0, which is the default value, the animation effect is disabled. If the animation is enabled, the component will behave in the following order.
- The axis line will be animated in the rendering direction (clockwise or anticlockwise).
- Each tick line and label will then be animated.
- If available, ranges will be animated.
- If available, pointers will be animated in the same way as pointer animation.
- If available, annotations will be animated.
The animation of the Circular Gauge is demonstrated in the following example.
@using Syncfusion.EJ2;
@using Syncfusion.EJ2.CircularGauge;
@Html.EJS().CircularGauge("container").AnimationDuration(2000).Load("gaugeLoad").Background("transparent").Axes(axes => axes
.Radius("80%").StartAngle(230).EndAngle(130).LabelStyle(labelStyle => labelStyle.Position(Position.Inside).Font(font => font.FontFamily("inherit")).Offset(-1))
.Annotations(annotation => annotation.Content("<div style='font-size:18px;margin-left: -20px;margin-top: -12px; color:#9DD55A'>60</div>").ZIndex("1").Angle(165).Radius("35%").Add())
.Pointers(pointer => pointer.Value(60).Radius("60%").PointerWidth(7).Color("#c06c84").Animation(animation => animation.Enable(true).Duration(2000)).Cap(cap => cap.Radius(8).Color("#c06c84").Border(border => border.Width(0))).NeedleTail(needleTail => needleTail.Length("0%")).Add())
.Ranges(range => range.Start(0).End(30).StartWidth(22).EndWidth(22).Color("#E63B86").Radius("60%").Add())
.LineStyle(lineStyle => lineStyle.Width(8).Color("#E0E0E0"))
.MinorTicks(minorTick => minorTick.Offset(5)).MajorTicks(majorTick => majorTick.Offset(5)).Add()).Render()
<script>
var rangeLinearGradient = {
startValue: '0%',
endValue: '100%',
colorStop: [
{ color: '#9e40dc', offset: '0%', opacity: 1 },
{ color: '#d93c95', offset: '70%', opacity: 1 },
],
};
window.gaugeLoad = function (args) {
args.gauge.axes[0].ranges[0].linearGradient = rangeLinearGradient;
}
</script>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EJ2_Core_Application.Models;
using Newtonsoft.Json;
namespace EJ2_Core_Application.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
}
}
Only the pointer of the Circular Gauge can be animated individually, not the axis lines, ticks, labels, ranges, and annotations. You can refer this link to enable only pointer animation.