Xamarin IOS, how to move piechart labels outside of pie


#1

Hello, I want to move the labels of my pieChart outside of the pie but I am kind of lost, my objective is to make a pie that looks like the one seen on this page:

This is the code I have, in a class that inherits from SChartDataSource, I have overrided the GetLabelForSlice method to create custom labels.

protected override UILabel GetLabelForSlice (ShinobiChart chart, int sliceIndex, SChartRadialSeries series)
        {
            UILabel label = new UILabel (new Rectangle(0,0,60,30));
            label.BackgroundColor = UIColor.Clear;
            label.Font = UIFont.FromName(“HDI-GerlingSans-Regular”, 16);
            label.TextColor = UIColor.FromRGB (255, 255, 255);

            // Move   label  somewhere
            label.Center = new PointF (100,100);

            SChartData datapoint = chart.DataSource.GetDataPoint(chart,sliceIndex,0);
            String value = datapoint.YValue.Description;
            if (value.Length > 3) {
                value = value.Substring (0, 4) + “%”;
            } else {
                value = value + “%”;
            }
            label.Text = value;

            return label;
        }

Maybe I have to set the position on the chart itself or in the class where I create the chart, thanks.


#2

Did you implement OnAddingRadialLabel and OnRenderStarted too, as in the blog post? Those are the two methods responsible for positioning the label.