Version

Configuring Selection and Explosion (XamDoughnutChart)

Topic Overview

Purpose

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

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

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

This topic explains using a code example how to add the XamDoughnutChart control to a Xamarin.Forms application.

Slice Selection Configuration Summary

Control configuration summary chart

The following table lists the configurable aspects of the XamDoughnutChart 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.

Changing the selection state upon slice tap

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

Enable/Disable Slice Selection

Overview

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

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

Changing the Selection State upon Slice Tap

Overview

The XamDoughnutChart 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 tap.

In XAML:

<ig:XamDoughnutChart SliceClick="DoughnutSliceClicked">
…

In C#:

private void DoughnutSliceClicked(object sender, SliceClickEventArgs e)
{
    e.IsSelected = !e.IsSelected;
}

Slice Explosion Configuration Summary

Control configuration summary chart

The following table lists the configurable aspects of the XamDoughnutChart 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 tap

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

Enable/ Disable Slice Explosion

Overview

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

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 XamDoughnutChart with 1 slice exploded.

XamDoughnutChart Selection Explosion Xamarin.png

Changing the Explosion State upon Slice Tap

Overview

The XamDoughnutChart 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 tap.

In XAML:

<ig:XamDoughnutChart SliceClick="DoughnutSliceClicked">
…

In C#:

private void DoughnutSliceClicked(object sender,  SliceClickEventArgs e)
{
    e.IsExploded = !e.IsExploded;
}