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

chart series is overriding ...

1 Answer 39 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Asif
Top achievements
Rank 1
Asif asked on 18 Apr 2012, 08:25 AM
I need to some help regarding the chart. I need to show clustered bar chart and have to add series dynamically. Below is my code that builds the chart..
=======================================================================================================
                    List<ChartDispayView> lineResultsList = new List<ChartDispayView>();
                    locChart.SeriesMappings.Clear();
                    
                    foreach (var line in vmRef.ChartLineMasterCollection)
                    {
                        if (line.IsChecked)
                        {
                            lineResultsList.AddRange(this.BuildLineViewChartData(line.LineName, vmRef.ChartResultsCollection.ToList()));

                            SeriesMapping sm = new SeriesMapping() { LegendLabel = line.LineName };
                            sm.ItemMappings.Add(new ItemMapping("PercentageLineOccupation", DataPointMember.YValue));
                            sm.ItemMappings.Add(new ItemMapping("Years", DataPointMember.XCategory));
                            sm.SeriesDefinition = new BarSeriesDefinition() { ShowItemLabels = true, ShowItemToolTips = true };
                            locChart.SeriesMappings.Add(sm);
                        }
                    }

                    locChart.ItemsSource = lineResultsList;
=======================================================================================================



It shouldn't create overwrite existing series.

Please guide me what i am doing wrong in the code and how to fix this issue.

Thanks

1 Answer, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 19 Apr 2012, 03:20 PM
Hello,

The chart configuration is correct and the chart would appear just fine, given that the datasource contains a single value for each category in a series (that is: only one item with LineName = "Apple Line" and Years = "2HJ2012" should appear in the date). It seems this is not the case here -- there are two such items: one with PercentageLineOccupation = 146.64 and another one with PercentageLineOccupation = 19.48. I am not sure of the expected result in this case - if you expect two blue bars side by side, you will have to ensure that each of them goes into different series.

Kind regards,
Ves
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Chart
Asked by
Asif
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or