DxChart<T>.RedrawAsync() Method
Re-renders the Chart and its child components.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v21.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:
- A user resizes the browser window.
- The Chart component is bound to an ObservableCollection<T> or BindingList<T> object and the bound object changes.
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">
<DxChart Data="forecasts" @ref="Chart">
<DxChartBarSeries ArgumentField="@((WeatherForecast i) => i.Date)"
ValueField="@((WeatherForecast i) => i.Precipitation)"
Name="Precipitation">
</DxChartBarSeries>
</DxChart>
</div>
@code {
DxChart<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