Style sliceStyle = new Style
{
Fill = Color.Gray,
Opacity = .75,
};
this.ultraDoughnutChart1.SelectedStyle = sliceStyle;
This topic explains how to configure selection and explosion for the slices of the UltraDoughnutChart™ .
The following topics are prerequisites to understanding this topic:
This topic contains the following sections:
The following table lists the configurable aspects of the UltraDoughnutChart control related to slice selection.
You can enable (default setting) or disable slice selection in the UltraDoughnutChart .
The following table maps the desired behavior to property settings.
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.
The following table maps the desired behavior to property settings.
The screenshot below demonstrates how the selected slice (the slice at the top) of the UltraDoughnutChart looks as a result of the following settings:
The UltraDoughnutChart exposes a SliceClick event used to change the selected/unselected state of a slice.
The following table maps the desired behavior to property settings.
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
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.
The following table maps the desired behaviors to property settings.
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);
The following table lists the configurable aspects of the UltraDoughnutChart control related to slice explosion.
You can enable (default setting) or disable slice explosion in the UltraDoughnutChart .
The following table maps the desired behavior to property settings.
The following screenshot demonstrates a UltraDoughnutChart with 1 slice exploded.
The UltraDoughnutChart exposes a SliceClick event used to change whether a slice is exploded.
The following table maps the desired behavior to property settings.
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
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.
The following table maps the desired behavior to property settings.
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)