# Selection

## Content



Selection in charts helps the end-user to select the required data point or the whole series at run-time during analysis, etc.

In FlexChart, selection is disabled by default. However, you can enable the selection by setting the [SelectionMode](/componentone/api/maui/online-maui/dotnet-api/C1.Maui.Chart/C1.Maui.Chart.FlexChartBase.SelectionMode.html) property. This property allows you to set the selection mode to either Series or Point using the [ChartSelectionMode](/componentone/docs/maui/online-maui/) enumeration. FlexChart also lets you get or set the index of the selected item using the [SelectedIndex](/componentone/api/maui/online-maui/dotnet-api/C1.Maui.Chart/C1.Maui.Chart.FlexChartBase.SelectedIndex.html) property. Moreover, it provides a SelectionChanged event which notifies when the selected point or series is changed so that you can customize the selection process according to the requirements. You can also customize how a selected item should appear by using the [SelectionStyle](/componentone/api/maui/online-maui/dotnet-api/C1.Maui.Chart/C1.Maui.Chart.FlexChartBase.SelectionStyle.html) property. The property is of ChartStyle type and lets you change the stroke, stroke color, stroke thickness, line pattern etc.

![](https://cdn.mescius.io/document-site-files/images/4e85e507-742e-4a29-b3fe-f23b37c29164/images/flexchart-selection.png)

Following code shows how to set the selection mode for the chart.

```xml
<c1:FlexChart x:Name="chart" ItemsSource="{Binding Data}" SelectionMode="Point"
              BindingX="Date" ChartType="Column">
    <c1:Series SeriesName="Downloads" Binding="Downloads" />
    <c1:Series SeriesName="Sales" Binding="Sales"/>
</c1:FlexChart>
```

Following code is required to shows how to set the selection index and style set for the chart at runtime. This sample uses the same datasource as used in [Basic Charts](/componentone/docs/maui/online-maui/maui-controls/flexchart-overview/flechart-types/basiccharts).

```csharp
chart.SelectedIndex = 2;
chart.SelectionStyle = new ChartStyle()
{
    Stroke = Colors.Brown,
    StrokeThickness = 2
};
```