Best way to load data in Stacked Bar Chart

2 posts, 0 answers
  1. Donald Hamm
    Donald Hamm avatar
    21 posts
    Member since:
    May 2008

    Posted 17 Jul 2009 Link to this post

    I have a List collection of data with a cateory name  and a int array (4 elements) for the stacked bar.  What is the best way to load the stacked bar so the category name shows in the x axis and the chart can use the int array?  The examples do not show how the 'label' can be defined.  All current examples use 'doubles' array of doubles...

    E.G.,  class with values to load...

    public class StackedBarData
        _private int[] = _barDataPoints = null;
       public int[] BarDataPoints  
            // loaded from database call outside of class...
            get { return this._barDataPoints ;}
            set { this._barDataPoints = value;}

       _private string _categoryName = "";
       public string CategoryName
            get {return this._categoryName;}
            set {this._categoryName = value;}

    the int array has 4 elements.

    here is how I setup the  the series:


    int seriesIndex = 0;





    SeriesMapping sm1 = new SeriesMapping();





    StackedBarSeriesDefinition d1 = new StackedBarSeriesDefinition();


    d1.StackGroupName =



    sm1.SeriesDefinition = d1;


    sm1.LegendLabel =



    "Show Me the Ints 1"; // name for each item to show...


    sm1.CollectionIndex = seriesIndex++; // index into the int array to show data points...




    ItemMapping im1 = new ItemMapping("BarDataPoints", DataPointMember.YValue); // contains 4 data elements to show



    im1 =



    new ItemMapping("CategoryName", DataPointMember.XCategory); // name from class property



    (etc for each of the 4 Mapping entries)

    // now add to the chart...

    List<StackedBarData> listOfDataPoints= new List<StackedBarData>();

    int [4] data = new int[] { 55, 22, 63, 74};

    StackedBarData barData = new StackedBarData();
    barData.CateoryName = "My New Int 1";
    barData.BarDataPoints = data;

    // add rest of data points...





    (etc for the rest of mappings)

    // assign to the chart...






    this.RadProgramSiteChart.ItemsSource = listOfDataPoints;

    When I use this, I get the IEnumerable error (can't find the array of ints)..
    Where did I go wrong?









  2. Vladimir Milev
    Vladimir Milev avatar
    1061 posts

    Posted 21 Jul 2009 Link to this post

    Hi Donald Hamm,

    Check this help article. It explains the best way to deal with categories.

    Kind regards,
    Vladimir Milev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top