chart series is overriding ...

2 posts, 0 answers
  1. Asif
    Asif avatar
    1 posts
    Member since:
    Jan 2012

    Posted 18 Apr 2012 Link to this post

    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
  2. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 19 Apr 2012 Link to this post

    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top