This is a migrated thread and some comments may be shown as answers.

Custom PieChart Label

3 Answers 81 Views
Chart - Xamarin.Android
This is a migrated thread and some comments may be shown as answers.
Takudzwa
Top achievements
Rank 1
Takudzwa asked on 06 Oct 2016, 09:26 AM

Hi, can you please provide an example on how i customize the labels on the pie chart. I want them to look like "Total Male: 67%" instead of just 67%.

Thanks

3 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 07 Oct 2016, 07:25 AM
Hello Takudzwa Mawarire,

To customize the pie labels you can use the LableValueToStringConverter property. The property value is a callback that is called by the chart and you can use it to format the label value in any way you want.

Please write again if you have more questions.


Regards,
Victor
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Takudzwa
Top achievements
Rank 1
answered on 07 Oct 2016, 10:31 AM
[quote]Victor said:Hello Takudzwa Mawarire,

To customize the pie labels you can use the LableValueToStringConverter property. The property value is a callback that is called by the chart and you can use it to format the label value in any way you want.

Please write again if you have more questions.


Regards,
Victor
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items

[/quote]

Hi, thanks for the response, but can you provide an example please. I am a newbie.

01.private RadPieChartView CreateChart()
02.        {
03.            try
04.            {
05.                var pieChart = new RadPieChartView(this);
06.                var tooltipBehavior = new ChartTooltipBehavior(this);
07. 
08.                pieChart.Behaviors.Add(tooltipBehavior);
09.                 
10.                var pieSeries = new PieSeries
11.                {
12.                    ValueBinding = new SeriesResultDataBinding("Value"),
13.                    Data = (Java.Lang.IIterable) this._distArray,
14.                    ShowLabels = true,
15.                    NameBinding = new SeriesResultDataBinding("Name")
16.                };
17.                //pieSeries.LabelValueToStringConverter
18.                //Try get the label
19.                pieChart.Series.Add(pieSeries);
20. 
21.                return pieChart;
22.            }
23.            catch (Exception ex)
24.            {
25.                new AlertDialog.Builder(this)
26.                    .SetTitle("ActivityGetReport - CreateChart")
27.                    .SetMessage("Error Occurred: " + ex.Message)
28.                    .SetPositiveButton("OK", delegate { })
29.                    .Show();
30.                return null;
31.            }
32. 
33.        }

Above is the method i am using to create my charts, which i then call in the onCreate() method as shown:

1.var chartView= (ViewGroup)FindViewById(Resource.Id.chartContainer);
2.                chartView.AddView(CreateChart());

I am using a different method for my data. I want to know where exactly to i place the piece of code to format my labels in a desired manner.

Thanks again

0
Victor
Telerik team
answered on 11 Oct 2016, 01:52 PM
Hello Takudzwa,

Thanks for writing.
It appears that there is a bug only in PieSeries that causes LabelValueToStringConverter to now be invoked.
We will fix this ASAP.

Regards,
Victor
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart - Xamarin.Android
Asked by
Takudzwa
Top achievements
Rank 1
Answers by
Victor
Telerik team
Takudzwa
Top achievements
Rank 1
Share this question
or