Chart for Xamarin.iOS: Selection
This help topic demonstrates how you can make your charts more interactive by enabling a selection behavior.
Configure
You can alter the selection mode by altering the chart SeriesSelectionMode
and DataPointSelectionMode
properties with the following value:
- TKChartSelectionModeNone - No selection.
- TKChartSelectionModeSingle - A single point/series can be selected.
- TKChartSelectionModeMultiple - Multiple points/series can be selected.
In addition you can finely tune the selection by setting the selection
property of each series:
- TKChartSeriesSelectionNotSet - Selection not set for this series, fall back to the chart selection settings.
- TKChartSeriesSelectionNone - Selection disabled.
- TKChartSeriesSelectionSeries - Whole series selection.
- TKChartSeriesSelectionDataPoint - Single data point selection.
- TKChartSeriesSelectionDataPointMultiple - Select multiple data points.
This way each series can have a separate selection mode. One series can select a single point, another series can select multiple points and a third series can be selected as a whole series if necessary. Please note that the series selection has higher priority than the chart selection.
Use the SelectedSeries
and SelectedPoints
properties to get currently selected series or points respectively.
The IsSelected
property of TKChartSeries indicates whether the series is selected.
You can determine whether a selection is changed by adopting TKChartDelegate
protocol and implementing one the following methods:
In addition, you can change the selection programmatically by calling the Select
method in the following manner:
Note that you can clear the selection by passing nil value to the Series
argument.