X Axis Dates are not distinct

2 posts, 0 answers
  1. Chris
    Chris avatar
    2 posts
    Member since:
    May 2013

    Posted 24 May 2013 Link to this post

    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:AxisX  LabelRotationAngle="90" Title="Day of Month"   IsDateTime="True"    />

    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.
  2. Petar Kirov
    Petar Kirov avatar
    425 posts

    Posted 29 May 2013 Link to this post

    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.

    Petar Kirov

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top