Axis Tick Strategy that is designed for depicting date and time.

Axis values are interpreted as UNIX timestamps similarly as with JavaScript Date API.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

Axis interval ranges supported by DateTImeTickStrategy:

  • Minimum: 1 second (1000).
  • Maximum: 1000 years (really big number).

For reaching Axis ranges smaller than 1 second, TimeTickStrategy is recommended.

Note, that available axis interval ranges can be also limited by the type of Axis, refer to Axis documentation for more information.

Axis tick strategy is selected with setTickStrategy method:

 Axis.setTickStrategy(AxisTickStrategies.DateTime, (dateTimeTicks) => dateTimeTicks)

All configuration of automatically created ticks is done using the callback from setTickStrategy, see example below for the idea:

 // Specify TickStrategy and use callback to style automatic ticks.
Axis.setTickStrategy(AxisTickStrategies.DateTime, (dateTimeTicks) => dateTimeTicks
// All methods of `DateTimeTickStrategy` can be used here for styling ticks.
.setMajorTickStyle((majorTicks) => majorTicks
.setLabelFont((font) => font
.setWeight('bold')
)
)
)

All available strategies for automatic Axis ticks creation can be referenced via AxisTickStrategies.

Hierarchy

  • DateTimeTickStrategyRecord
    • DateTimeTickStrategy

Implements

  • MutableAxisTickStrategy

Constructors

  • Parameters

    • Optional values: Iterable<[string, unknown]> | Partial<DateTimeTickStrategyProperties>

    Returns DateTimeTickStrategy

Properties

cursorFormatter: undefined | FormattingFunction

Cursor formatter.

This controls the date time formatting used by:

  • Default cursor result table formatters.
  • Default cursor tick formatters along Axis which uses this TickStrategy.
  • Axis.formatValue method of the Axis which uses this TickStrategy.

undefined means to use default date time cursor formatting.

 // Example value, cursor formatter to display week day, year, month, day, hour and minute.
cursorFormatter: (value, range, locale) =>
new Date(value).toLocaleDateString(locale, {
weekday: 'long',
year: 'numeric',
month: 'numeric',
day: 'numeric',
minute: '2-digit',
hour: '2-digit',
})
dateOrigin: undefined | Date

Optional "origin date" value.

By default data-points are interpreted as UTC dates (milliseconds since January 1st 1970 GMT+0). If a dateOrigin is defined, data-points will instead be interpreted as milliseconds since dateOrigin.

formatOptionsGreatDay: DateTimeFormatter

Formatter options for great ticks that are placed on relevant day intervals.

formatOptionsGreatHour: DateTimeFormatter

Formatter options for great ticks that are placed on relevant hour intervals.

formatOptionsGreatMinute: DateTimeFormatter

Formatter options for great ticks that are placed on relevant minute intervals.

formatOptionsGreatMonth: DateTimeFormatter

Formatter options for great ticks that are placed on relevant month intervals.

formatOptionsGreatSecond: DateTimeFormatter

Formatter options for great ticks that are placed on relevant second intervals.

formatOptionsGreatWeek: DateTimeFormatter

Formatter options for great ticks that are placed on relevant week intervals.

formatOptionsGreatYear: DateTimeFormatter

Formatter options for great ticks that are placed on relevant year intervals.

formatOptionsMajorCentury: DateTimeFormatter

Formatter options for major ticks that are placed on relevant century intervals.

formatOptionsMajorDay: DateTimeFormatter

Formatter options for major ticks that are placed on relevant day intervals.

formatOptionsMajorDecade: DateTimeFormatter

Formatter options for major ticks that are placed on relevant decade intervals.

formatOptionsMajorHour: DateTimeFormatter

Formatter options for major ticks that are placed on relevant hour intervals.

formatOptionsMajorMilliSecond: DateTimeFormatter

Formatter options for major ticks that are placed on relevant millisecond intervals.

formatOptionsMajorMinute: DateTimeFormatter

Formatter options for major ticks that are placed on relevant minute intervals.

formatOptionsMajorMonth: DateTimeFormatter

Formatter options for major ticks that are placed on relevant month intervals.

formatOptionsMajorSecond: DateTimeFormatter

Formatter options for major ticks that are placed on relevant second intervals.

formatOptionsMajorWeek: DateTimeFormatter

Formatter options for major ticks that are placed on relevant week intervals.

formatOptionsMajorYear: DateTimeFormatter

Formatter options for major ticks that are placed on relevant year intervals.

formatOptionsMinorDay: DateTimeFormatter

Formatter options for minor ticks that are placed on relevant day intervals.

formatOptionsMinorDecade: DateTimeFormatter

Formatter options for minor ticks that are placed on relevant decade intervals.

formatOptionsMinorHour: DateTimeFormatter

Formatter options for minor ticks that are placed on relevant hour intervals.

formatOptionsMinorMillisecond: DateTimeFormatter

Formatter options for minor ticks that are placed on relevant millisecond intervals.

formatOptionsMinorMinute: DateTimeFormatter

Formatter options for minor ticks that are placed on relevant minute intervals.

formatOptionsMinorMonth: DateTimeFormatter

Formatter options for minor ticks that are placed on relevant month intervals.

formatOptionsMinorSecond: DateTimeFormatter

Formatter options for minor ticks that are placed on relevant second intervals.

formatOptionsMinorWeek: DateTimeFormatter

Formatter options for minor ticks that are placed on relevant week intervals.

formatOptionsMinorYear: DateTimeFormatter

Formatter options for minor ticks that are placed on relevant year intervals.

greatTickStyle: TickStyle

Style of Great ticks.

To disable great ticks, set to emptyTick.

NOTE: Label alignment is overridden, and has no effect on this property.

locale: undefined | string

Valid javascript Date locale string, that specifies a geographical, political or cultural region.

undefined passes the decision making to the browser.

For example values, refer to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat

majorTickStyle: VisibleTicks

Style of Major ticks.

Major ticks can't be disabled (via emptyTicks), because TickLevel style doesn't support emptyTicks, and Major tick level must exist for Minor tick positioning.

minorTickStyle: TickStyle

Style of Minor ticks.

To disable minor ticks, set to emptyTick.

Methods

  • Get cursor formatter of this DateTimeTickStrategy object.

    Returns

    FormattingFunction as set by user, or undefined to indicate that the default date time cursor formatting is configured.

    Returns undefined | FormattingFunction

  • Get the dateOrigin of this DateTimeTickStrategy object.

    By default data-points are interpreted as UTC dates (milliseconds since January 1st 1970 GMT+0). If a dateOrigin is defined, data-points will instead be interpreted as milliseconds since dateOrigin.

    Returns

    A JavaScript Date object or undefined.

    Returns undefined | Date

  • Get great tick style of this DateTimeTickStrategy object.

    Great ticks display the largest Date/Time information for the active time range. There is always exactly one great tick in view.

    Returns

    Great tick style.

    Returns TickStyle

  • Get locale of this DateTimeTickStrategy object.

    The locale specifies a geographical, political or cultural region, affecting all formatting of Tick labels.

    Returns

    JavaScript Date locale string, that specifies a geographical, political or cultural region.

    Returns undefined | string

  • Get major tick style of this DateTimeTickStrategy object.

    Major ticks display the next smaller Date/Time information after Great ticks. Often times, they represent the most important information.

    Returns

    Major tick style.

    Returns TickStyle

  • Get minor tick style of this DateTimeTickStrategy object.

    Minor ticks display the next smaller Date/Time information after Major ticks.

    Returns

    Minor tick style.

    Returns TickStyle

  • Set cursor formatter for this DateTimeTickStrategy object.

    This will override the date time formatting used by:

    • Default cursor result table formatters.
    • Default cursor tick formatters along Axis which uses this TickStrategy.
    • Axis.formatValue method of the Axis which uses this TickStrategy.
     // Example syntax, specify cursor formatting to display week day, year, month, day, hour and minute.
    Axis.setTickStrategy(AxisTickStrategies.DateTime, (ticks) => ticks
    .setCursorFormatter((value, range, locale) =>
    new Date(value).toLocaleDateString(locale, {
    weekday: 'long',
    year: 'numeric',
    month: 'numeric',
    day: 'numeric',
    minute: '2-digit',
    hour: '2-digit',
    })
    )
    )

    Returns

    New DateTimeTickStrategy object.

    Parameters

    • formatter: undefined | FormattingFunction

      FormattingFunction or undefined to use default date time cursor formatting.

    Returns DateTimeTickStrategy

  • Construct a new DateTimeTickStrategy object based on this one, but with modified dateOrigin.

    By default data-points are interpreted as UTC dates (milliseconds since January 1st 1970 GMT+0). If a dateOrigin is defined, data-points will instead be interpreted as milliseconds since dateOrigin.

    Specifying a dateOrigin can be necessary in applications where there is a long range of date-time data, and high resolution zooming is desired.

    Example usage:

    Application with one day of high-density data starting in year 2020:

    // Without specifying a dateOrigin, zooming will be limited to minutes with this range.
    // Milliseconds resolution can be reached by setting the dateOrigin to a Date
    // that is closer to the actual data (instead of the default 1.1.1970).
    Axis.setTickStrategy(
    AxisTickStrategies.DateTime,
    ( tickStrategy: DateTimeTickStrategy ) => tickStrategy
    .setDateOrigin( new Date( 2020, 0, 1 ) )
    )

    Check our DateTime Axis Interactive Example for a more thorough example on DateTime TickStrategy usage: https://lightningchart.com/lightningchart-js-interactive-examples/examples/lcjs-example-0020-dateTimeAxis.html

    Returns

    New DateTimeTickStrategy object.

    Parameters

    • dateOrigin: undefined | Date

      A JavaScript Date object or undefined.

    Returns DateTimeTickStrategy

  • Construct a new DateTimeTickStrategy object based on this one, but with modified formatting options for DateTime ranges where ticks are positioned as follows:

    • Great: Weeks
    • Major: Days
    • Minor: Hours

    Example usage:

    Axis.setTickStrategy(
    AxisTickStrategies.DateTime,
    ( tickStrategy: DateTimeTickStrategy ) => tickStrategy
    .setFormattingDay(
    { year: 'numeric', month: 'long' },
    { day: '2-digit' },
    { hour: '2-digit', minute: '2-digit' }
    )
    )

    The used formatting options are dynamically chosen depending on the range of Axis, so depending on the application this formatting customization method might not have a visible effect.

    For more detailed example usage, refer to DateTimeFormatter.

    Returns

    New DateTimeTickStrategy object.

    Parameters

    • greatTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for great ticks.

    • majorTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for major ticks

    • minorTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for minor ticks.

    Returns DateTimeTickStrategy

  • Construct a new DateTimeTickStrategy object based on this one, but with modified formatting options for DateTime ranges where ticks are positioned as follows:

    • Major: Decades
    • Minor: Years

    Example usage:

    Axis.setTickStrategy(
    AxisTickStrategies.DateTime,
    ( tickStrategy: DateTimeTickStrategy ) => tickStrategy
    .setFormattingDecade(
    { year: 'numeric' },
    { year: 'numeric' }
    )
    )

    The used formatting options are dynamically chosen depending on the range of Axis, so depending on the application this formatting customization method might not have a visible effect.

    For more detailed example usage, refer to DateTimeFormatter.

    Returns

    New DateTimeTickStrategy object.

    Parameters

    • majorTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for major ticks

    • minorTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for minor ticks.

    Returns DateTimeTickStrategy

  • Construct a new DateTimeTickStrategy object based on this one, but with modified formatting options for DateTime ranges where ticks are positioned as follows:

    • Great: Days
    • Major: Hours
    • Minor: Minutes

    Example usage:

    Axis.setTickStrategy(
    AxisTickStrategies.DateTime,
    ( tickStrategy: DateTimeTickStrategy ) => tickStrategy
    .setFormattingHour(
    { year: 'numeric', month: 'long', day: '2-digit' },
    { hour: '2-digit', minute: '2-digit' },
    { hour: '2-digit', minute: '2-digit' }
    )
    )

    The used formatting options are dynamically chosen depending on the range of Axis, so depending on the application this formatting customization method might not have a visible effect.

    For more detailed example usage, refer to DateTimeFormatter.

    Returns

    New DateTimeTickStrategy object.

    Parameters

    • greatTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for great ticks.

    • majorTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for major ticks

    • minorTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for minor ticks.

    Returns DateTimeTickStrategy

  • Construct a new DateTimeTickStrategy object based on this one, but with modified formatting options for DateTime ranges where ticks are positioned as follows:

    • Great: Seconds
    • Major: Every tenth MilliSecond

    Example usage:

    Axis.setTickStrategy(
    AxisTickStrategies.DateTime,
    ( tickStrategy: DateTimeTickStrategy ) => tickStrategy
    .setFormattingMilliSecond(
    { year: 'numeric', month: 'long', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' },
    ( value ) => new Date( value ).getUTCMilliseconds()
    )
    )

    The used formatting options are dynamically chosen depending on the range of Axis, so depending on the application this formatting customization method might not have a visible effect.

    For more detailed example usage, refer to DateTimeFormatter.

    Returns

    New DateTimeTickStrategy object.

    Parameters

    • greatTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for great ticks.

    • majorTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for major ticks

    Returns DateTimeTickStrategy

  • Construct a new DateTimeTickStrategy object based on this one, but with modified formatting options for DateTime ranges where ticks are positioned as follows:

    • Great: Hours
    • Major: Minutes
    • Minor: Seconds

    Example usage:

    Axis.setTickStrategy(
    AxisTickStrategies.DateTime,
    ( tickStrategy: DateTimeTickStrategy ) => tickStrategy
    .setFormattingMinute(
    { year: 'numeric', month: 'long', day: '2-digit' },
    { hour: '2-digit', minute: '2-digit' },
    { hour: '2-digit', minute: '2-digit', second: '2-digit' }
    )
    )

    The used formatting options are dynamically chosen depending on the range of Axis, so depending on the application this formatting customization method might not have a visible effect.

    For more detailed example usage, refer to DateTimeFormatter.

    Returns

    New DateTimeTickStrategy object.

    Parameters

    • greatTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for great ticks.

    • majorTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for major ticks

    • minorTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for minor ticks.

    Returns DateTimeTickStrategy

  • Construct a new DateTimeTickStrategy object based on this one, but with modified formatting options for DateTime ranges where ticks are positioned as follows:

    • Great: Years
    • Major: Months
    • Minor: Weeks

    Example usage:

    Axis.setTickStrategy(
    AxisTickStrategies.DateTime,
    ( tickStrategy: DateTimeTickStrategy ) => tickStrategy
    .setFormattingMonth(
    { year: 'numeric' },
    { month: 'long' },
    { day: '2-digit' }
    )
    )

    The used formatting options are dynamically chosen depending on the range of Axis, so depending on the application this formatting customization method might not have a visible effect.

    For more detailed example usage, refer to DateTimeFormatter.

    Returns

    New DateTimeTickStrategy object.

    Parameters

    • greatTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for great ticks.

    • majorTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for major ticks

    • minorTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for minor ticks.

    Returns DateTimeTickStrategy

  • Construct a new DateTimeTickStrategy object based on this one, but with modified formatting options for DateTime ranges where ticks are positioned as follows:

    • Great: Minutes
    • Major: Seconds
    • Minor: Milliseconds

    Example usage:

    Axis.setTickStrategy(
    AxisTickStrategies.DateTime,
    ( tickStrategy: DateTimeTickStrategy ) => tickStrategy
    .setFormattingSecond(
    { year: 'numeric', month: 'long', day: '2-digit', hour: '2-digit', minute: '2-digit' },
    { hour: '2-digit', minute: '2-digit', second: '2-digit' },
    ( value ) => new Date( value ).getUTCMilliseconds(),
    )
    )

    The used formatting options are dynamically chosen depending on the range of Axis, so depending on the application this formatting customization method might not have a visible effect.

    For more detailed example usage, refer to DateTimeFormatter.

    Returns

    New DateTimeTickStrategy object.

    Parameters

    • greatTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for great ticks.

    • majorTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for major ticks

    • Optional minorTickFormattingOptions: DateTimeFormatter

      Formatting options for minor ticks

    Returns DateTimeTickStrategy

  • Construct a new DateTimeTickStrategy object based on this one, but with modified formatting options for DateTime ranges where ticks are positioned as follows:

    • Great: Months
    • Major: Weeks
    • Minor: Days

    Example usage:

    Axis.setTickStrategy(
    AxisTickStrategies.DateTime,
    ( tickStrategy: DateTimeTickStrategy ) => tickStrategy
    .setFormattingWeek(
    { year: 'numeric', month: 'long' },
    { day: '2-digit' },
    { day: '2-digit' }
    )
    )

    The used formatting options are dynamically chosen depending on the range of Axis, so depending on the application this formatting customization method might not have a visible effect.

    For more detailed example usage, refer to DateTimeFormatter.

    Returns

    New DateTimeTickStrategy object.

    Parameters

    • greatTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for great ticks.

    • majorTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for major ticks

    • minorTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for minor ticks.

    Returns DateTimeTickStrategy

  • Construct a new DateTimeTickStrategy object based on this one, but with modified formatting options for DateTime ranges where ticks are positioned as follows:

    • Major: Years
    • Minor: Months

    Example usage:

    Axis.setTickStrategy(
    AxisTickStrategies.DateTime,
    ( tickStrategy: DateTimeTickStrategy ) => tickStrategy
    .setFormattingYear(
    { year: 'numeric' },
    { month: 'short' }
    )
    )

    The used formatting options are dynamically chosen depending on the range of Axis, so depending on the application this formatting customization method might not have a visible effect.

    For more detailed example usage, refer to DateTimeFormatter.

    Returns

    New DateTimeTickStrategy object.

    Parameters

    • majorTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for major ticks

    • minorTickFormattingOptions: undefined | DateTimeFormatter

      Formatting options for minor ticks.

    Returns DateTimeTickStrategy

  • Construct a new DateTimeTickStrategy object based on this one, but with modified great tick style.

    Great ticks display the largest Date/Time information for the active time range. There is always exactly one great tick in view.

    Example usage:

    Disable great ticks:

    Axis.setTickStrategy(
    AxisTickStrategies.DateTime,
    ( tickStrategy: DateTimeTickStrategy ) => tickStrategy
    .setGreatTickStyle( emptyTick )
    )

    Set font of great ticks:

    Axis.setTickStrategy(
    AxisTickStrategies.DateTime,
    ( tickStrategy: DateTimeTickStrategy ) => tickStrategy
    .setGreatTickStyle(( tickStyle: VisibleTicks ) => tickStyle
    .setLabelFont(( font ) => font
    .setWeight( 'bold' )
    )
    )
    )

    Returns

    New DateTimeTickStrategy object.

    Parameters

    Returns DateTimeTickStrategy

  • Construct a new DateTimeTickStrategy object based on this one, but with modified major tick style.

    Major ticks display the next smaller Date/Time information after Great ticks. Often times, they represent the most important information.

    Example usage:

    Set font of major ticks:

    Axis.setTickStrategy(
    AxisTickStrategies.DateTime,
    ( tickStrategy: DateTimeTickStrategy ) => tickStrategy
    .setMajorTickStyle(( tickStyle ) => tickStyle
    .setLabelFont(( font ) => font
    .setWeight( 'bold' )
    )
    )
    )

    Returns

    New DateTimeTickStrategy object.

    Parameters

    Returns DateTimeTickStrategy

  • Construct a new DateTimeTickStrategy object based on this one, but with modified minor tick style.

    Minor ticks display the next smaller Date/Time information after Major ticks.

    Example usage:

    Disable minor ticks:

    Axis.setTickStrategy(
    AxisTickStrategies.DateTime,
    ( tickStrategy: DateTimeTickStrategy ) => tickStrategy
    .setMinorTickStyle( emptyTick )
    )

    Set font of minor ticks:

    Axis.setTickStrategy(
    AxisTickStrategies.DateTime,
    ( tickStrategy: DateTimeTickStrategy ) => tickStrategy
    .setMinorTickStyle(( tickStyle ) => tickStyle
    .setLabelFont(( font ) => font
    .setWeight( 'bold' )
    )
    )
    )

    Returns

    New DateTimeTickStrategy object.

    Parameters

    Returns DateTimeTickStrategy