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

Donut Chart with Custom Format / Label Point

3 Answers 160 Views
Chart - Xamarin.iOS
This is a migrated thread and some comments may be shown as answers.
Enrique
Top achievements
Rank 1
Enrique asked on 11 Apr 2016, 04:51 AM

Hi,

Im creating a Dashboard using StoryBoard and Telerik Chart within Xamarin. I was able to create my chart and populate but I'm lost when I try to set the format. I want to set the current Label + Value as the second image. 

 Here is my code and I have attached 2 images, the first one is the current behavior of my code, and second is what I'm trying to create.

TKChart revenueView = new TKChart();
revenueView.BackgroundColor = UIColor.FromRGB (238, 238, 238);
revenueView.AllowAnimations = true;
revenueView.Legend.Hidden = false;
revenueView.Legend.Style.Position = TKChartLegendPosition.Right;
revenueView.AutoresizingMask = ~UIViewAutoresizing.None;
TKChartDonutSeries series = new TKChartDonutSeries (revData.GetCurrentData (time, comparision));
series.Title = "Series Title";
series.SelectionMode = TKChartSeriesSelectionMode.DataPoint;
series.InnerRadius = 0.6f;
series.ExpandRadius = 1.1f;
series.LabelDisplayMode = TKChartPieSeriesLabelDisplayMode.Outside;
series.Style.PointLabelStyle.TextHidden = false;
series.Style.PointLabelStyle.LabelOffset = new UIOffset (0, -25);

revenueView.AddSeries (series);

 

3 Answers, 1 is accepted

Sort by
0
Adrian
Telerik team
answered on 14 Apr 2016, 08:51 AM
Hi, Enrique,

Thank you for writing.

This scenario can be achieved by implementing TextForLabelAtPoint method of TKChartDelegate. This delegate method allows you to return a string for every point label in the chart. Consider the code below:
class ChartDelegate : TKChartDelegate
{
    public override string TextForLabelAtPoint (TKChart chart, TKChartData dataPoint, TKChartSeries series, nuint dataIndex)
    {
        // return desired string
    }
}
    

I hope this helps.

Regards,
Adrian
Telerik
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
Enrique
Top achievements
Rank 1
answered on 16 Apr 2016, 02:17 AM

Is possible apply a Style for an item in the serie just when it is Selected?. I want to show the value as normal behavior display mode outsite, but show the percentage when is selected and display mode inside. In the override method LabelForDataPoint I'm able to detect when is selected but when I apply the style is applied for entire serie not just for the datapoint selected.

if (series.Index == (nuint)selectedSeriesIndex ; dataIndex == (nuint)selectedDataPointIndex)<br>
   series.Style.PointLabelStyle.LabelOffset = new UIOffset(0, -50);
   return new TKChartPointLabel(dataPoint, series, string.Format("{0}%", percentage));
}

I add an image with desired behavior.

Regardsk

0
Adrian
Telerik team
answered on 20 Apr 2016, 12:13 PM
Hello, Enrique,

Currently TKChart does not support manipulation of only one point label in the series out of the box. I logged this in our feedback portal where you can vote or comment this feature request. We will consider implementing such functionality in a future version.

Regards,
Adrian
Telerik
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.iOS
Asked by
Enrique
Top achievements
Rank 1
Answers by
Adrian
Telerik team
Enrique
Top achievements
Rank 1
Share this question
or