How to show RadPieChart Legend

5 posts, 0 answers
  1. Jonas
    Jonas avatar
    1 posts
    Member since:
    Sep 2008

    Posted 22 Oct 2012 Link to this post

    How can I show the legend list for my radpiechart? And is there a way to hide the labels?

    <telerik:RadPieChart Grid.Column="4" Grid.Row="1" Grid.RowSpan="8" DataContext="{Binding Path=BidKpiViewModel, Mode=TwoWay}" Name="radPieChart1" VerticalAlignment="Center"
                                            Height="250" Width="250" HorizontalAlignment="Center">
                            <telerik:RadPieChart.Palette>
                                <telerik:ChartPalette>
                                    <telerik:ChartPalette.GlobalEntries>
                                        <telerik:PaletteEntry Fill="#000080" />
                                        <telerik:PaletteEntry Fill="#0000FF" />
                                        <telerik:PaletteEntry Fill="#0080FF" />
                                        <telerik:PaletteEntry Fill="#00FFFF" />
                                        <telerik:PaletteEntry Fill="#00FF80" />
                                        <telerik:PaletteEntry Fill="#00FF00" />
                                        <telerik:PaletteEntry Fill="#80FF00" />
                                        <telerik:PaletteEntry Fill="#FFFF00" />
                                        <telerik:PaletteEntry Fill="#FF8000" />
                                        <telerik:PaletteEntry Fill="#FF0000" />
                                        <telerik:PaletteEntry Fill="#800000" />
                                    </telerik:ChartPalette.GlobalEntries>
                                </telerik:ChartPalette>
                            </telerik:RadPieChart.Palette>
                            <telerik:RadPieChart.Series>
                                <telerik:PieSeries ItemsSource="{Binding Path=WbsBreakdown, Mode=TwoWay}" ValueBinding="Percent" DisplayName="KPI Break down" ShowLabels="True" RadiusFactor="0.6">
                                    <telerik:PieSeries.LabelDefinitions>
                                        <telerik:ChartSeriesLabelDefinition Margin="-30" Binding="WbsCodeString" />
                                    </telerik:PieSeries.LabelDefinitions>
                                </telerik:PieSeries>
                            </telerik:RadPieChart.Series>
                        </telerik:RadPieChart>
  2. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 24 Oct 2012 Link to this post

    Hi,

    is there a way to hide the labels?
    In your code you have set the ShowLabels to true. To hide the labels you need to set it to false.

    How can I show the legend list for my radpiechart?
    The RadChartView does not offer a built-in legend. This means that you have the full freedom of implementing a legend based on your specifications.

    Kind regards,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Jan
    Jan avatar
    24 posts
    Member since:
    Nov 2011

    Posted 31 Jan 2014 in reply to Petar Marchev Link to this post

    Telerik / Petar,

    With regards to implementing a legend "based on your specification", the biggest issue with this is color matching. How do I get the colors used in the chart and implement them in, say, my own stack panel of TextBlock? By not generating the legend during the chart generation, I fail to see how this can be accomplished unless there is a way to access the same list of colors, in the same order, that the chart itself is using. Can you offer insight? This is plaguing me right now as I try to convert to "RadChartView" paradigm. (As an aside, please note to people that RadChartView is not an actual class for making charts.)

    Thank you.
  5. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 01 Feb 2014 Link to this post

    Hello Nelson,

    You have found an old thread, from 2012. It is now 2014 and the ChartView has legend support. You can see this demonstrated in many of our online QSF examples. I have also attached a simple project to demonstrate the integration between the RadPieChart and RadLegend controls.

    Regards,
    Petar Marchev
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  6. Jan
    Jan avatar
    24 posts
    Member since:
    Nov 2011

    Posted 03 Feb 2014 in reply to Petar Marchev Link to this post

    Thank you, Petar. Unfortunately, your online demos and the link you referenced do not show legends.

    However, thank you for the demo. It was very helpful.

    Just for further clarification for anyone else reading this, the RadLegend binds to a property of the chart itself. The property is called LegendItems. At first glance it may appear that you must supply a property of this name in your underlying DataContext but that is incorrect. The DataContext of the RadLegend is apparently set automatically to the targeted chart.

    Here is a simple legend:

    <telerik:RadLegend Items="{Binding LegendItems, ElementName=MyChart}" />
Back to Top
DevCraft banner