New to Telerik UI for WinForms? Download free 30-day trial

Selection

This help topic will demonstrate how you can make your charts more interactive by adding a selection behavior.

In order to utilize this behavior users simply have to add it to the chart's Controllers collection. For example:

Add Controller

radChartView1.Controllers.Add(new ChartSelectionController());
radChartView1.SelectionMode = ChartSelectionMode.SingleDataPoint;
radChartView1.SelectedPointChanged += new ChartViewSelectedChangedEventHandler(radChartView1_SelectedPointChanged);

The ChartSelectionController will be added automatically if the SelectionMode property of RadChartView control is set to one of available options.

ChartSelectionMode

radChartView1.SelectionMode = ChartSelectionMode.SingleDataPoint;
radChartView1.SelectionMode = ChartSelectionMode.MultipleDataPoints;

Here is a sample using PieSeries and multiple selection. When a slice is selected, it is being offsetted from the center:

Sliced Pie

public ChartSelection()
{
    InitializeComponent();
    radChartView1.AreaType = ChartAreaType.Pie;
    PieSeries pieSeries = new PieSeries();
    pieSeries.ShowLabels = true;
    pieSeries.PointSize = new SizeF(15, 15);
    pieSeries.DataPoints.Add(new PieDataPoint(10));
    pieSeries.DataPoints.Add(new PieDataPoint(5));
    pieSeries.DataPoints.Add(new PieDataPoint(40));
    pieSeries.DataPoints.Add(new PieDataPoint(22));
    pieSeries.DataPoints.Add(new PieDataPoint(11));
    pieSeries.DataPoints.Add(new PieDataPoint(20));
    radChartView1.Series.Add(pieSeries);
    radChartView1.Controllers.Add(new ChartSelectionController());
    radChartView1.SelectionMode = ChartSelectionMode.MultipleDataPoints;
    radChartView1.SelectedPointChanged += new ChartViewSelectedChangedEventHandler(radChartView1_SelectedPointChanged);
}
void radChartView1_SelectedPointChanged(object sender, ChartViewSelectedPointChangedEventArgs args)
{
    if (args.NewSelectedPoint != null)
    {
        UpdateSelectedPoint(args.NewSelectedPoint);
    }
    if (args.OldSelectedPoint != null)
    {
        UpdateSelectedPoint(args.OldSelectedPoint);
    }
}
void UpdateSelectedPoint(DataPoint point)
{
    PieDataPoint pieDataPoint = point as PieDataPoint;
    if (pieDataPoint != null)
    {
        if (pieDataPoint.IsSelected)
        {
            pieDataPoint.OffsetFromCenter = 0.1;
        }
        else
        {
            pieDataPoint.OffsetFromCenter = 0;
        }
    }
}

Figure 2: Sliced Pie

WinForms RadChartView Sliced Pie