Search results

Annotations in ASP.NET Core Linear Gauge

22 Jul 2021 / 3 minutes to read

Annotations are used to mark the specific area of interest in the Linear Gauge with text, HTML elements, or images. Any number of annotations can be added to the Linear Gauge component

Adding annotation

To render the custom HTML elements in the Linear Gauge component, use the Content property in the e-lineargauge-annotation. The annotation can be rendered either by specifying the id of the element or specifying the code to create a new element that needs to be displayed in the gauge area.

tagHelper
Copied to clipboard
@using Syncfusion.EJ2

<ejs-lineargauge id="linear" Orientation="Horizontal">
    <e-lineargauge-annotations>
        <e-lineargauge-annotation Content="#walking" X="100" Y="100" ZIndex="1"></e-lineargauge-annotation>
    </e-lineargauge-annotations>
</ejs-lineargauge>

<div>    
    <script id="walking" type="text/x-template">
        <div id="annotation" style="width:100px;">
            <img style="height:20px;width:20px" src="@Url.Content("~/Content/CircularGauge/walking.svg")">
        </div>
    </script>
</div>

Adding annotation to the Linear Gauge

Customization

The following properties are used to customize the annotation.

  • ZIndex - This property is used to bring the annotation to the front or back, when annotation overlaps with another element.
  • AxisValue - This property is used to place the annotation in the specified axis value with respect to the provided axis index.
  • AxisIndex - This property is used to place the annotation in the specified axis with respect to the provided axis value.
  • HorizontalAlignment - This property is used to place the annotation horizontally.
  • VerticalAlignment - This property is used to place the annotation vertically.
  • X, Y - This property is used to place the annotation in the specified location.

Changing the z-index

To change the stack order of an annotation element, the ZIndex property of the e-lineargauge-annotation can be used.

tagHelper
Copied to clipboard
@using Syncfusion.EJ2

<ejs-lineargauge id="linear" Orientation="Horizontal">
    <e-lineargauge-annotations>
        <e-lineargauge-annotation Content="<div><h1>Gauge</h1></div>" ZIndex="1"></e-lineargauge-annotation>
    </e-lineargauge-annotations>
</ejs-lineargauge>

Adding z-index to annotation

Positioning an annotation

The annotation can be placed anywhere in the Linear Gauge by setting the pixel value to the X and Y properties in the e-lineargauge-annotation.

tagHelper
Copied to clipboard
@using Syncfusion.EJ2

<ejs-lineargauge id="linear" Orientation="Horizontal">
    <e-lineargauge-annotations>
        <e-lineargauge-annotation Content="<div id='first'><h1>Gauge</h1></div>" X="250" Y="100" ZIndex="1"></e-lineargauge-annotation>
    </e-lineargauge-annotations>
</ejs-lineargauge>

Adding position to annotation

Alignment of annotation

The annotation can be aligned horizontally and vertically by using the HorizontalAlignment and VerticalAlignment properties respectively. The possible values can be ”Center”, ”Far”, ”Near”, and ”None”. The HorizontalAlignment and VerticalAlignment properties are not applicable when the X and Y properties are set in the e-lineargauge-annotation.

tagHelper
Copied to clipboard
@using Syncfusion.EJ2

<ejs-lineargauge id="linear">
    <e-lineargauge-annotations>
        <e-lineargauge-annotation Content="<div id='first'><h1>Gauge</h1></div>" VerticalAlignment="Center" HorizontalAlignment="Center" ZIndex="1"></e-lineargauge-annotation>
    </e-lineargauge-annotations>
</ejs-lineargauge>

Alignment of annotation

Multiple annotations

Multiple annotations can be added to the Linear Gauge component by adding the multiple e-lineargauge-annotation in the e-lineargauge-annotations and customization for the annotation can be done with the e-lineargauge-annotation.

tagHelper
Copied to clipboard
@using Syncfusion.EJ2

<ejs-lineargauge id="linear">
    <e-lineargauge-annotations>
        <e-lineargauge-annotation Content="<div><h1 style='color: red;'>Speed</h1></div>" VerticalAlignment="Near" HorizontalAlignment="Center" X="100" Y="150" ZIndex="1"></e-lineargauge-annotation>
        <e-lineargauge-annotation Content="<div><h1 style='color: blue;'>Meter</h1></div>" VerticalAlignment="Center" HorizontalAlignment="Center" X="-100" Y="-100" ZIndex="1"></e-lineargauge-annotation>
    </e-lineargauge-annotations>
</ejs-lineargauge>

Adding multiple annotations