I am going to use a RadCartesianChart to show a point series with DataTimeContinuousAxis as my Horizontal axis and Linear Vertical axis. My requirement is that I want to show only those DateTime axis labels where I have some data point. Also instead of showing it as DateTime I want to bind to some other string.Except those other axis labels should be hidden (where no data point is present). How do I Achieve this?
4 Answers, 1 is accepted
If we understand you correctly you want to show only the labels on the Horizontal axis which have DataPoint and present them with a string different from the date format. Correct us if we are wrong. Basically, DateTimeContinuousAxis is like a numerical axis and the values are always sorted chronologically. For example, you cannot have one step represented by one day and then another step for two days interval. If it is appropriate for your scenario we advise you to consider using CategoricalAxis instead.
As for the second question in your post, using a CategoricalAxis you can specify a string which will represent the label values and bind it to the X value of the data points, instead of the date property.
Hope this information is helpful.
I would like to restate, I am using a Linear axis as Horizontal and Vertical. In the horizontal axis I want to make only those axis Labels visible where I have original DataPoints. (Eg. Say my points are pt1=(2,10) pt2= (6,5) pt3=(7,4). Make only 2,6,7 visible in horizontal axis. Also instead of 2, 6,7 I want to display strings (2=second, 6=Sixth,7=Seventh). How do I acheive this? I cannot use categorical axis because the chart is continuous. And positions of 2,6,7 should be as in Linear Axis.
The Linear axis doesn't support the behavior mentioned in your last reply out of the box. Basically, the Linear axis is a continuous one the chart tries to position labels in a numerical manner and at equal distances (evenly distributed). For example, 0, 5 and 10 are evenly distributed, where 2, 6 and 7 are not (because 2 is much closer to 6 than 7 is).
We think that in order to clearly visualize the scenario, it would be best if you leave the numerical axis as it is and use datapoint labels (ShowLabels property of the series). This way, the user will know very well the range of the axis and he will also see the labels of the data points, so their values will be clear too.
If you insist on the look you describe, you can hide the labels on the Horizontal axis using the ShowLabels property set to false. Then you can create custom annotations for the values you want to display, and position them at the bottom, where the horizontal axis is. You can take a look at the following resources below:
- Custom Annotations - help article which describes how you can create a custom annotation.
- ChartView Annotation - online example demo which demonstrates a possible way of using annotation
- AnnotationTypes - SDK example where you can examine the different types of annotations
Thank you very much for the detailed information. I too feel by showing Labels on points and annotations this could be achieved.