Adding to the X-Axis

Thread is closed for posting
2 posts, 0 answers
  1. Jeff
    Jeff avatar
    10 posts
    Member since:
    Mar 2009

    Posted 07 Apr 2009 Link to this post

    I'm trying to create a chart with custom x-axis values. Right now, they are defaulting to 1, 2, 3, 4, 5...etc.
    I need them to be a specific string value from the datatable. "P 2009, P 2010, P 2010, etc. etc."
    There are several things that are dependent on the for loop below (which I left out) which is why I need to keep the for loop.
    I cannot bind the series to the datatable. I know that would be much easier, but a lot of functionality is dependent on the for loop below. How may I add the X-axis values?

    (int idx = 0; idx < dtDataTable.Rows.Count; idx++)





      int iValue = Convert.ToInt32(dtDataTable.Rows[idx][sSeries]);



      string sLabel = iValue.ToString("#,#", CultureInfo.InvariantCulture);


      csGLFunc.AddItem(iValue, sLabel);






    Any help would be very much appreciated.

    Thank you.




  2. Dessy
    Dessy avatar
    73 posts

    Posted 10 Apr 2009 Link to this post

    Hi Jeff,

    In order to achieve this, you should set AutoScale property to false.

    RadChart1.PlotArea.XAxis.AutoScale = false;

    Then, that one option for adding  items to XAxis would be to use AddItem method of the Axis inside the same loop:


    where label is the string variable which will be added to XAxis.


    Hope that helps.

    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Back to Top