Changing label step of x-axis dynamically

2 posts, 0 answers
  1. Douglas
    Douglas avatar
    15 posts
    Member since:
    Feb 2012

    Posted 12 Apr 2012 Link to this post

    I have a chart with several series.  The data comes from a web service asynchronously.  

    Data in the chart can be updated by choosing different date ranges.

    What is the best way to figure out how many items are in the chart and calculate the label step so that we only show about 10 labels along the x-axis no matter how many items are in the chart?

    Right now I am getting the count of how many items are in one of the series and then calculating label step based on that.  But this has a few issues because I don't know if that series will always have items in it and I don't know if it will have the most items in it.  That leads me to think I could try to consider all the series, but that starts to get complicated and there must be an easier/cleaner way?  Is there anything in the telerik chart components that allows us to restrict the x-axis to only showing x number of labels?

  2. Petar Marchev
    Petar Marchev avatar
    996 posts

    Posted 17 Apr 2012 Link to this post

    Hi Douglas,
    Are you using XCategory or XValue? I think that if you use XValue you shouldn't have such problems (by keeping the x axis AutoRange=true).

    If you use XCategory - then the axis wants to show each category because categories are meant to be totally different - such as "Apples", "Carrots", "Tomatoes" and so on. And this is why you get a label for each data point.

    I would generally suggest updating your project to work with XValue. If it is not possible to switch to XValue - then iterating through all the series and counting the data points is the only way to go.    

    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top