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

[Solved] How to handle 0% of data points in label definition in DoughnutSeries

3 Answers 120 Views
Chart for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Zubair
Top achievements
Rank 1
Zubair asked on 29 Jan 2014, 07:31 AM
Hi i used DoughnutSeries chart in my windows store app . problem is that when legend is 0 percent then label show 0%. i want to remove label definition for specific 0 percent data points. for better understanding i attach picture of chart. i want to handle 0 percent that is on right side of chart 
thanks

3 Answers, 1 is accepted

Sort by
0
Accepted
Ivaylo Gergov
Telerik team
answered on 30 Jan 2014, 05:07 PM
Hi,

In your scenario I can suggest that you change the ChartSeriesLabelDefinition.Template and use a ValueConvertor to skip a label which is 0%. Here's an example:
<telerikChart:DoughnutSeries.LabelDefinitions>
    <telerikChart:ChartSeriesLabelDefinition>
       <telerikChart:ChartSeriesLabelDefinition.Template>
            <DataTemplate>
                <TextBlock Text="{Binding Converter={StaticResource converter}}"/>
            </DataTemplate>
       </telerikChart:ChartSeriesLabelDefinition.Template>
    </telerikChart:ChartSeriesLabelDefinition>
</telerikChart:DoughnutSeries.LabelDefinitions>

<Page.Resources>
    <local:Converter x:Key="converter"/>
</Page.Resources>

Where the Converter class looks like this: 

public class Converter : IValueConverter
 {
     public object Convert(object value, Type targetType, object parameter, string language)
     {
         var dataPoint = value as DoughnutDataPoint;
         var percent = dataPoint.Percent;
 
         if (percent == 0)
         {
             return "";
         }
         else
         {
             return String.Format("{0}%",percent);
         }
     }
 
     public object ConvertBack(object value, Type targetType, object parameter, string language)
     {
         throw new NotImplementedException();
     }
 }

I hope this helps.

Regards,
Ivaylo Gergov
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

0
Zubair
Top achievements
Rank 1
answered on 04 Feb 2014, 04:05 PM
thanks for u r reply . Overlapping of labels hurt me more. have u any solution for this problem ? Check attach file thnks.
0
Ivaylo Gergov
Telerik team
answered on 05 Feb 2014, 12:22 PM
Hi,

Currently the RadChart does not support Smart Labels i.e. to automatically align labels so that each labeled value stands out clearly. I have logged this as a feature request in our Ideas and Feedback portal where you can vote for it and raise its priority.

Thank you for your valuable feedback.

Regards,
Ivaylo Gergov
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

Tags
Chart for XAML
Asked by
Zubair
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Zubair
Top achievements
Rank 1
Share this question
or