Search results

Pointers in ASP.NET MVC Linear Gauge control

Pointers are used to indicate values on the axis. Value of the pointer can be modified using the value property.

razor
pointers.cs
@using Syncfusion.EJ2;
@Html.EJS().LinearGauge("linear").Load("gaugeLoad").Render()
<script>
    window.gaugeLoad = function (args) {
        var axis = args.gauge.axes[0];
        axis.pointers = [{
            value: 80

        }]
    }
</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;
using Syncfusion.EJ2.Charts;
using Syncfusion.EJ2.LinearGauge;


namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {

            return View();
        }
    }
}

Types of pointer

The Linear Gauge supports the following two types of pointers:

  • Bar
  • Marker

You can choose any one of the pointer by using type property.

Marker Pointer

A marker pointer is a shape, that can be placed to mark the pointer value in the linear gauge.

Types of marker shapes

The following marker types are available in linear gauge. You can change the marker shape using markerType property in pointer options. The available marker types are,

  • Circle
  • Rectangle
  • Triangle
  • InvertedTriangle
  • Diamond

You can also use image instead of rendering shape as pointer. It can be achieved by using markerType property as Image set image path to ‘imageUrl’ in pointer.

razor
marker-pointer.cs
@using Syncfusion.EJ2;
@Html.EJS().LinearGauge("linear").Load("gaugeLoad").Render()
<script>
    window.gaugeLoad = function (args) {
        var axis = args.gauge.axes[0];
        axis.pointers = [{
            value: 80,
            type: 'Marker',
            markerType: 'Circle'
        }]
    }
</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;
using Syncfusion.EJ2.Charts;
using Syncfusion.EJ2.LinearGauge;


namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {

            return View();
        }
    }
}

Marker Pointer Customization

The marker can be customized by using the following properties.

  • height - Specifies pointer height
  • width - Specifies pointer width
  • color - Specifies pointer color
  • placement - Specifies pointer placement position, available placement options are ‘Near’, ‘Far’, ‘Center’ and ‘None’
  • offset - Specifies offset value from it default position.
  • animationDuration - Specifies pointer animation duration
  • border - Specifies pointer border color and width
razor
@using Syncfusion.EJ2;
@Html.EJS().LinearGauge("linear").Load("gaugeLoad").Render()
<script>
    window.gaugeLoad = function (args) {
        var axis = args.gauge.axes[0];
        axis.pointers = [{
            value: 80,
            markerType: 'Circle',
            height: 15,
            width: 15,
            color: '#cd41f4'
        }]
    }
</script>

Bar Pointer

Bar pointer is used to track the axis value and it will render depending upon the container type. Bar pointer starts from the beginning of the gauge and ends at the pointer value.

razor
bar-pointer.cs
@using Syncfusion.EJ2;
@Html.EJS().LinearGauge("linear").Load("gaugeLoad").Render()
<script>
    window.gaugeLoad = function (args) {
        var axis = args.gauge.axes[0];
        axis.pointers = [{
            value: 60,
            type: 'Bar'
        }]
    }
</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;
using Syncfusion.EJ2.Charts;
using Syncfusion.EJ2.LinearGauge;


namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {

            return View();
        }
    }
}

Bar pointer customization

The bar pointer can be customized using following properties.

  • width - Specifies bar pointer width
  • color - Specifies bar pointer color
  • offset - Helps to move the bar pointer from its default position.
  • border - Specifies bar pointer border width and color
  • placement property is not supported for bar pointer.
razor
bar-pointer-customization.cs
@using Syncfusion.EJ2;
@Html.EJS().LinearGauge("linear").Load("gaugeLoad").Render()
<script>
    window.gaugeLoad = function (args) {
        var axis = args.gauge.axes[0];
        axis.pointers = [{
            value: 60,
            type: 'Bar',
            width: 20,
            color: '#f44141'
        }]
    }
</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;
using Syncfusion.EJ2.Charts;
using Syncfusion.EJ2.LinearGauge;


namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {

            return View();
        }
    }
}

Pointer placement

You can placement the marker pointer in any of the following locations using [placement] property.

  • Far
  • Near
  • Center
  • None
razor
pointer-placement.cs
@using Syncfusion.EJ2;
@Html.EJS().LinearGauge("linear").Load("gaugeLoad").Render()
<script>
    window.gaugeLoad = function (args) {
        var axis = args.gauge.axes[0];
        axis.pointers = [{
            value: 60,
            markerType: 'Arrow',
            color: '#f44141',
            placement: 'Near'
        }]
    }
</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;
using Syncfusion.EJ2.Charts;
using Syncfusion.EJ2.LinearGauge;


namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {

            return View();
        }
    }
}

Multiple Pointers

In addition to the default pointer, you can add n number of pointer to an axis.

razor
multiple-pointers.cs
@using Syncfusion.EJ2;
@Html.EJS().LinearGauge("linear").Load("gaugeLoad").Render()
<script>
    window.gaugeLoad = function (args) {
        var axis = args.gauge.axes[0];
        axis.pointers = [{
            value: 80
        },
        {
            value: 60,
            markerType: 'Circle'
        },
        {
            value: 30,
            markerType: 'Diamond'
        }]
    }
</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;
using Syncfusion.EJ2.Charts;
using Syncfusion.EJ2.LinearGauge;


namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {

            return View();
        }
    }
}

Pointer Animation

Pointer will animate on loading the gauge. This can be handled by using animationDuration property. You need to specify the duration of the animation in milliseconds.

razor
pointer-animation.cs
@using Syncfusion.EJ2;
@Html.EJS().LinearGauge("linear").Load("gaugeLoad").Render()
<script>
    window.gaugeLoad = function (args) {
        var axis = args.gauge.axes[0];
        axis.pointers = [{
            value: 60,
            animationDuration: 1000
        }]
    }
</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;
using Syncfusion.EJ2.Charts;
using Syncfusion.EJ2.LinearGauge;


namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {

            return View();
        }
    }
}

Gradient Color

Gradient support allows to add multiple colors in the ranges and pointers of the circular gauge. The following gradient types are supported in the circular gauge.

  • Linear Gradient
  • Radial Gradient

Linear Gradient

Using linear gradient, colors will be applied in a linear progression. The start value of the linear gradient can be set using the startValue property. The end value of the linear gradient will be set using the endValue property. The color stop values such as color, opacity and offset are set using colorStop property.

The linear gradient can be applied to all pointer types like marker and range bar. To do so, follow the below code sample.

razor
lineargradient.cs
@Html.EJS().LinearGauge("container").Load("onGaugeLoad").Orientation(Syncfusion.EJ2.LinearGauge.Orientation.Horizontal).Container(
            new Syncfusion.EJ2.LinearGauge.LinearGaugeContainer { Width = 30,
                Offset = 30 }
           ).Margin(new Syncfusion.EJ2.LinearGauge.LinearGaugeMargin{ Bottom=50}).Axes(new List<Syncfusion.EJ2.LinearGauge.LinearGaugeAxis>
                {
                new Syncfusion.EJ2.LinearGauge.LinearGaugeAxis
                {
                Minimum = 0, Maximum = 100,
                Line = new Syncfusion.EJ2.LinearGauge.LinearGaugeLine { Width = 0 },
                MajorTicks = new Syncfusion.EJ2.LinearGauge.LinearGaugeTick { Interval= 25, Height= 0 },
                MinorTicks = new Syncfusion.EJ2.LinearGauge.LinearGaugeTick { Height=0 },
                LabelStyle = new Syncfusion.EJ2.LinearGauge.LinearGaugeLabel {  Offset = 55 },
                } }).Render();

<script type="text/javascript">
    function onGaugeLoad(sender) {
        sender.gauge.axes[0].pointers = [{
            value: 80, height: 25,
            width: 35, placement: 'Near',
            offset: -44, markerType: 'Triangle',
            linearGradient: {
                startValue: '0%',
                endValue: '100%',
                colorStop: [
                { color: '#fef3f9', offset: '0%', opacity: 1 },
                { color: '#f54ea2', offset: '100%', opacity: 1 }]
            }
        }];
        sender.gauge.axes[0].ranges = [{
            start: 0, end: 80,
            startWidth: 30, endWidth: 30,
            color: '#f54ea2', offset: 30,
        }]
    }
</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;
using Syncfusion.EJ2.Charts;
using Syncfusion.EJ2.LinearGauge;


namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {

            return View();
        }
    }
}

Radial Gradient

Using radial gradient, colors will be applied in circular progression. The inner circle position of the radial gradient will be set using the innerPosition property. The outer circle position of the radial gradient can be set using the outerPosition property. The color stop values such as color, opacity and offset are set using colorStop property.

The radial gradient can be applied to all pointer types like marker and range bar. To do so, follow the below code sample.

razor
radialgradient.cs
@Html.EJS().LinearGauge("container").Load("onGaugeLoad").Orientation(Syncfusion.EJ2.LinearGauge.Orientation.Horizontal).Container(
            new Syncfusion.EJ2.LinearGauge.LinearGaugeContainer { Width = 30,
                Offset = 30 }
           ).Margin(new Syncfusion.EJ2.LinearGauge.LinearGaugeMargin{ Bottom=50}).Axes(new List<Syncfusion.EJ2.LinearGauge.LinearGaugeAxis>
                {
                new Syncfusion.EJ2.LinearGauge.LinearGaugeAxis
                {
                Minimum = 0, Maximum = 100,
                Line = new Syncfusion.EJ2.LinearGauge.LinearGaugeLine { Width = 0 },
                MajorTicks = new Syncfusion.EJ2.LinearGauge.LinearGaugeTick { Interval= 25, Height= 0 },
                MinorTicks = new Syncfusion.EJ2.LinearGauge.LinearGaugeTick { Height=0 },
                LabelStyle = new Syncfusion.EJ2.LinearGauge.LinearGaugeLabel {  Offset = 55 },
                } }).Render();

<script type="text/javascript">
    function onGaugeLoad(sender) {
        sender.gauge.axes[0].pointers = [{
            value: 80, height: 25,
            width: 35, placement: 'Near',
            offset: -44, markerType: 'Triangle',
            radialGradient: {
                radius: '60%',
                outerPosition: { x: '50%', y: '50%' },
                innerPosition: { x: '50%', y: '50%' },
                colorStop: [
                { color: '#fff5f5', offset: '0%', opacity: 0.9 },
                { color: '#f54ea2', offset: '100%', opacity: 0.8 }]
            }
        }];
        sender.gauge.axes[0].ranges = [{
            start: 0, end: 80,
            startWidth: 30, endWidth: 30,
            color: '#f54ea2', offset: 30,
        }]
    }
</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;
using Syncfusion.EJ2.Charts;
using Syncfusion.EJ2.LinearGauge;


namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {

            return View();
        }
    }
}