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

How to display label in Pieseries for Phone

2 Answers 124 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
enamul
Top achievements
Rank 1
enamul asked on 29 Apr 2012, 12:02 AM
I am newbie to Telerik controls. Trying to create a pie chart with lables, but not able to find a complete example in Telerik help files.

xaml
<chart:RadPieChart x:Name="gPie" Margin="27,95,143,276" Grid.Row="1" DataContext="{Binding}">
            <chart:PieSeries ShowLabels="True" DataContext="{Binding}">
                <chart:PieSeries.SliceStyles>
                    <Style TargetType="Path">
                        <Setter Property="Fill" Value="Magenta"/>
                    </Style>
 
                    <Style TargetType="Path">
                        <Setter Property="Fill" Value="LimeGreen"/>
                    </Style>
 
                    <Style TargetType="Path">
                        <Setter Property="Fill" Value="DarkOrange"/>
                    </Style>
 
                    <Style TargetType="Path">
                        <Setter Property="Fill" Value="Purple"/>
                    </Style>
 
                    <Style TargetType="Path">
                        <Setter Property="Fill" Value="Green"/>
                    </Style>
 
                    <Style TargetType="Path">
                        <Setter Property="Fill" Value="Red"/>
                    </Style>
                    <Style TargetType="Path">
                        <Setter Property="Fill" Value="Blue"/>
                    </Style>
                </chart:PieSeries.SliceStyles>
                 
                <!--<chart:PieSeries.LabelTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding}"
                               FontSize="14"
                               Foreground="{StaticResource PhoneBackgroundBrush}"
                               FontWeight="Bold"/>
                    </DataTemplate>
                </chart:PieSeries.LabelTemplate>-->
            </chart:PieSeries>
        </chart:RadPieChart>

And I am setting the value in C#:
this.gPie.Series[0].ItemsSource = new double[] { iFajr, iDohr, iAsr, iMagrib, iEsha, iFasting, iHajj };

The pie chart displays fine with %-tile lable for each item. But I like to use custom lable for them. How do I do it? Also, Is there a way to display the lables on the side (with a color icon and corresponding text), not on the chart itself?

2 Answers, 1 is accepted

Sort by
0
RoboticPet
Top achievements
Rank 1
answered on 01 May 2012, 04:18 AM
enamul, it looks like you can do part of what you want by using Standard Numeric Format Strings (http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx).  E.g. if you set LabelFormat on the PieSeries to "n2" you will get the percentages in decimals of two digits with no percent sign.

However, what I want to do is just show the actual values that I specified as the PieDataPoints (whole numbers).  What is the recommended way to do that?
0
Victor
Telerik team
answered on 02 May 2012, 01:37 PM
Hello Enamul,

Thanks for the question

If I understood you correctly you are asking whether the chart can display a legend? If this is indeed your requirement you will have to create the legend manually, since RadChart does not yet support automatic legend generation. Currently, all customization of the labels should be done within the LabelTemplate in the pie series. For special formatting you can use a binding converter that converts the actual label string to anything you deem appropriate for your scenario.

Please write again if you have other questions.

Greetings,
Victor
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Chart
Asked by
enamul
Top achievements
Rank 1
Answers by
RoboticPet
Top achievements
Rank 1
Victor
Telerik team
Share this question
or