Bar chart dynamic series

2 posts, 0 answers
  1. Arun Kumar
    Arun Kumar avatar
    60 posts
    Member since:
    Nov 2009

    Posted 19 Jul 2011 Link to this post

    Hi All,

    I have the following data (City, Description, Counts) returned from database

    City,            Description,      Counts
    Beirut Desc - 1 10000
    Beirut Desc - 2 100
    Beirut Desc - 3 5
    Beijing   Desc - 1 90
    Japan Desc - 3 2
    Singapore   Desc - 2 2300

    Here not always all city will load. Based on some filters data is populated.

    I want to show Description in xcategory and Counts in YValue and city will be series and legend value.

    I am using group description based on city but its not giving correct result. Also I tried to add series based on cities but that also not working (showing all description as same value (i.e) first series value). 

    How do I create bar chart for this?

  2. Missing user
    Missing user avatar

    Posted 22 Jul 2011 Link to this post

    Hello Arun Kumar,

    You can use SeriesMapping.GroupingSettings to group the data by City. You also need to set the Description field as XCategory DataPointMember. For example:
    <telerik:RadChart x:Name="radChart">
                    <telerik:BarSeriesDefinition />
                    <telerik:GroupingSettings ShouldCreateSeriesForLastGroup="True">
                            <telerik:ChartGroupDescriptor Member="City"/>
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="Counts" />
                    <telerik:ItemMapping DataPointMember="XCategory" FieldName="Description" />

    and the code-behind:
    List<MyDataItem> data = new List<MyDataItem>()
        new MyDataItem() {City = "Beirut", Counts = 10000, Description = "1"},
        new MyDataItem() {City = "Beirut", Counts = 100, Description = "2"},
        new MyDataItem() {City = "Beirut", Counts = 5, Description = "3"},
        new MyDataItem() {City = "Beijing", Counts = 90, Description = "1"},
        new MyDataItem() {City = "Japan", Counts = 2, Description = "3"},
        new MyDataItem() {City = "Singapore", Counts = 2300, Description = "2"}
    radChart.ItemsSource = data;
    public class MyDataItem
        public string City { get; set; }
        public string Description { get; set; }
        public double Counts { get; set; }

    For additional information on grouping functionality, please refer to the following help topic:

    I hope that this helps.

    Kind regards,
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. DevCraft banner
Back to Top