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

X Axis Dates are not distinct

1 Answer 66 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 24 May 2013, 10:52 PM
I am trying to set my x axis as a date. When I do that it seems to generate a random number of labels where only one has a value associated with it.

For example, if i had these two items:

measures.Add(new RandomItem{ Date = DateTime.Now.AddDays(-3).Date, ValOne= 5, ValTwo = 4, ValThree = 3, ValFour = 2, ValFive = 1 });
measures.Add(new RandomItem{ Date = DateTime.Now.AddDays(-2).Date, ValOne= 5, ValTwo = 7, ValThree = 3, ValFour = 2, ValFive = 1 });

The graph has the x-axis set to autocalculate and I get 13 values on the x-axis but only two distinct and only two are populated with the values above
           
<telerik:ChartArea.AxisX>
 <telerik:AxisX  LabelRotationAngle="90" Title="Day of Month"   IsDateTime="True"    />
 </telerik:ChartArea.AxisX>

What am I doing wrong? How can i get the graph to only show distinct values? I have a series set up for each val where the date is the XValue. This is an MVVM project.

1 Answer, 1 is accepted

Sort by
0
Petar Kirov
Telerik team
answered on 29 May 2013, 04:41 PM
Hi Chris,

The RadChart's axes have two modes - categorical and numerical. In numerical mode, the series associated with the axis are positioned  according their XValue (of their data points) which should be a number or DateTime. When the axis is AutoRange mode, the axis calculates MinValue and MaxValue, and depending on the available horizontal space -  Step, so that when more space is available more MajorTicks and Labels are displayed and when there is less space - less labels and MajorTicks.

In the categorical mode the chart will position the items on equal distance from one another (as if the x axis is not continuous, but behaving like slot collection - each item sits on its own slot) and will display an axis label per each item. This label is actually the the XCategory DataPointMember. There are no restrictions to the type. If it is different than string, int or DateTime then the default string from
DataItem.[associated_with_XCategory_property].ToString() is displayed

That's said, I believe that changing the XValue binding to XCategory should fulfil your requirements. I have attached screenshot with each of the modes for reference.

Regards,
Petar Kirov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

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