Search results

Axes

Axes is a collection of linear axis which can be used to indicate the numeric values. Line, ticks, labels, ranges and pointers are the sub elements of an axis.

Line Customization

The line property of an axis provides options to customize the heightwidthcolor and offset of the axis line.

razor
line-customization.cs
@using Syncfusion.EJ2;
@Html.EJS().LinearGauge("linear").Axes(axis=>axis.Line(new
{
    height = 150,
    width = 2,
    color = "#4286f4",
    offset = 2
}).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.Charts;
using Syncfusion.EJ2.LinearGauge;


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

            return View();
        }
    }
}

Ticks Customization

You can customize the height, color and width of major and minor ticks, by using majorTicks and minorTicks) property. By default, interval for major ticks will be calculated automatically and also you can customize the interval for major and minor ticks using interval property.

razor
ticks-customization.cs
@using Syncfusion.EJ2;
@Html.EJS().LinearGauge("linear").Axes(axis=>axis.Minimum(20).Maximum(140).MajorTicks(new
{
    interval = 20
}).MinorTicks(new
{
    interval = 5,
    color = "red"
}).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.Charts;
using Syncfusion.EJ2.LinearGauge;


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

            return View();
        }
    }
}

Labels Customization

The labelStyle property of an axis provides options to customize the offsetformat, color and font of the axis labels.

razor
labels-customization.cs
@using Syncfusion.EJ2;
@Html.EJS().LinearGauge("linear").Axes(axis=>axis.LabelStyle(new
{
    format = "c"
}).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.Charts;
using Syncfusion.EJ2.LinearGauge;


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

            return View();
        }
    }
}

Label Format

Axis labels can be formatted by using the format property in labelStyle and it supports all the globalize formats.

razor
label-format.cs
@using Syncfusion.EJ2;
@Html.EJS().LinearGauge("linear").Axes(axis=>axis.Minimum(20).Maximum(140).LabelStyle(new
{
    format = "{value}°C"
}).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.Charts;
using Syncfusion.EJ2.LinearGauge;


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

            return View();
        }
    }
}

The following table describes the result of applying some commonly used label formats on numeric values.

Label Value Label Format property value Result Description
1000 n1 1000.0 The Number is rounded to 1 decimal place
1000 n2 1000.00 The Number is rounded to 2 decimal place
1000 n3 1000.000 The Number is rounded to 3 decimal place
0.01 p1 1.0% The Number is converted to percentage with 1 decimal place
0.01 p2 1.00% The Number is converted to percentage with 2 decimal place
0.01 p3 1.000% The Number is converted to percentage with 3 decimal place
1000 c1 $1,000.0 The Currency symbol is appended to number and number is rounded to 1 decimal place
1000 c2 $1,000.00 The Currency symbol is appended to number and number is rounded to 2 decimal place

Custom Label Format

Axis also supports custom label format using placeholder like {value}°C, in which the value represents the axis label e.g. 20°C.

razor
custom-label.cs
@using Syncfusion.EJ2;
@Html.EJS().LinearGauge("linear").Width("100%").Height("50%").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.Charts;
using Syncfusion.EJ2.LinearGauge;


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

            return View();
        }
    }
}

Inverted Axes

isInversed property is used to choose the rendering of axis either bottom to top or top to bottom direction.

razor
inverted-axes.cs
@using Syncfusion.EJ2;
@Html.EJS().LinearGauge("linear").Axes(axis=>axis.IsInversed(true).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.Charts;
using Syncfusion.EJ2.LinearGauge;


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

            return View();
        }
    }
}

Opposed Axes

To place an axis opposite from its original position, set opposedPosition property as true in the axis.

razor
opposed-axes.cs
@using Syncfusion.EJ2;
@Html.EJS().LinearGauge("linear").Axes(axis=>axis.OpposedPosition(true).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.Charts;
using Syncfusion.EJ2.LinearGauge;


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

            return View();
        }
    }
}

Multiple Axes

You can render any number of axis for a linear gauge by using array of axis objects. Each axis will have its own ranges, pointers, annotations and customization options.

razor
multiple-axes.cs
@using Syncfusion.EJ2;
@Html.EJS().LinearGauge("linear").Axes(ViewBag.axis).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.Charts;
using Syncfusion.EJ2.LinearGauge;


namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            List<LinearGaugeAxis> axes = new List<LinearGaugeAxis>();
            LinearGaugeAxis axis1 = new LinearGaugeAxis();
            axis1.LabelStyle = new
            {
                format = "{value}°C"
            };
            axes.Add(axis1);
            ViewBag.axis = axes;
            LinearGaugeAxis axis2 = new LinearGaugeAxis();
            axis2.LabelStyle = new
            {
                format = "{value}°F"
            };
            axis2.OpposedPosition = true;
            axes.Add(axis2);
            ViewBag.axis = axes;
            return View();
        }
    }
}