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>();
                        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.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.

  2. Ves
    Ves avatar
    2916 posts

    Posted 19 Apr 2012 Link to this post


    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,
    the Telerik team

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

Back to Top