Methods in Blazor Linear Gauge Component

30 Aug 20213 minutes to read

The following methods are available in the Linear Gauge component.

SetPointerValue

To change the pointer value dynamically, use the SetPointerValue method in the Linear Gauge component. The following are the arguments for this method.

Argument name Description
axisIndex Specifies the index of the axis in which the pointer value is to be updated.
pointerIndex Specifies the index of the pointer to be updated.
pointerValue Specifies the value of the pointer to be updated.
@using Syncfusion.Blazor.LinearGauge

<button style="margin-left:34px" @onclick="ChangePoinerValue">Update pointer value
</button>
<SfLinearGauge @ref="lineargauge" Width="250px" Height="250px">
    <LinearGaugeAxes>
        <LinearGaugeAxis>
            <LinearGaugePointers>
                <LinearGaugePointer Value="10"></LinearGaugePointer>
            </LinearGaugePointers>
        </LinearGaugeAxis>
    </LinearGaugeAxes>
</SfLinearGauge>

@code {
    SfLinearGauge lineargauge;
    public void ChangePoinerValue()
    {
        lineargauge.SetPointerValue(0, 0, 30);
    }
}

Calling methods in linear gauge

SetAnnotationValue

To change the annotation content dynamically, use the SetAnnotationValue method in the Linear Gauge component. The following are the arguments for this method.

Argument name Description
annotationIndex Specifies the index number of the annotation to be updated.
content Specifies the text for the annotation to be updated.
axisValue Specifies the value of the axis where the annotation is to be placed.

This method will not be applicable for the ContentTemplate class in LinearGaugeAnnotation.

@using Syncfusion.Blazor.LinearGauge

<button style="margin-left:34px" @onclick="ChangeAnnotationValue">Update annotation value</button>
<SfLinearGauge @ref="lineargauge" Width="250px" Height="250px">
    <LinearGaugeAnnotations>
        <LinearGaugeAnnotation AxisValue="0" ZIndex="1" Content="10">
        </LinearGaugeAnnotation>
    </LinearGaugeAnnotations>
    <LinearGaugeAxes>
        <LinearGaugeAxis>
        </LinearGaugeAxis>
    </LinearGaugeAxes>
</SfLinearGauge>

@code {
    SfLinearGauge lineargauge;
    public void ChangeAnnotationValue()
    {
        lineargauge.SetAnnotationValue(0, "50", 50);
    }
}

RefreshAsync

The RefreshAsync method can be used to change the state of the component and render it again.

@using Syncfusion.Blazor.LinearGauge

<button style="margin-left:34px" @onclick="RefreshAsync">Refresh Gauge</button>
<SfLinearGauge @ref="lineargauge" Width="250px" Height="250px">
    <LinearGaugeAxes>
        <LinearGaugeAxis>
            <LinearGaugePointers>
                <LinearGaugePointer Value="10"></LinearGaugePointer>
            </LinearGaugePointers>
        </LinearGaugeAxis>
    </LinearGaugeAxes>
</SfLinearGauge>

@code {
    SfLinearGauge lineargauge;
    public async Task RefreshAsync()
    {
        await lineargauge.RefreshAsync();
    }
}