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

Fixed Width Legend with Legend Label Text Wrapping

2 Answers 523 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 01 Oct 2010, 08:46 PM
I'm trying to set my ChartLegend to a fixed width and wrap the LegendLabel text to fit inside it.

How can I do this?

2 Answers, 1 is accepted

Sort by
0
Tim
Top achievements
Rank 1
answered on 02 Oct 2010, 03:01 PM
I would like to know this as well.  My legend takes up more space than my pie chart.  A scroll bar list box would be great.
0
Evgenia
Telerik team
answered on 06 Oct 2010, 12:43 PM
Hi,

By default the ChartLegend uses a vertical StackPanel to arrange its children. Its legend items are made to fit the size of the legend. You can set legend's size to fixed value like this:

radChart.DefaultView.ChartArea.Legend.Width = 100;
NOTE that as soon as you set legend's size to custom value your legend items maybe chopped off (not quite visible) so you should decrease FontSize value of text and retemplate the LegendItemMarker. 

What I suggest you is a work-around - by aligning the legend to the top or bottom. Check this demo for tips on how to do it.

If you want to keep the position of the legend at right you can add a ScrollViewer control in order to be able to show large number of chart legend items in a limited space. For more information take a look at this blogpost: http://blogs.telerik.com/velinangelov/posts/09-12-23/silverlight_wpf_custom_legend_with_radchart.aspx
(the style at the bottom of the post).

Hope this helps.

Kind regards,
Evgenia
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Daniel
Top achievements
Rank 1
Answers by
Tim
Top achievements
Rank 1
Evgenia
Telerik team
Share this question
or