How to Change the RadChart's Item Soucre while update RadChart

2 posts, 0 answers
  1. kakit
    kakit avatar
    1 posts
    Member since:
    Dec 2010

    Posted 20 Dec 2010 Link to this post

    How can I  Change the RadChart's Item Soucre while update RadChart,

    private void UpdateBarChart(RadChart chart, string region, ObservableCollection<StoreAnalysis> storeAnalysisList)
            {
                chart.DefaultView.ChartTitle.Content = "Region Performance - Region Comparsion";
                chart.SeriesMappings.Clear();
                chart.ItemsSource = storeAnalysisList;
                chart.SeriesMappings = new SeriesMappingCollection();
               
                SeriesMappingCollection seriesMapping = new SeriesMappingCollection();
                ChartAggregateFunction aggFunct = ChartAggregateFunction.Sum;
                SeriesMapping seriesMap = new SeriesMapping();
                seriesMap.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor("Period"));
                seriesMap.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor("StoreName"));
                seriesMap.ItemMappings.Add(new ItemMapping("Sales", DataPointMember.YValue, aggFunct));
                seriesMap.ItemMappings.Add(new ItemMapping("StoreName", DataPointMember.XCategory));
                chart.SeriesMappings.Add(seriesMap);

                chart.DefaultView.ChartArea.StartTransitionAnimation();
                chart.Rebind();
            }

    it will cause error from this code when run "chart.SeriesMappings.Add(seriesMap);"
    am i miss something?

  2. Evgeni "Zammy" Petrov
    Admin
    Evgeni "Zammy" Petrov avatar
    168 posts

    Posted 23 Dec 2010 Link to this post

    Hello kakit,

     First you should not create new SeriesMappingCollection, clearing is it more than enough.
    There is no need to call Rebind if you have databound RadChart to an ObservableCollection.

    This is all I can infer from the source code you have sent 

    If you still have this problem please provide us with additional details about the specific scenario.

    Kind regards,
    Evgeni "Zammy" Petrov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
Back to Top