Methods in Blazor Sparkline Component

13 Oct 20211 minute to read

Using the @ref property, create an object for the Sparkline component and call the desired method.

Refresh

The RefreshAsync method helps to render the Sparkline component again.

@using Syncfusion.Blazor.Charts

<button @onclick="RefreshCall">Refresh</button>
<SfSparkline @ref="@Sparkline" DataSource="new int[]{ 3, 6, 4, 1, 3, 2, 5 }" Type="SparklineType.Area" Height="200px" Width="350px" Fill="#b2cfff" LineWidth="1">
</SfSparkline>

@code
{
    public SfSparkline<int> Sparkline { get; set; }
    public async Task RefreshCall()
    {
        await Sparkline.RefreshAsync();
    }
}