Customizing RadChart layout

3 posts, 1 answers
  1. David Kossatz
    David Kossatz avatar
    5 posts
    Member since:
    Feb 2010

    Posted 09 Feb 2010 Link to this post

    Hey all,

    I am trying to customize my RadChart layout and have something very similiar to the following:

    <UserControl     
        x:Class="TelerikTest.Page2"    
        xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"      
        xmlns:Chart="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting"    
        xmlns:Charting="clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting"                 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     
        xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"    
        xmlns:gauge="clr-namespace:Telerik.Windows.Controls.Gauges;assembly=Telerik.Windows.Controls.Gauge"     
        xmlns:control="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Gauge"     
        >    
        <Grid x:Name="LayoutRoot" Background="White">               
            <Grid.RowDefinitions>    
                <RowDefinition Height="9*"/>    
                <RowDefinition Height="1*"/>    
            </Grid.RowDefinitions>    
            <Border BorderBrush="Aquamarine" BorderThickness="10" Grid.Row="0">    
                <Chart:RadChart x:Name="Chart1" UseDefaultLayout="False" Grid.Row="0">    
                    <Chart:RadChart.LegendStyle>    
                        <Style TargetType="Charting:ChartLegend">    
                            <Setter Property="ItemsPanel" >    
                                <Setter.Value>    
                                    <ItemsPanelTemplate>    
                                        <StackPanel Orientation="Horizontal" />    
                                    </ItemsPanelTemplate>    
                                </Setter.Value>    
                            </Setter>    
                        </Style>    
                    </Chart:RadChart.LegendStyle>    
                    <Grid>    
                        <Grid.RowDefinitions>    
                            <RowDefinition Height="1*" />    
                            <RowDefinition Height="8*" />    
                            <RowDefinition Height="1*" />    
                        </Grid.RowDefinitions>    
        
                        <Charting:ChartArea x:Name="ChartArea1" LegendName="ChartLegend1"     
                                   Grid.Row="1" />    
        
                        <Charting:ChartTitle Content="Sample Report" Grid.Row="0"    
                                    VerticalAlignment="Top" HorizontalAlignment="Center"    
                                     />    
        
                        <Charting:ChartLegend x:Name="ChartLegend1" Header="Legend:"    
                                     Grid.Row="2"    
                                     VerticalAlignment="Top"/>                        
                    </Grid>    
                        
                </Chart:RadChart>    
            </Border>    
            <Button x:Name="Btn" Content="Load" Click="Btn_Click" Grid.Row="1"/>    
        </Grid>    
    </UserControl>    
     

    Also (not shown above), I have a RadGridView that has a DateTime value in the first column, and a few more columns (Value1, Value2, etc).
    I want it to plot each of the Values columns on the Y-axis and the DateTime on the x-axis.  So in the code-behind, I have the SeriesMapping created with the ItemMappings set up properly and I add the each of the SeriesMappings to Chart1.

    So when the user selects some rows, I have in the SelectionChanged event handler to update the Chart1.ItemsSource field but the points do not get graphed! (this is the problem)

    When I don't use my customized layout (and just UseDefaultLayout = True), my points do get graphed.  I've also tried setting the ChartArea1.ItemsSource field to the selected items but that didn't work either.

    Any help would be appreciated!  If you need more info, let me know.

    -David


  2. David Kossatz
    David Kossatz avatar
    5 posts
    Member since:
    Feb 2010

    Posted 10 Feb 2010 Link to this post

    I found a workaround for now...

                RadChart1.ItemsSource = selectedList;  
                ChartArea1.DataSeries.Clear();  
                foreach (var ds in RadChart1.DefaultView.ChartArea.DataSeries)  
                {  
                    ChartArea1.DataSeries.Add(ds);  
                } 

    Once I set the RadChart1.ItemsSource to the selected rows of the GridView, it updates the RadChart1.DefaultView.ChartArea.DataSeries.  I would expect that if I set the ChartArea1.ItemsSource to the selected rows, the ChartArea1.DataSeries would be updated...but it is not.

    Is this the intended behaviour?  Or is there another way I should be doing this?

    Thanks!

    -David
  3. Answer
    Vladimir Milev
    Admin
    Vladimir Milev avatar
    1061 posts

    Posted 12 Feb 2010 Link to this post

    Hi David Kossatz,

    If you intend to use databinding with a ChartArea different from the one in the DefaultView simply use the SeriesMapping.ChartArea or SeriesMapping.ChartAreaName propeties to indicate that.

    Greetings,
    Vladimir Milev
    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.
Back to Top