This question is locked. New answers and comments are not allowed.
I think there's a problem to change legend panel orientation when RadChart control starts with that panel visibility collapsed.
I have a project with two RadChart controls with same data. First control starts with legend panel visible, the second starts with panel collapsed.
I have a button for each control to change orientation. For the first chart, changing orientation works fine, for the other doesn't.
I'm using RadControls for Silverlight v2010.1.422.
sample XAML:
| <Grid x:Name="LayoutRoot"> |
| <StackPanel Orientation="Vertical"> |
| <telerik:RadChart x:Name="rChart1" Width="300" Height="200"/> |
| <Button Content="Orientation" Click="Orientation1_Click" Margin="10" Width="80"/> |
| <telerik:RadChart x:Name="rChart2" Width="300" Height="200" Margin="50,0,0,0"/> |
| <Button Content="Orientation" Click="Orientation2_Click" Margin="10" Width="80"/> |
| </StackPanel> |
| </Grid> |
Code-Behind:
| public MainPage() |
| { |
| InitializeComponent(); |
| List<ChartData> data = new List<ChartData>(); |
| data.Add(new ChartData { Name = "A", Value = 1 }); |
| data.Add(new ChartData { Name = "B", Value = 2 }); |
| data.Add(new ChartData { Name = "C", Value = 3 }); |
| data.Add(new ChartData { Name = "D", Value = 4 }); |
| SeriesMapping sm = new SeriesMapping(); |
| sm.ItemMappings.Add(new ItemMapping("Name", DataPointMember.XCategory)); |
| sm.ItemMappings.Add(new ItemMapping("Value", DataPointMember.YValue)); |
| sm.ItemMappings.Add(new ItemMapping("Name", DataPointMember.LegendLabel)); |
| rChart1.ItemsSource = data; |
| rChart1.DefaultSeriesDefinition = new PieSeriesDefinition(); |
| rChart1.SeriesMappings.Add(sm); |
| rChart1.DefaultView.ChartArea.Legend.ItemsPanelOrientation = Orientation.Vertical; |
| rChart2.ItemsSource = data; |
| rChart2.DefaultSeriesDefinition = new PieSeriesDefinition(); |
| rChart2.SeriesMappings.Add(sm); |
| rChart2.DefaultView.ChartLegend.Visibility = Visibility.Collapsed; |
| } |
| private void Orientation1_Click(object sender, RoutedEventArgs e) |
| { |
| Orientation o = rChart1.DefaultView.ChartArea.Legend.ItemsPanelOrientation; |
| if (o.Equals(Orientation.Horizontal)) rChart1.DefaultView.ChartArea.Legend.ItemsPanelOrientation = Orientation.Vertical; |
| else rChart1.DefaultView.ChartArea.Legend.ItemsPanelOrientation = Orientation.Horizontal; |
| } |
| private void Orientation2_Click(object sender, RoutedEventArgs e) |
| { |
| Visibility v = rChart2.DefaultView.ChartLegend.Visibility; |
| if (v.Equals(Visibility.Collapsed)) rChart2.DefaultView.ChartLegend.Visibility = Visibility.Visible; |
| Orientation o = rChart2.DefaultView.ChartArea.Legend.ItemsPanelOrientation; |
| if (o.Equals(Orientation.Horizontal)) rChart2.DefaultView.ChartArea.Legend.ItemsPanelOrientation = Orientation.Vertical; |
| else rChart2.DefaultView.ChartArea.Legend.ItemsPanelOrientation = Orientation.Horizontal; |
| } |
ChartData is a separate class file with two automatic properties: Name and Value