Can't change donut labels (iOS Xamarin)


I’m trying to change the labels on my donut chart but it’s not working. Currently they just show up as a number like 1234566789.12. I want them to show up as something like “VTI: $1,234,566,789.12”. I tried following this tutorial and adapting the code for C#: here but it doesn’t work. The SChartDelegate.AlterDataPointLabel is never called (I set a break point at the start of it) and my labels always show up as the default.

I create my chart, and set its .Delegate field to my instance of an SChartDelegate subclass. This subclass contains the single method:

public override void AlterDataPointLabel(ShinobiChart chart, SChartDataPointLabel label, SChartDataPoint dataPoint, SChartSeries series) { if (label.Tag != CUSTOMIZED) { label.Tag = CUSTOMIZED; var dp = (SChartRadialDataPoint)dataPoint; label.Text = $"{dp.Name}: {dp.Value:N2}"; } }

It’s never called and the label never changes. I then looked at the reference for SChartDonutSeries (which is a tad confusing because even though I clicked the Xamarin link the code is in Objective-C) and it says that there’s an instance method named “CreateLabels”. I thought that might be how I’m supposed to customize things. However, looking at the class in Visual Studio, this method doesn’t seem to exist at all at least in the Xamarin version of the code.

At this point I’m not sure where to look or what to do to change my labels. Any help would be appreciated, thanks.


Hi Architekt,

Our radial charts (Pie & donut) have different delegate methods for this feature.

The SChartDelegate method you are after is:

public override void WillAddRadialLabel(ShinobiChart chart, UILabel label, SChartRadialDataPoint datapoint, nint index, SChartRadialSeries series)
	{ ... }

If you add your implementation inside this method to your delegate it should provide you with the behaviour you are after.

Let me know if you have any questions.

Kind regards,
Andrew Polkinghorn.