Selection in WinUI Chart (SfCircularChart)
1 Jul 20212 minutes to read
Circular chart supports selection that allows to select a segment in a series or series itself by using ChartSelectionBehavior.
Enable Selection
To enable the selection in chart, create an instance of ChartSelectionBehavior and add it to the Behaviors
collection of circular chart. And also need to set the SelectionBrush property to highlight the segment in the series.
<chart:SfCircularChart>
<chart:SfCircularChart.Behaviors>
<chart:ChartSelectionBehavior />
</chart:SfCircularChart.Behaviors>
<chart:SfCircularChart.Series>
<chart:PieSeries SelectionBrush="BlueViolet"/>
</chart:SfCircularChart.Series>
</chart:SfCircularChart>
SfCircularChart chart = new SfCircularChart();
ChartSelectionBehavior selection = new ChartSelectionBehavior();
chart.Behaviors.Add(selection);
PieSeries series = new PieSeries();
series.SelectionBrush = new SolidColorBrush(Colors.BlueViolet);
chart.Series.Add(series);
Multi-selection
Circular chart allows to select single or multiple segment\series using Type property. By default the Type value is Point.
<chart:SfCircularChart>
. . .
<chart:SfCircularChart.Behaviors>
<chart:ChartSelectionBehavior Type="MultiPoint"/>
</chart:SfCircularChart.Behaviors>
</chart:SfCircularChart>
SfCircularChart chart = new SfCircularChart();
. . .
ChartSelectionBehavior selection = new ChartSelectionBehavior();
selection.Type = SelectionType.MultiPoint;
chart.Behaviors.Add(selection);
Events
The following events are available in chart SfCircularChart.
SelectionChanging
The SelectionChanging event occurs before the data point is being selected. This is a cancelable event. This argument contains the following information.
- SelectedSeries - Gets the series of the selected data point.
- SelectedSegments - Gets or sets the segments collection of the selected series.
- SelectedSegment - Gets the segment of the selected data point.
- SelectedIndex - Gets the selected data point index.
- PreviousSelectedIndex - Gets the previous selected data point index.
- IsDataPointSelection - Gets a value that indicates whether the selection is segment selection or series selection.
- Cancel - Gets or Sets a value that indicates whether the selection should be canceled.
SelectionChanged
The SelectionChanged event occurs after a data point has been selected. This argument contains the following information.
- SelectedSeries - Gets the series of the selected data point.
- SelectedSegments - Gets the segments collection of the selected series.
- SelectedSegment - Gets the segment of the selected data point.
- SelectedIndex - Gets the selected data point index.
- PreviousSelectedSeries - Gets the previous selected series.
- PreviousSelectedIndex - Gets the previous selected data point index.
- IsDataPointSelection - Gets a value that indicates whether the selection is segment selection or series selection.
- SelectedSeriesCollection - Gets the series collection that has been selected through rectangle selection or mouse interaction.