Skip to main content
A newer version of this page is available. .

DxChartBase.RedrawAsync() Method

Re-renders the chart component and its child components.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v22.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public Task RedrawAsync()

Returns

Type Description
Task

An asynchronous operation that redraws the chart.

Remarks

The chart component redraws itself automatically when:

To force the chart to re-render the component, call the RedrawAsync method.

In the snippet below, the chart component is in the hidden <div> element. The chart is re-rendered when its parent container becomes visible.

<style>
    .hidden {
        display: none;
    }

    .visible {
        display: block;
    }
</style>

<DxButton Text="Make Visble" Click="MakeDivVisible" />

<div class="@divClass">
    <DxPieChart Data="forecasts" @ref="Chart">
        <DxPieChartSeries ArgumentField="@((WeatherForecast i) => i.Date)"
                          ValueField="@((WeatherForecast i) => i.Precipitation)"
                          Name="Precipitation">
        </DxPieChartSeries>
        <DxChartLegend Visible="false" />
    </DxPieChart>
</div>

@code {
    DxPieChart<WeatherForecast> Chart;
    string divClass = "hidden";
    bool NeedsRedraw;
    void MakeDivVisible()
    {
        divClass = "visible";
        NeedsRedraw = true;
    }
    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (NeedsRedraw)
            await Chart.RedrawAsync();
        NeedsRedraw = false;
    }
    protected override void OnInitialized()
    {
        forecasts = GetForecast();
    }
}

To update the chart when its data source collection changes, use the RefreshData method.

See Also