Search results

Appearance

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.

razor
title.cs
@using Syncfusion.EJ2;
@Html.EJS().CircularGauge("circular2").Title("Speedometer").TitleStyle(new
{
    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,

razor
position.cs
@using Syncfusion.EJ2;
@Html.EJS().CircularGauge("circular2").CenterX("10%").CenterY("50%").Axes(axis => axis.LineStyle(new
{
    width = 2,
    color = "#F8F8F8"

}).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.

razor
position-percentage.cs
@using Syncfusion.EJ2;
@Html.EJS().CircularGauge("circular2").CenterX("20").CenterY("20").Axes(axis=>axis.LineStyle(new
{
    width = 2,
    color = "#F8F8F8"

}).StartAngle(90).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();
        }
    }
}

Area Customization

Customize the gauge background

Using background and border properties, you can change the background color and border of the circular gauge.

razor
area-customization.cs
@using Syncfusion.EJ2;
@Html.EJS().CircularGauge("circular2").Background("skyblue").Border(new
{
    width = 2,
    color = "#FF0000"
}).Axes(axis => axis.Radius("90%").Maximum(120).StartAngle(230).EndAngle(130).LineStyle(new {
    width = 2
}).MajorTicks(new
{
    width = 1,
    color = "#8c8c8c"
}).MinorTicks(new
{
    width = 1,
    color = "#8c8c8c"
}).Ranges(ViewBag.ranges).Pointers(ViewBag.pointers).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.

razor
margin.cs
@using Syncfusion.EJ2;
@Html.EJS().CircularGauge("circular").Margin(new {
    left= 40,
    right= 40,
    top= 40,
    bottom= 40
}).Background("skyblue").Border(new
{
    width = 2,
    color = "#FF0000"
}).Axes(axis => axis.Radius("90%").Maximum(120).StartAngle(230).EndAngle(130).LineStyle(new {
    width = 2
}).MajorTicks(new
{
    width = 1,
    color = "#8c8c8c"
}).MinorTicks(new
{
    width = 1,
    color = "#8c8c8c"
}).Ranges(ViewBag.ranges).Pointers(ViewBag.pointers).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();
        }
    }
}