Skip to main content

DxChartBase.ClearSelectionAsync() Method

Resets selection in the chart.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public Task ClearSelectionAsync()

Returns

Type Description
Task

A structure that stores an awaitable result of an asynchronous operation.

Remarks

The following example clears selection in a chart when a user clicks the Reset Selection button:

Selection is reset

@page "/"
@using System.Drawing
@using System.Diagnostics

<DxChart @ref="@chart"
         Data="@dataPoints"
         Width=500 Height=300
         SeriesSelectionMode=ChartSelectionMode.Single
         PointSelectionMode=ChartSelectionMode.Single>

    <DxChartLineSeries ArgumentField="@((DataPoint i) => i.Arg)"
                       ValueField="@((DataPoint i) => i.Value1)"
                       Name="Series 1"
                       HoverMode=ChartContinuousSeriesHoverMode.None
                       SelectionMode=ChartContinuousSeriesSelectionMode.None>
        <DxChartSeriesPoint HoverMode=ChartSeriesPointHoverMode.None
                            SelectionMode=ChartSeriesPointSelectionMode.Point />
    </DxChartLineSeries>

    <DxChartLegend Orientation="Orientation.Horizontal"
                   HorizontalAlignment="HorizontalAlignment.Right"
                   Position="RelativePosition.Outside" />
</DxChart>

<DxButton Text="Reset Selection" Click=@OnButtonClick />

@code {
    private DataPoint[] dataPoints;
    DxChartBase chart;

    protected override void OnInitialized() {
        dataPoints = GetDataPoints();
    }

    async void OnButtonClick(MouseEventArgs args) {
        await chart.ClearSelectionAsync();
    }

    public class DataPoint {
        public string Arg { get; set; }
        public int Value1 { get; set; }
        public int Value2 => (int)(Value1 * 1.2);
        public double Value3 { get; set; }
    }
    public DataPoint[] GetDataPoints() {
        DataPoint[] dataPoints = new DataPoint[] {
            new DataPoint() { Arg = "I", Value1 = 26, Value3 = 23},
            new DataPoint() { Arg = "II", Value1 = 24, Value3 = 23},
            new DataPoint() { Arg = "III", Value1 = 25, Value3 = 24},
            new DataPoint() { Arg = "IV", Value1 = 27, Value3 = 29},
            new DataPoint() { Arg = "V", Value1 = 28, Value3 = 30},
        };
        return dataPoints;
    }
}
See Also