Custom PieChart Label

4 posts, 0 answers
  1. Takudzwa
    Takudzwa avatar
    4 posts
    Member since:
    Oct 2014

    Posted 06 Oct Link to this post

    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

  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 07 Oct Link to this post

    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
  3. DevCraft banner
  4. Takudzwa
    Takudzwa avatar
    4 posts
    Member since:
    Oct 2014

    Posted 07 Oct in reply to Victor Link to this post

    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

    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

  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 11 Oct Link to this post

    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
Back to Top
DevCraft banner