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

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

1 Answer 60 Views
Chart
This is a migrated thread and some comments may be shown as answers.
kakit
Top achievements
Rank 1
kakit asked on 21 Dec 2010, 03:47 AM
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?

1 Answer, 1 is accepted

Sort by
0
Evgeni "Zammy" Petrov
Telerik team
answered on 23 Dec 2010, 05:39 PM
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
Tags
Chart
Asked by
kakit
Top achievements
Rank 1
Answers by
Evgeni "Zammy" Petrov
Telerik team
Share this question
or