Skip to main content
All docs
V24.2

DxPieChart<T>.SelectPoints(Int32, T[]) Method

Selects pie sectors that correspond to the specified data points.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

Declaration

public void SelectPoints(
    int seriesIndex,
    params T[] points
)

Parameters

Name Type Description
seriesIndex Int32

The series position in chart markup.

points T[]

Data points.

Remarks

Set the DxPieChart.PointSelectionMode property to Single or Multiple to enable sector selection in <DxPieChart>.

Call the following methods to manage point selection in code:

SelectPoints
Select specific pie sectors in code.
DeselectPoints
Deselect specific pie sectors in code.
ClearSelectionAsync()
Resets selection in the entire Chart component.

SelectPoints and DeselectPoints method overloads accept a single or multiple data points as parameters.

When you call SelectPoints or DeselectPoints method overloads, <DxPieChart> raises the SelectionChanged event. You can obtain information about the selected sector in the event handler.

Example

The following code snippet selects and deselects sectors of the specified series on button clicks:

DxPieChart - Point Selection in Code

<DxPieChart Data="@DataSource"
            Width="500px"
            @ref="pieChart"
            CustomizeSeriesPoint="CustomizeSeriesPoint"
            PointSelectionMode="ChartSelectionMode.Multiple">
    <DxPieChartSeries ArgumentField="@((StatisticPoint v) => v.Region)"
                      ValueField="@((StatisticPoint v) => v.Population24)"
                      SummaryMethod="Enumerable.Sum"
                      Name="Region">
        <DxChartSeriesLabel Visible="true"
                            ValueFormat="ChartElementFormat.Millions()"
                            Position="RelativePosition.Inside" />
    </DxPieChartSeries>
    <DxPieChartSeries ArgumentField="@((StatisticPoint v) => v.Country)"
                      ValueField="@((StatisticPoint v) => v.Population24)"
                      Name="Country">
        <DxChartSeriesLabel Visible="true"
                            ValueFormat="ChartElementFormat.Millions()"
                            Position="RelativePosition.Inside" />
    </DxPieChartSeries>
    <DxChartTitle Text="Population by Region and Country" />
    <DxChartLegend Position="RelativePosition.Outside" />
</DxPieChart>

<DxButton Text="Select points"
          Click="SelectPoints"
          RenderStyleMode="ButtonRenderStyleMode.Outline"/>
<DxButton Text="Deselect points"
          Click="DeselectPoints"
          RenderStyleMode="ButtonRenderStyleMode.Outline"/>

@code {
    IEnumerable<StatisticPoint> DataSource = Enumerable.Empty<StatisticPoint>();
    protected override void OnInitialized() {
        DataSource = GenerateData();
    }
    DxPieChart<StatisticPoint> pieChart;

    void SelectPoints() {
        // Pass the series index (order) as a parameter
        pieChart.SelectPoints(1, DataSource.First(), DataSource.Last());
        // Pass the series name as a parameter
        pieChart.SelectPoints("Country", DataSource.First(), DataSource.Last());
    }

    void DeselectPoints() {
        // Pass the series index (order) as a parameter
        pieChart.DeselectPoints(1, DataSource.First());
        // Pass the series name as a parameter
        pieChart.DeselectPoints("Country", DataSource.First());
    }

    Dictionary<object, Color> palette = new() {
        { "North America", Color.FromArgb(204, 21, 8) },
        { "Europe", Color.FromArgb(23, 87, 235) },
        { "USA", Color.FromArgb(230, 92, 23) },
        { "Canada", Color.FromArgb(237, 148, 14) },
        { "Germany", Color.FromArgb(41, 139, 230) },
        { "Italy", Color.FromArgb(41, 202, 230) },
        { "UK", Color.FromArgb(41, 230, 224) },
        { "France", Color.FromArgb(28, 149, 173) },
    };
    void CustomizeSeriesPoint(ChartSeriesPointCustomizationSettings settings) {
        settings.PointAppearance.Color = palette[settings.Point.Argument];
    }
}
See Also