Quick question about databinding to manual data series

5 posts, 0 answers
  1. Marcus Lambert
    Marcus Lambert avatar
    41 posts
    Member since:
    Aug 2009

    Posted 23 Nov 2009 Link to this post

    Hi,
    I am binding a List to a bar chart and defining a Series Mapping.
    The problem I am having is that if I change the List in my ViewModel the chart seem to think that the it now has another series.
    That is a nice feature but I dont want it to happen, is there a way to clear the orginal ?
    Below is how I am binding ...

    Thanks

     <Telerik_Windows_Controls:RadChart UseDefaultLayout="False" ItemsSource="{Binding BIStatEmailUsers, Mode=OneWay}" Grid.Row="4" d:LayoutOverrides="Width" Height="300" >
       <Telerik_Windows_Controls:RadChart.DefaultSeriesDefinition>
        <Telerik_Windows_Controls_Charting:HorizontalStackedBarSeriesDefinition/>
       </Telerik_Windows_Controls:RadChart.DefaultSeriesDefinition>
       <Telerik_Windows_Controls:RadChart.SeriesMappings>
        <Telerik_Windows_Controls_Charting:SeriesMapping ChartAreaName="TopInternalUsers">
         <Telerik_Windows_Controls_Charting:SeriesMapping.ItemMappings>
          <Telerik_Windows_Controls_Charting:ItemMapping FieldName="total"/>
          <Telerik_Windows_Controls_Charting:ItemMapping DataPointMember="XCategory" FieldName="lastname"/>
         </Telerik_Windows_Controls_Charting:SeriesMapping.ItemMappings>
        </Telerik_Windows_Controls_Charting:SeriesMapping>
       </Telerik_Windows_Controls:RadChart.SeriesMappings>
    <Telerik_Windows_Controls:RadChart/>
  2. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 26 Nov 2009 Link to this post

    Hi Marcus,

    This is a known issue. It is already fixed. Expect the service pack in the first half of December.

    Best,
    Evtim
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Nathan
    Nathan avatar
    24 posts
    Member since:
    Sep 2009

    Posted 18 Jan 2010 Link to this post

    Hello,

    Any update on this issue? I just updated to 2009.3.1314 (trial) and I still get similar results.

    I am setting my itemsource in code, but when I do something like this I get duplicate charts:

     

     

    RadChart1.ItemsSource = Nothing 
     
    RadChart1.ItemsSource = oCol (observable collection I am binding to)  
     


    Any update would be appreciated!

    Thanks,
    Nathan

     

     

     

     

  5. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 21 Jan 2010 Link to this post

    Hi Nathan,

    I have attached a small example -- binding RadChart to observable collection. Can you please update it, so that the issue is reproduced?

    Best regards,
    Ves
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Nathan
    Nathan avatar
    24 posts
    Member since:
    Sep 2009

    Posted 21 Jan 2010 Link to this post

    Hi Ves,

    I did manage to recreate this issue, but at the same time found what I am doing wrong. When refreshing the chart, I not only have to clear the itemsource but also the seriesmappings since I am adding them dynamically in code - not in xaml.

    So this replicates the duplication (commenting out the seriesmappings defined in xaml):
            private void LoadData()  
            {  
                RadChart1.ItemsSource = null;  
     
                SeriesMapping sm1 = new SeriesMapping();  
                sm1.CollectionIndex = 0;  
                sm1.SeriesDefinition = new BarSeriesDefinition();  
                sm1.LegendLabel = "My legend";  
     
                ItemMapping yMap = new ItemMapping("MyProperty", DataPointMember.YValue);  
                ItemMapping xMap = new ItemMapping("MyDescription", DataPointMember.XCategory);  
     
                sm1.ItemMappings.Add(yMap);  
                sm1.ItemMappings.Add(xMap);  
     
                RadChart1.SeriesMappings.Add(sm1);  
     
                ObservableCollection<ObservableCollection<MyObject>bindData = new ObservableCollection<ObservableCollection<MyObject>>();  
     
                data = new ObservableCollection<MyObject>()  
                {  
                    new MyObject() {MyProperty=4MyDescription="Number A"},  
                    new MyObject() {MyProperty=3MyDescription="Number B"},  
                    new MyObject() {MyProperty=2,  MyDescription="Number C"},  
                    new MyObject() {MyProperty=4,  MyDescription="Number D"}  
                };  
     
                bindData.Add(data);  
     
                RadChart1.ItemsSource = bindData;  
            } 

    But if I do this when clearing out the old data it now works great!

     

                RadChart1.ItemsSource = null;  
                RadChart1.SeriesMappings.Clear(); 

    This all makes sense since I am adding series mappings directly to the chart I would also have to remove them (or skip adding them again) on a refresh. Since the user can change the chart type (say from vertical to horizontal bar) I simply remove all series mappings
    and rebuild the entire chart.

    Thanks for the help (and the great controls)!

Back to Top
DevCraft banner