Skip to main content

DxChartBase.RefreshData() Method

Reloads data and redraws the chart component.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor


public void RefreshData()


If the chart’s data source is a collection that implements the INotifyCollectionChanged interface, the chart component updates its Data property automatically each time the collection changes. For other data source types, use the RefreshData method. This method obtains the latest state of the data source and applies it to the chart.

The following code snippet updates the chart on a button click:

<DxButton Text="Add a new day"
          Click="(e) => GenerateNewItem()">

<DxChart Data="@DataList" @ref="Chart">
    <DxChartLineSeries T="DailyData" 
                       ArgumentField="@(s => s.Date)" 
                       ValueField="@(s => s.Value)" />
          <DxChartAxisLabel Format="ChartElementFormat.MonthAndDay" />
    <DxChartLegend Visible="false" />

@code {
    int DaysNum { get; set; } = 0;
    DxChart<DailyData> Chart;
    static readonly Random random = new Random();

    protected override void OnInitialized()
        DataList = GetData();

    void GenerateNewItem()
        DataList.Add(new DailyData()
            Date = new DateTime(2020, 05, 20).AddDays(++DaysNum),
            Value = random.Next(10, 20)

DxChart - RefreshData Method

If the data source does not change, call the RedrawAsync method to re-render the chart.

See Also