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

clone chart legend

1 Answer 49 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Tamas
Top achievements
Rank 1
Tamas asked on 06 Sep 2010, 09:27 PM
Hi,

I'd like to display the legend of a RadChart out of the chart. Is this possible? I have a tabcontrol with several tabitems. There is a tabitem with a radchart on it, which is filled with data and the legend items are generated automatically. After this I'd like to display the legend of the chart in another tabitem.

Is this possible?

Many thanks and best regards,
Tamás

1 Answer, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 09 Sep 2010, 09:48 AM
Hello Tamas,

You can achieve the desired effect like this:

XAML
<telerik:RadTabControl Height="600" Width="800">
    <telerik:RadTabItem Header="Chart">
        <telerik:RadChart x:Name="RadChart1" >
            <telerik:RadChart.DefaultView>
                <telerik:ChartDefaultView>
                    <telerik:ChartDefaultView.ChartArea>
                        <telerik:ChartArea Legend="{Binding ElementName=ChartLegend1}" />
                    </telerik:ChartDefaultView.ChartArea>
                    <telerik:ChartDefaultView.ChartLegend>
                        <telerik:ChartLegend Visibility="Collapsed" />
                    </telerik:ChartDefaultView.ChartLegend>
                </telerik:ChartDefaultView>
            </telerik:RadChart.DefaultView>
        </telerik:RadChart>
    </telerik:RadTabItem>
    <telerik:RadTabItem Header="Legend">
        <telerik:ChartLegend x:Name="ChartLegend1" />
    </telerik:RadTabItem>
</telerik:RadTabControl>

C#
public partial class MainPage : UserControl
{
    public MainPage()
    {
        InitializeComponent();
 
        Random rand = new Random(123456);
        List<ChartData> data = new List<ChartData>();
        for (int i = 0; i < 10; i++)
            data.Add(new ChartData() { XValue = i, YValue = rand.Next(10, 100) });
 
        SeriesMapping sm = new SeriesMapping();
        sm.ItemMappings.Add(new ItemMapping("XValue", DataPointMember.XValue));
        sm.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue));
 
        RadChart1.SeriesMappings.Add(sm);
        RadChart1.DefaultSeriesDefinition = new DoughnutSeriesDefinition();
        RadChart1.ItemsSource = data;
    }
}
 
public class ChartData
{
    public double YValue
    {
        get;
        set;
    }
 
    public double XValue
    {
        get;
        set;
    }
}


Hope this helps.


Kind regards,
Freddie
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
Tamas
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Share this question
or