Labels on Pie Chart

6 posts, 1 answers
  1. Igor
    Igor avatar
    29 posts
    Member since:
    Mar 2012

    Posted 12 Aug 2012 Link to this post

    I have a RadPieChart that is bound to an observable collection:

    <chart:RadPieChart Palette="Warm" x:Name="incomesChart">
        <chart:PieSeries ShowLabels="True" LabelTemplate="{StaticResource LabelTemplate}"  ValueBinding="Sum" ItemsSource="{Binding IncomeStats}">
        </chart:PieSeries>
    </chart:RadPieChart>


    The class that is bound to the chart is called StatDetailViewModel and consists of double Sum used in the chart and string  Category that I want to show as Labels. My LabelTemplate is

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


    This template shows the percentage values as Labels in red. I expected that the value sent to this DataTemplate would be my  StatDetailViewModel  class and not the percentage. 

    So how do I shows a specific property from the bound class as Label? (string Category in StatDetailViewModel  in this case).
  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 14 Aug 2012 Link to this post

    Hi Igor,

    Thank you for writing.
    You need to use the LabelDefinitions property of the chart series. Currently the online help is not updated so please have a look at the attached file. You need to read the Label Definitions article under the Series folder.
    Please write again if you need further assistance.

    Greetings,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Igor
    Igor avatar
    29 posts
    Member since:
    Mar 2012

    Posted 14 Aug 2012 Link to this post

    Thanks but I do not get how to use it. In the documentation there is (I suppose I should put it in the RadPieChart element content)

    <telerikChart:ChartSeriesLabelDefinition Binding="Text"/>

    but there is no info what telerikChart is. Is it clr-namespace:Telerik.Charting;assembly=Telerik.Windows.Controls.Chart or clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Chart? Neither of them shows ChartSeriesLabelDefinition  in IntelliSense. 


  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 15 Aug 2012 Link to this post

    Hello Igor,

    Thanks for writing.
    The label definitions are in this namespace:

    xmlns:telerikChart="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Chart"
    Also please rebuild your project and upgrade to the latest release in order to be sure that the label definitions feature is present in the assemblies that you are using.

    Kind regards,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Igor
    Igor avatar
    29 posts
    Member since:
    Mar 2012

    Posted 15 Aug 2012 Link to this post

    I am using the latest version (2012.2.801.2040) from the start, I cleaned and rebuilt the solution and it did not help. When I paste the label definition to the RadPieChart the complirer says

    A value of type 'ChartSeriesLabelDefinition' cannot be added to a collection or dictionary of type 'PresenterCollection`1'.

    Could you please attach a complete example? 

  7. Answer
    Victor
    Admin
    Victor avatar
    1351 posts

    Posted 15 Aug 2012 Link to this post

    Hello Igor,

    When you read the introduction of the help article for the label definitions you will notice that the all series have a LabelDefinitions property which is a collection. You need to put each label definition you define inside this collection. Since you are using the pie series, you need to do this:

    <telerikChart:RadPieChart>
        <telerikChart:PieSeries>
            <telerikChart:PieSeries.LabelDefinitions>
                <telerikChart:ChartSeriesLabelDefinition/>
            </telerikChart:PieSeries.LabelDefinitions>
        </telerikChart:PieSeries>
    </telerikChart:RadPieChart>
    Please write again if you have other questions.

    Kind regards,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner