DateTimeContinuousAxis last date is not visible

3 posts, 0 answers
  1. Vipin
    Vipin avatar
    2 posts
    Member since:
    May 2011

    Posted 08 Feb Link to this post

    I am using below code snippet but not getting end date on xaxis.[Please refer attached screen print.]
    I need to show end date irrespective of (Odd/Even)number points. Can you please suggest how to achieve this.
    public DateTimeContinuousAxis SetTimeInterval(DateTimeContinuousAxis xAxis, int dateCount)
              var range = xAxis.Maximum - xAxis.Minimum;
              double lbs = System.Math.Ceiling(range.TotalDays / 10);
              if (lbs > 0 && range.TotalDays / lbs > 5)
                  xAxis.MajorStepUnit = TimeInterval.Day;
                  xAxis.LabelInterval = 3;//(int)Math.Round(lbs);
                  xAxis.LastLabelVisibility = Telerik.Charting.AxisLastLabelVisibility.Visible;
                  xAxis.MajorStep = range.TotalDays;
              return xAxis;
  2. Vipin
    Vipin avatar
    2 posts
    Member since:
    May 2011

    Posted 08 Feb in reply to Vipin Link to this post

    Correction to question in previous post:

    I need to show end date irrespective of (Odd/Even)number of data points in the series. Can you please suggest how to achieve this?

  3. DevCraft R3 2016 release webinar banner
  4. Dinko
    Dinko avatar
    182 posts

    Posted 11 Feb Link to this post


    Thank you for contacting us.

    Let me first explain LabelInterval and MajorStep properties. The LabelInterval property specifies the value indicating that only one on n axis labels will be visible (where n is the value of the property). As for the MajorStep, it specify a step for the major ticks which determines at which values will the major ticks be displayed.

    In your case, when you set the LabelInterval to 3 the label will be visible on the third tick. So when you set MajorStep to the total days between the min and max date you are will have only 2 ticks. The last label is not visible because you have only two ticks. You can just adjust the labels on every thick by setting the LabelInterval to 1 which is the default value.

    Instead of manually calculating the axis step you can take advantage of the SmartLabelsMode property of the axis which was introduced with the Q2 2015 release. The Axis Smart Labels help article explains in more details how you can use it. 

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top