how to make StackedBar100 X-Axis show words instead of number

4 posts, 0 answers
  1. Jasmine Zong
    Jasmine Zong avatar
    2 posts
    Member since:
    Feb 2010

    Posted 15 Feb 2010 Link to this post

    I am try to create a stackedbar100 chart, everything looks fine for me, except I cannot display the words in the x-Axis, at the moment, the x-Axis only display numbers, such as (1  2   3   4 ...), I want this changed to a list of words, i.e. (Ford    Toyota    Honda ....).  When I try to map it to a list of class (as below), it always give me this error : No IEnumerable item found at index: 0 in the ItemsSource!. So can you show me how to do this, thanks a lot.

                SeriesMapping seriesMapping = new SeriesMapping();
                seriesMapping.SeriesDefinition = new StackedBar100SeriesDefinition();
                seriesMapping.ItemMappings.Add(new ItemMapping("brand", DataPointMember.XValue));
                seriesMapping.ItemMappings.Add(new ItemMapping("percent", DataPointMember.YValue));
                radChart.SeriesMappings.Add(seriesMapping);
                radChart.ItemsSource = CreatePercentage();
  2. Bartholomeo Rocca
    Bartholomeo Rocca avatar
    247 posts
    Member since:
    May 2006

    Posted 16 Feb 2010 Link to this post

    Hello Jasmine,

    You need to map the DataPointMember.XCategory instead of XValue in this scenario - http://www.telerik.com/help/silverlight/radchart-features-categorical-charts.html.


    Greetings,
    Bart.
  3. Jasmine Zong
    Jasmine Zong avatar
    2 posts
    Member since:
    Feb 2010

    Posted 17 Feb 2010 Link to this post

    Hi Bartholomeo,

    I still have some trouble after I change from XValue to XCategory , as I create a list to provide the data for StackedBar100 (as below), but I got the error message said: Unhandled Error in Silverlight Application No IEnumerable item found at index: 0 in the ItemsSource!.
    So I am wondering if you help with this IEnumerable problem, or show me how to create stackedbar100 chart using method as:
    dataSeries.Add( new DataPoint() { YValue = [20,30,10,20,15,15], XCategory = "Grapes" }) (as I tried, but DataPoint doesn't support an array of data). Thanks a lot.

    SeriesMapping seriesMapping = new SeriesMapping();
    seriesMapping.SeriesDefinition = new StackedBar100SeriesDefinition();
     seriesMapping.ItemMappings.Add(new ItemMapping("country", DataPointMember.XCategory));
    seriesMapping.ItemMappings.Add(new ItemMapping("percent", DataPointMember.YValue));
    radChart.SeriesMappings.Add(seriesMapping);
    radChart.ItemsSource = CreatePercentage();

        public List<percentageList> CreatePercentage()
            {
                List<percentageList> plist = new List<percentageList>();           
                for (int i = 0; i < 12; i++)
                {
                    plist.Add(new percentageList(i, GerRandomPercentageData(i)));
                }
                return plist;
            }
        }

        public class percentageList
        {
            public string country { get; set; }
            public double[] percent { get; set; }
            public percentageList(string country, double[] percent)
            {
                this.country = country;
                this.percent = percent;
            }
        }
  4. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 19 Feb 2010 Link to this post

    Hello Jasmine,

    The ItemMapping between DataField and DataPointMember defines one-to-one relationship (i.e. the DataField should be resolved to a scalar value and you have defined the percent property as a double array). Please modify the property type to double and the control will behave as expected.


    All the best,
    Manuel
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top