Programmatically select slice in donut/pie chart


How can I programmatically select a slice in a Shinobi donut or pie chart?

There is a method on the SChartSeries class called SetSliceAsSelected() but that doesn’t seem to do anything.

Or maybe I’m calling it at the wrong time.

Anyone any idea?

Propagate gesture events to containing controller (ShinobiCharts)

This is what I tried, but it doesn’t work.

_chart = new ShinobiChart(Bounds);
            _chart.DataSource = myDataSource;

            var series = (SChartPieSeries)_chart.DataSource.GetSeries(_chart, 0);

            series.SetSliceAsSelected(0, true);


Also very strange, at that point in my code, series.DataSeries.DataPoints.Count is 0!

However, there is definitely data in my data source.


Does anybody have an idea? It must be something very obvious …


After hours of trying, I still haven’t managed to make this work. I really need to solve this. Can any of the developers try to help me?



Your series count would be 0 at that point because the chart has not queried its data-source yet, and thus hasn’t been supplied any series.

Have you tried overriding the OnRenderStarted method of your donut chart’s delegate? At this point you know your chart has fully queried its data-source and is ready to render your chart. You could do something like this:

protected override void OnRenderStarted(ShinobiChart chart, bool fullRedraw)
    if (firstLoad) {

        SChartDonutSeries series = new SChartDonutSeries (chart.ChartSeries.ValueAt(0));

        series.SetSliceAsSelected (0, true);

        firstLoad = false;

As the chart actually renders every single time it draws (including every frame whilst you are panning your chart, for example), the firstLoad guard is needed to ensure we only set the slice to be selected the very first time it is drawn.



Hi Jan, thank you for your reply. I tried your code but it doesn’t work unfortunately, the slice still does not explode. Can the reason be that I’m using a pie chart instead of a donut chart?

And why are you creating a new series? I would expect the series is already there.


Hi Jan, I added your code to the Shinobi PieChart sample project hat is included with the library and have uploaded it with filedropper:

As you will see in the example the first slice is not exploded, neither in the pie chart, nor in the donut chart.


Hi Boo-lee,

There seems to be an issue when trying to set the selected property of a slice on a pie/donut series before it has finished animating. I have raised this with our development team, and they will look into this in the near future. In the meanwhile, there are two options:

  1. Set the slice you want as selected after the series has finished animating by implementing the SChartDelegate method  OnAnimationDidFinish.
  2. Disable animations on your chart, and stick with the method we discussed previously.



Hi Jan,

Overriding OnAnimationDidFinish method and setting the slice selection there made it work.

Thank you!