Pre loader

CategoryDateTimeAxis Grid Lines

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

Answered
3
0

Hi Guys,

My Sci Chart has dates along the X-Axis. So far my data is at week level (one point for each week).

Ideally I would like to have a subtle grid line at each week, a more noticeable grid line to represent the start of each month, and a major grid line to represent the start of each year.

I understand that the current implementation of the XAxis seems to only use Minor and Major gridlines.

I am interested in drawing grid lines such that:

one minor vertical grid-line is drawn on the start of each week
one medium vertical grid-line is drawn on the start of each month
one major vertical grid-line is drawn on the start of each year
And for these grid lines to be drawn regardless of the current visible range or ÔÇ£zoomÔÇØ of the chart.

Is there a simple tutorial or some snippet of code illustrating what I need to overwrite in a custom class in order to get this functionality into my chart?

Thanks again,
Miles

  • You must to post comments
Best Answer
3
0

Hi Miles,

SciChart is only configured to draw two gridlines, major and minor. There are three ways I can suggest you do this (or close enough)

a.) Simplest way, manually calculate Major, MinorDelta

Configure the chart by setting AutoTicks=False and set the MajorDelta, MinorDelta to weeks and months.

See this KB article on Axis Gridlines, Ticks, Label Formatting which shows how to set MajorDelta, MinorDelta and AutoTicks to get simple adjustment of the tick frequency.

In SciChart a TimeSpan of one month is defined as this:

private const double DaysInMonth = 365.2425 / 12.0;

// Usage, 3 month timespan defined by Timespan t = FromMonths(3)
public static TimeSpan FromMonths(int numberMonths)
{
    return TimeSpan.FromDays(numberMonths * DaysInMonth);
}

This would achieve you month, week gridlines but not day. As you zoom in you could however switch the Major,Minor delta of the chart to show weeks and days.

more b. Complex way, use the TickProvider API

In SciChart v3.0 and above, there is now a way to override the exact Tick Intervals.

See this KB article on Advanced Tick Frequency Overriding which introduces the TickProvider API. This allows exact calculation of ticks (Axis Major, Minor gridlines and labels) as the axis is drawn.

Hope this helps!

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.