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

RadPieChart not showing label

1 Answer 83 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.
Igor
Top achievements
Rank 1
Igor asked on 16 May 2013, 07:35 AM
I have an app with a WP7 and WP8 build. I have a RadPieChart defined as

   <DataTemplate x:Key="LabelTemplate">
            <TextBlock Text="{Binding}"
                       Foreground="White" />
        </DataTemplate>

<chart:RadPieChart Palette="Warm"
                                           x:Name="expensesChart"
                                           Height="360"
                                           Width="360"
                                           HorizontalAlignment="Left">
                            <chart:PieSeries ShowLabels="True"
                                             LabelTemplate="{StaticResource LabelTemplate}"
                                             ValueBinding="Sum"
                                             ItemsSource="{Binding ExpenseStats}">
 
                                <chart:PieSeries.LabelDefinitions>
                                    <chart:ChartSeriesLabelDefinition Binding="Category" />
                                </chart:PieSeries.LabelDefinitions>
 
                            </chart:PieSeries>
                        </chart:RadPieChart>

This code works fine in WP7 build of the app and shows Category as the label for each item. However, in WP8 build of the app, the labels are shown as Telerik.Charting.PieDataPoint for each item (sceenshot: https://pbs.twimg.com/media/BKWX0LqCcAAvv64.png:large).

Is there something different in the RadPieChart for WP8? I noticed then when I do not use the LabelTemplate, then the label is shown ok on WP8 but I do not know how to change its color.

1 Answer, 1 is accepted

Sort by
0
Accepted
Victor
Telerik team
answered on 21 May 2013, 07:32 AM
Hi Igor,

Thanks for the question.

RadChart for WP8 was updated with several new features and also refactoring of existing ones. One of the few breaking changes introduced is the behavior you are describing. The DataContext of your data templates is no longer a string but the chart data point itself. This allows a lot more flexibility when defining the data template since you have access to the full data object that the chart data point represents. You have to modify your binding slightly. Instead of simply {Binding} it should be {Binding Percent}. You can also specify string format in the binding if you want to display the percent sign.

Please write again if you have other questions.

Kind regards,
Victor
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Tags
Chart
Asked by
Igor
Top achievements
Rank 1
Answers by
Victor
Telerik team
Share this question
or