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

Changing label step of x-axis dynamically

1 Answer 148 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Douglas
Top achievements
Rank 1
Douglas asked on 13 Apr 2012, 01:23 AM
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?



1 Answer, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 17 Apr 2012, 07:06 PM
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.    

 
Greetings,
Petar Marchev
the Telerik team

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

Tags
Chart
Asked by
Douglas
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Share this question
or