This is a migrated thread and some comments may be shown as answers.

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

3 Answers 76 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Jasmine Zong
Top achievements
Rank 1
Jasmine Zong asked on 15 Feb 2010, 11:28 PM
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();

3 Answers, 1 is accepted

Sort by
0
Bartholomeo Rocca
Top achievements
Rank 1
answered on 16 Feb 2010, 08:09 AM
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.
0
Jasmine Zong
Top achievements
Rank 1
answered on 18 Feb 2010, 01:50 AM
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;
        }
    }
0
Giuseppe
Telerik team
answered on 19 Feb 2010, 09:43 AM
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.
Tags
Chart
Asked by
Jasmine Zong
Top achievements
Rank 1
Answers by
Bartholomeo Rocca
Top achievements
Rank 1
Jasmine Zong
Top achievements
Rank 1
Giuseppe
Telerik team
Share this question
or