Appearance in Circular Gauge Control

19 Dec 202210 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;

<ejs-circulargauge id="circular" title="Speedometer">
    <e-circulargauge-titlestyle color="red"></e-circulargauge-titlestyle>
</ejs-circulargauge>

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;

<ejs-circulargauge id="circular" centerX="20" centerY="50">
    <e-circulargauge-axes>
        <e-circulargauge-axis startAngle="0" endAngle="180">
            <e-axis-linestyle color="#F8F8F8" width="2"></e-axis-linestyle>
        </e-circulargauge-axis>
    </e-circulargauge-axes>
</ejs-circulargauge>

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;

<ejs-circulargauge id="circular" centerX="10%" centerY="50%">
    <e-circulargauge-axes>
        <e-circulargauge-axis startAngle="0" endAngle="180">
            <e-axis-linestyle color="#F8F8F8" width="2"></e-axis-linestyle>
        </e-circulargauge-axis>
    </e-circulargauge-axes>
</ejs-circulargauge>

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;

<ejs-circulargauge id="circular" background="skyblue">
    <e-circulargauge-border color="#FF0000" width="2"></e-circulargauge-border>
        <e-circulargauge-axes>
            <e-circulargauge-axis radius="90%" maximum="120" startAngle="230" endAngle="130"></e-circulargauge-axis>
        </e-circulargauge-axes>
</ejs-circulargauge>
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;

<ejs-circulargauge id="circular" background="skyblue">
    <e-circulargauge-border color="#FF0000" width="2"></e-circulargauge-border>
    <e-circulargauge-margin left="40" right="40" bottom="40" top="40"></e-circulargauge-margin>
    <e-circulargauge-axes>
        <e-circulargauge-axis radius="90%" maximum="120" startAngle="230" endAngle="130"></e-circulargauge-axis>
    </e-circulargauge-axes>
</ejs-circulargauge>
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;

<ejs-circulargauge id="circular" background="skyblue" moveToCenter="true">
    <e-circulargauge-axes>
        <e-circulargauge-axis startAngle="270" endAngle="90"></e-circulargauge-axis>
    </e-circulargauge-axes>
</ejs-circulargauge>

NOTE

View Sample in GitHub.