WPF Charting Documentation - SciChart WPF Charts SDK v5.x
The DiscontinuousDateTimeAxis

New to SciChart v5, available in the Enterprise & SDK Editions!

The DiscontinuousDateTimeAxis is a Value-Axis suitable for the XAxis when the data on the XAxis is a DateTime. It is not suitable for YAxis or other data-types. 

This axis differs from the DateTimeAxis in that it allows you to skip periodic dates/times, or time ranges from the chart. For example:

Declaring a DiscontinuousDateTimeAxis

Use the following code to decalare a DiscontinuousDateTimeAxis.

<s:SciChartSurface.XAxis>
   <s:DiscontinuousDateTimeAxis DrawMajorBands="True" GrowBy="0.0, 0.1" />
</s:SciChartSurface.XAxis>
var sciChartSurface = new SciChartSurface();
 
var xAxis = new DiscontinuousDateTimeAxis
{
    Calendar = new DefaultDiscontinuousDateTimeCalendar(),
    GrowBy = new DoubleRange(0.0, 0.1),
    AxisAlignment = AxisAlignment.Bottom,
    AxisTitle = "Time",
    Calendar = new DefaultDiscontinuousDateTimeCalendar(),
};
 
sciChartSurface.XAxis = xAxis;
NOTE: if you don’t set the Calender property it will use DefaultDiscontinuousDateTimeCalendar and will behave like DateTimeAxis.

Calendars

IDiscontinuousDateTimeCalendar is a base interface for calendars. DiscontinuousDateTimeCalendarBase is a base abstract class that provides basic functionality for calendars (checking if value is in a gap, getting time in ticks between dates taking gaps into account etc.).

For creating your custom calendars, you should inherit it from DiscontinuousDateTimeCalendarBase and change the following collections:

You may set dates with HH, MM and SS – it will work as well.

In our examples, there are two implemented calendars: NYSECalendar and LSECalendar. These are defined as follows:

Example DiscontinuousDateTimeAxis Calendars
Copy Code
/// <summary>
/// Example of how to make a Discontinuous DateTime Calender for the New York Stock Exchange
/// 
/// If you wish to extend this, ensure that public holidays are set for the year(s) which you wish to show data
/// e.g. https://www.redcort.com/us-federal-bank-holidays/
/// </summary>
public class NYSECalendar : DiscontinuousDateTimeCalendarBase
{
    public NYSECalendar()
    {
        // For intraday data, you can add a skip range like this.
        // For daily data, skip ranges will cause the Daily OHLC bars with timestamp at 0:00:00 to be skipped 
        //SkipDayTimeRange.Add(new TimeSpanRange(new TimeSpan(0, 0, 0), new TimeSpan(9, 30, 0))); // NYSE is open at 9:30 am EST
        //SkipDayTimeRange.Add(new TimeSpanRange(new TimeSpan(16, 0, 0), new TimeSpan(24, 0, 0))); // NYSE is closed at 16:00 pm EST
        // NYSE is closed on weekends
        SkipDaysInWeek.Add(DayOfWeek.Saturday);
        SkipDaysInWeek.Add(DayOfWeek.Sunday);
        SkipDates.Add(new DateTime(2015, 12, 25)); // NYSE Closed on Christmas Day 2015
        SkipDates.Add(new DateTime(2016, 1, 1)); // NYSE Closed on New years day 2016
        SkipDates.Add(new DateTime(2016, 1, 15)); // NYSE Clsoed on Martin Luther King Day 2016
        SkipDates.Add(new DateTime(2016, 11, 24)); // NYSE Closed on Thanksgiving  2016
    }
}
/// <summary>
/// Example of how to make a Discontinuous DateTime Calender for the London Stock Exchange
/// 
/// If you wish to extend this, ensure that public holidays are set for the year(s) which you wish to show data
/// e.g. http://www.lseg.com/areas-expertise/our-markets/london-stock-exchange/equities-markets/trading-services/business-days
/// </summary>
public class LSECalendar : DiscontinuousDateTimeCalendarBase
{
    public LSECalendar()
    {
        // For intraday data, you can add a skip range like this.
        // For daily data, skip ranges will cause the Daily OHLC bars with timestamp at 0:00:00 to be skipped 
        //SkipDayTimeRange.Add(new TimeSpanRange(new TimeSpan(0, 0, 0), new TimeSpan(8, 0, 0))); // LSE is open at 08:00am GMT
        //SkipDayTimeRange.Add(new TimeSpanRange(new TimeSpan(16, 30, 0), new TimeSpan(24, 0, 0))); // LSE is closed at 16:30pm GMT
        // LSE is closed on weekends
        SkipDaysInWeek.Add(DayOfWeek.Saturday);
        SkipDaysInWeek.Add(DayOfWeek.Sunday);
        SkipDates.Add(new DateTime(2015, 12, 25)); // LSE Closed on Christmas Day 2015
        SkipDates.Add(new DateTime(2016, 1, 1)); // LSE Closed on New Years day 2016
    }
}

Example of the DiscontinuousDateTimeAxis

There is an example in our examples suite of using the DiscontinuousDateTimeAxis. Please go to featured Apps > Financial Charts > Discontinuous Axis Demo to see it.

DiscontinuousDateTimeAxis Example

DiscontinuousDateTimeAxis Example

Data must be prepared for the DiscontinuousAxis by applying a Filter (see Filters API) passing in the calendar to skip time ranges. For example:

Example Title
Copy Code
using SciChart.Charting.Model.Filters;
// ... 
void InitData()
{
    var calender = new LSECalendar();
    var priceData = new OhlcDataSeries<DateTime, double> 
    priceData.Append(...); // Append some OHLC data to the series 
    
    // Convert to a discontinuous series 
    var priceDataDiscontinuous = (IOhlcDataSeries<DateTime, double>)_priceData.ToDiscontinuousSeries(calender);
    
    // Apply to the chart 
    sciChartSurface.RenderableSeries.Add(new FastOhlcRenderableSeries { DataSeries = priceDataDiscontinuous });
}

Once you have done this the data is prepared and skipped ranges excluded.

The calendar may be updated at any time by calling the extension method .ToDiscontinuousSeries with a new calender.

 

 

 

 


SCICHART ® is a Registered Trademark in the UK, US and EEC. Copyright SciChart Ltd 2011-2018.

Email us to give feedback!