Skip to main content

DxChartBase.RedrawAsync() Method

Re-renders the chart component and its child components.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

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