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

How to show RadPieChart Legend

4 Answers 178 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Jonas
Top achievements
Rank 1
Jonas asked on 22 Oct 2012, 11:22 PM
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>

4 Answers, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 24 Oct 2012, 08:47 AM
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.

0
Jan
Top achievements
Rank 1
answered on 31 Jan 2014, 05:32 PM
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.
0
Petar Marchev
Telerik team
answered on 01 Feb 2014, 01:44 PM
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 >>
0
Jan
Top achievements
Rank 1
answered on 03 Feb 2014, 03:43 PM
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}" />
Tags
Chart
Asked by
Jonas
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Jan
Top achievements
Rank 1
Share this question
or