Version

Configuring Selection and Explosion (UltraDoughnutChart)

Topic Overview

Purpose

This topic explains how to configure selection and explosion for the slices of the UltraDoughnutChart™ .

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

This topic gives an overview of the UltraDoughnutChart™ control and its main features.

This topic explains using a code example how to add the UltraDoughnutChart control to a Windows Forms application.

Slice Selection Configuration Summary

Control configuration summary chart

The following table lists the configurable aspects of the UltraDoughnutChart control related to slice selection.

Configurable aspect Details Properties / Events

Enable/disable slice selection

You can enable or disable the ability to select slices or not.

Configuring the look of the selected slices

You can define how the selected slices will look by defining a style and assigning it to the SelectedStyle property of the RingSeries .

Changing the selection state upon slice click

If you attach an event handler for the SliceClick event, it supplies a reference to the clicked slice in the event arguments allowing you to modify its selection state.

Modifying the contents of the SelectedSlices collection

You can change the selected slice by changing the contents of the SelectedSlices collection.

Enable/Disable Slice Selection

Overview

You can enable (default setting) or disable slice selection in the UltraDoughnutChart .

Note
Note:

You must perform all the remaining slice selection configurations in this topic with slice selection enabled.

Property settings

The following table maps the desired behavior to property settings.

In order to: Use this property: And set it to:

Enable/Disable slice selection

True or False

Configuring the Look of the Selected Slices

Overview

The UltraDoughnutChart exposes a SelectedStyle property that determines the look of the selected slices. By default, no style is applied, and selecting a slice will not alter its appearance in any way. In order to apply your own style to the selected slices you need to define a Style and set it as the value of the SelectedStyle property.

Property settings

The following table maps the desired behavior to property settings.

In order to: Use this property: And set it to:

Configure the look for selected slices.

Example

The screenshot below demonstrates how the selected slice (the slice at the top) of the UltraDoughnutChart looks as a result of the following settings:

Property Value

In C#:

Style sliceStyle = new Style
{
Fill = Color.Gray,
Opacity = .75,
};
this.ultraDoughnutChart1.SelectedStyle = sliceStyle;

In VB:

Dim sliceStyle As New Style
{
.Fill = Color.Gray, _
.Opacity = .75, _
}
Me.UltraDoughnutChart1.SelectedStyle = sliceStyle
Selection Doughnut Xamarin.png

Changing the Selection State upon Slice Click

Overview

The UltraDoughnutChart exposes a SliceClick event used to change the selected/unselected state of a slice.

Property settings

The following table maps the desired behavior to property settings.

In order to: Use this event / property: What to do:

Set the IsSelected property

SliceClickEventArgs.IsSelected

Set the IsSelected property of the SliceClickEventArgs to True or False

Example

The following code example demonstrates how to toggle the selection state of slices upon click.

In C#:

void DoughnutChart_SliceClick(object sender, DoughnutSliceClickEventArgs e)
{
 e.IsSelected = !e.IsSelected;
}

In VB:

Private Sub DoughnutChart_SliceClick(sender As Object, e As DoughnutSliceClickEventArgs)
  e.IsSelected = Not e.IsSelected
End Sub

Modifying the Contents of the SelectedSlices Collection

Overview

Another approach for managing the selected slices is to modify the contents of the SelectedSlices collection of the UltraDoughnutChart . To do this, you need to obtain a reference to one or more slice objects that you want to select and add them to the SelectedSlices. If you want to unselect slices, remove them from the collection.

Property settings

The following table maps the desired behaviors to property settings.

In order to: Use this event / property: What to do:

Modify the contents of the SelectedSlices collection

Add or Remove the respective slice from the SelectedSlices collection.

Example

The following code example demonstrates how to obtain a reference to the first slice of the UltraDoughnutChart in and add it to the collection with selected slices. An example of removing an item is also available. Note, execution of this code must occur after loading the particular ring series.

In C#:

    RingSeries ringSeries1 = doughnutChart.Series[0];
    // To add a selected item:
    ringSeries1.SelectedSlices.Add(3);
    // To remove a selected item:
    ringSeries.SelectedSlices.Remove(3);
    Dim ringSeries1 = doughnutChart.Series(0)
    ' To add a selected item:
    ringSeries1.SelectedSlices.Add(3);
    ' To remove a selected item:
    ringSeries.SelectedSlices.Remove(3);

Slice Explosion Configuration Summary

Control configuration summary chart

The following table lists the configurable aspects of the UltraDoughnutChart control related to slice explosion.

Configurable aspect Details Properties / Events

Enable/disable slice explosion

You can enable or disable the ability to explode slices.

Changing the exploded state of a slice upon slice click

If you attach an event handler for the SliceClick event, a reference to the clicked slice is supplied in the event arguments and you can modify its exploded state.

Modifying the contents of the ExplodedSlices collection

You can change the exploded slices by changing the contents of the ExplodedSlices collection.

Enable/ Disable Slice Explosion

Overview

You can enable (default setting) or disable slice explosion in the UltraDoughnutChart .

Note
Note:

You must perform all the remaining slice explosion configurations in this topic with slice explosion enabled.

Property settings

The following table maps the desired behavior to property settings.

In order to: Use this property: And set it to:

Enable/Disable slice explosion

True or False

Example

The following screenshot demonstrates a UltraDoughnutChart with 1 slice exploded.

XamDoughnutChart Selection Explosion Xamarin.png

Changing the Explosion State upon Slice Click

Overview

The UltraDoughnutChart exposes a SliceClick event used to change whether a slice is exploded.

Property settings

The following table maps the desired behavior to property settings.

In order to: Use this event / property: What to do:

Set the IsExploded property

SliceClickEventArgs.IsExploded

Set the IsExploded property of the SliceClickEventArgs to True or False

Example

The following code example demonstrates how to toggle the explosion state of slices upon click.

In C#:

private void DoughnutSliceClicked(object sender, DoughnutSliceClickedEventArgs e)
{
    e.IsExploded = !e.IsExploded;
}
Private Sub DoughnutSliceClicked(sender As Object, e As DoughnutSliceClickedEventArgs)
      e.IsExploded = Not e.IsExploded
End Sub

Modifying the Contents of the ExplodedSlices Collection

Overview

Another approach for managing the exploded slices is to modify the contents of the ExplodedSlices collection of the UltraDoughnutChart . To do this, you need to obtain a reference to one or more slice objects that you want to be able to explode and add them to the ExplodedSlices. If you want to set the non-exploded state of slices, remove them from the collection.

Property settings

The following table maps the desired behavior to property settings.

In order to: Use this event / property: What to do:

Modify the contents of the ExplodedSlices collection

Add or Remove the respective slice from the ExplodedSlices collection.

Example

The following code example demonstrates how to obtain a reference to the first slice of the UltraDoughnutChart in and add it to the collection with exploded slices. An example for removing an item is also available. Note, execution of this code must occur after loading the particular ring series.

In C#:

    RingSeries   ringSeries1 = doughnutChart.Series[0];
    // To add an exploded item:
    ringSeries1.ExplodedSlices.Add(3);
    // To remove an exploded item:
    ringSeries.ExplodedSlices.Remove(3);
    Dim ringSeries1 = doughnutChart.Series(0)
    ' To add an exploded item:
    ringSeries1.ExplodedSlices.Add(3)
    ' To remove an exploded item:
    ringSeries.ExplodedSlices.Remove(3)