Search results

Annotations

Annotations are used to mark the specific area of interest in the gauge area with texts, shapes or images. You can add any number of annotations to the gauge.

Annotation

By using the content property of annotation object, you can either specify the id of the element or specify the code to create a new element, that needs to be displayed in the gauge area.

tagHelper
annotations.cs
@using Syncfusion.EJ2
<ejs-lineargauge id="linear" annotations="ViewBag.annotations"></ejs-lineargauge>
<script id='fruits' type="text/x-template">
    <div id='apple'>
        <img src="/ej/styles/images/lineargauge/apple.png" />
    </div>
</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()
        {
            List<LinearGaugeAnnotation> annotations = new List<LinearGaugeAnnotation>();
            LinearGaugeAnnotation annotation1 = new LinearGaugeAnnotation();
            annotation1.Content = "#fruits";
            annotation1.X = 100;
            annotation1.Y = 100;
            annotations.Add(annotation1);
            ViewBag.annotations = annotations;
            return View();
        }
    }
}

Annotation Customization

Changing the z-order

You can change the z-order of the annotation element by using the zIndex property.

tagHelper
z-order.cs
@using Syncfusion.EJ2
<ejs-lineargauge id="linear" annotations="ViewBag.annotations"></ejs-lineargauge>
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()
        {
            List<LinearGaugeAnnotation> annotations = new List<LinearGaugeAnnotation>();
            LinearGaugeAnnotation annotation1 = new LinearGaugeAnnotation();
            annotation1.Content = "<div id='first'><h1>Gauge</h1></div>";
            annotation1.ZIndex = "-1";
            annotation1.HorizontalAlignment = Placement.Center;
            annotation1.VerticalAlignment = Placement.Center;
            annotations.Add(annotation1);
            ViewBag.annotations = annotations;
            return View();
        }
    }
}

Positioning the Annotation

You can place the annotation anywhere in gauge area by specifying pixel values to the x and y properties.

tagHelper
animation-position.cs
@using Syncfusion.EJ2
<ejs-lineargauge id="linear" annotations="ViewBag.annotations"></ejs-lineargauge>
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()
        {
            List<LinearGaugeAnnotation> annotations = new List<LinearGaugeAnnotation>();
            LinearGaugeAnnotation annotation1 = new LinearGaugeAnnotation();
            annotation1.Content = "<div id='first'><h1>Gauge</h1></div>";
            annotation1.X = 100;
            annotation1.Y = 100;
            annotations.Add(annotation1);
            ViewBag.annotations = annotations;
            return View();
        }
    }
}

Alignment of Annotation

You can align the annotation using horizontalAlignmentand verticalAlignment properties.

tagHelper
animation-alignment.cs
@using Syncfusion.EJ2
<ejs-lineargauge id="linear" annotations="ViewBag.annotations"></ejs-lineargauge>
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()
        {
            List<LinearGaugeAnnotation> annotations = new List<LinearGaugeAnnotation>();
            LinearGaugeAnnotation annotation1 = new LinearGaugeAnnotation();
            annotation1.Content = "<div id='first'><h1>Gauge</h1></div>";
            annotation1.VerticalAlignment = Placement.Center;
            annotation1.HorizontalAlignment = Placement.Center;
            annotations.Add(annotation1);
            ViewBag.annotations = annotations;
            return View();
        }
    }
}

Multiple Annotations

You can add multiple annotations to the gauge as demonstrated below.

tagHelper
multiple-annotations.cs
@using Syncfusion.EJ2
<ejs-lineargauge id="linear" annotations="ViewBag.annotations"></ejs-lineargauge>
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()
        {
            List<LinearGaugeAnnotation> annotations = new List<LinearGaugeAnnotation>();
            LinearGaugeAnnotation annotation1 = new LinearGaugeAnnotation();
            annotation1.Content = "<div id='first'><h1 style='color: red;'>Speed</h1></div>";
            annotation1.VerticalAlignment = Placement.Near;
            annotation1.HorizontalAlignment = Placement.Center;
            annotation1.X = 100;
            annotation1.Y = 150;
            annotations.Add(annotation1);
            LinearGaugeAnnotation annotation2 = new LinearGaugeAnnotation();
            annotation2.Content= "<div id='first'><h1 style='color: blue;'>Meter</h1></div>";
            annotation2.VerticalAlignment = Placement.Center;
            annotation2.HorizontalAlignment = Placement.Center;
            annotation2.X = -100;
            annotation2.Y = -100;
            annotations.Add(annotation2);
            ViewBag.annotations = annotations;
            return View();
        }
    }
}