Appearance in Circular Gauge Control
19 Jun 202410 minutes to read
Gauge Title
Circular gauge can be given a title by using title property, to show the information about the gauge. Title can be customized by using titleStyle property in gauge.
@using Syncfusion.EJ2;
@Html.EJS().CircularGauge("circular2").Title("Speedometer").TitleStyle(ts => ts.Color("#27d5ff")).Render()
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();
}
}
}
Gauge Position
Gauge can be positioned anywhere in the container with the help of centerX and centerY property and it accepts values either in percentage or in pixels. The default value of the centerX and centerY property is 50%, which means gauge will get rendered to the centre of the container.
In Pixel
You can set the mid point of the gauge in pixel as demonstrated below,
@using Syncfusion.EJ2;
@Html.EJS().CircularGauge("circular2").CenterX("20").CenterY("20").Axes(axis => axis.LineStyle(ls => ls.Color("#F8F8F8").Width(2)).StartAngle(0).EndAngle(180).Add()).Render()
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();
}
}
}
In Percentage
By setting the value in percentage, gauge gets its mid point with respect to its plot area. For example, when the centerX value as ‘0%’ and centerY value is ‘50%’, gauge will get positioned at the top left corner of the plot area.
@using Syncfusion.EJ2;
@Html.EJS().CircularGauge("circular2").CenterX("10%").CenterY("50%").Axes(axis => axis.LineStyle(ls => ls.Color("#F8F8F8").Width(2)).StartAngle(0).EndAngle(180).Add()).Render()
using Microsoft.AspNetCore.Mvc;
namespace EJ2_Core_Application.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
}
}
Area Customization
Customize the gauge background
Using background and border properties, you can change the background color and border of the circular gauge.
@using Syncfusion.EJ2;
@Html.EJS().CircularGauge("circular").Background("skyblue").Border(border =>border.Width(2).Color("#FF0000")).Axes(axis => axis
.Radius("90 %").Maximum(120).StartAngle(230).EndAngle(130).LineStyle(ls =>ls.Width(2)).MajorTicks(mt =>mt.Width(1).Color("#8c8c8c"))
.MinorTicks(mi => mi.Color("#8c8c8c").Width(1)).Add()).Render()
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;
using Syncfusion.EJ2.CircularGauge;
namespace EJ2_Core_Application.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
List<CircularGaugePointer> pointers = new List<CircularGaugePointer>();
CircularGaugePointer pointer1 = new CircularGaugePointer();
pointer1.Value = 60;
pointer1.Radius = "60%";
pointers.Add(pointer1);
ViewBag.pointers = pointers;
List<CircularGaugeRange> ranges = new List<CircularGaugeRange>();
CircularGaugeRange range1 = new CircularGaugeRange();
range1.Start = 0;
range1.End = 70;
range1.Radius = "110%";
range1.StartWidth = "10";
ranges.Add(range1);
CircularGaugeRange range2 = new CircularGaugeRange();
range2.Start = 70;
range2.End = 110;
range2.Radius = "110%";
range2.StartWidth = "10";
ranges.Add(range2);
CircularGaugeRange range3 = new CircularGaugeRange();
range3.Start = 110;
range3.End = 120;
range3.Radius = "110%";
range3.StartWidth = "10";
ranges.Add(range3);
ViewBag.ranges = ranges;
return View();
}
}
}
Gauge Margin
You can set margin for gauge from its container through margin property.
@using Syncfusion.EJ2;
@Html.EJS().CircularGauge("circular").Margin(margin => margin
.Bottom(40).Left(40).Right(40).Top(40)).Background("skyblue").Border(border =>border.Width(2).Color("#FF0000")).Axes(axis => axis
.Radius("90 %").Maximum(120).StartAngle(230).EndAngle(130).LineStyle(ls =>ls.Width(2)).MajorTicks(mt =>mt.Width(1).Color("#8c8c8c"))
.MinorTicks(mi => mi.Color("#8c8c8c").Width(1)).Add()).Render()
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;
using Syncfusion.EJ2.CircularGauge;
namespace EJ2_Core_Application.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
List<CircularGaugePointer> pointers = new List<CircularGaugePointer>();
CircularGaugePointer pointer1 = new CircularGaugePointer();
pointer1.Value = 60;
pointer1.Radius = "60%";
pointers.Add(pointer1);
ViewBag.pointers = pointers;
List<CircularGaugeRange> ranges = new List<CircularGaugeRange>();
CircularGaugeRange range1 = new CircularGaugeRange();
range1.Start = 0;
range1.End = 70;
range1.Radius = "110%";
range1.StartWidth = "10";
ranges.Add(range1);
CircularGaugeRange range2 = new CircularGaugeRange();
range2.Start = 70;
range2.End = 110;
range2.Radius = "110%";
range2.StartWidth = "10";
ranges.Add(range2);
CircularGaugeRange range3 = new CircularGaugeRange();
range3.Start = 110;
range3.End = 120;
range3.Radius = "110%";
range3.StartWidth = "10";
ranges.Add(range3);
ViewBag.ranges = ranges;
return View();
}
}
}
Radius calculation based on angles
Render semi or quarter circular gauges by modifying the start and end angles. By enabling the radius based on angle option, the radius of circular gauge will be calculated based on the start and end angles to avoid excess white space.
@using Syncfusion.EJ2;
@Html.EJS().CircularGauge("circular2").MoveToCenter(true).Axes(axis => axis.LineStyle(ls => ls.Color("#F8F8F8").Width(2)).StartAngle(0).EndAngle(180).Add()).Render()
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();
}
}
}
NOTE