Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxChartBase.RedrawAsync() Method

Re-renders the chart component and its child components.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public Task RedrawAsync()

#Returns

Type Description
Task

The task that is completed when the chart is redrawn.

#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