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

Problem with Silverlight Radchart

2 Answers 29 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Yathish
Top achievements
Rank 1
Yathish asked on 30 Dec 2011, 04:29 PM
Hi,

I am facing a strange problem with silverlight radchart.

Code:
            // Name the x-axis scale items

            TickPointCollection tickPoints = radChart1.DefaultView.ChartArea.AxisX.TickPoints;

            string[] months = new string[] { "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Jan", "Feb", "Mar" };

            for (int i = 0; i < tickPoints.Count; i++)

            {

                radChart1.DefaultView.ChartArea.AxisX.TickPoints[i].Label = months[i];

            }

This code is to label the x-axis with the months names. Few times, this code works beautiful - but most of the time, it results in a out of index exception.
When we try to debug this code and see the quick watch value of Tickpoints[i] in the for loop, we can see the Tickpoints number shows 11 at some time and 0 at sometimes. I am not able to understand what is missing here?

Any help is highly appreicated.

Thanks & Regards,
YK

2 Answers, 1 is accepted

Sort by
0
Accepted
Evgenia
Telerik team
answered on 04 Jan 2012, 09:43 AM
Hello Yathish,

  The reason for this out of index exception is that you may have tickpoints less than the number of the strings in your months array. For example if you have 5 datapoints (your XAxis will show the numbers from 1 to 5). However you try to assign the 6-th, 7-th and etc. tickpoints labels "Jun, "Jul" and etc.
I suggest that you provide a manual Range for your Axis so that the number of Tickpoints will always be equal to the number of strings you want to assign. To have a manual range you should set your AutoRange property to false and provide custom MinValue, MaxValue and Step. More information can be found here.    

Regards,
Evgenia
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Yathish
Top achievements
Rank 1
answered on 08 Jan 2012, 06:58 AM
Thanks Evgenia .

Regards,
YK
Tags
General Discussions
Asked by
Yathish
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Yathish
Top achievements
Rank 1
Share this question
or