Skip to main content
Version: v27

ITimeScaleApi

Interface

API object for interacting with the time scale.

You can retrieve this interface by using the IChartWidgetApi.getTimeScale method

Methods

barSpacing

Returns the current bar spacing

Signature

barSpacing() => number

Returns

number


barSpacingChanged

Users will be notified every time barSpacing value is changed. This typically occurs when zooming in/out on the chart. This is to detect when the chart has been zoomed in/out

Signature

barSpacingChanged() => ISubscription<(newBarSpacing: number) => void>

Returns

ISubscription<(newBarSpacing: number) => void>


coordinateToTime

Returns the time associated to a given coordinate (distance in pixels from the leftmost visible bar)

Signature

coordinateToTime(x: number) => number

Parameters

NameType
xnumber

Returns

number


defaultRightOffset

Object that can be used to read/set/watch the default right offset (margin)

Signature

defaultRightOffset() => IWatchedValue<number>

Returns

IWatchedValue<number>


defaultRightOffsetPercentage

Object that can be used to read/set/watch the default right offset (in percent) (margin)

Signature

defaultRightOffsetPercentage() => IWatchedValue<number>

Returns

IWatchedValue<number>


rightOffset

Returns the current right offset

Signature

rightOffset() => number

Returns

number


rightOffsetChanged

Users will be notified every time rightOffset value is changed. This is to detect when the chart has been scrolled left/right.

Signature

rightOffsetChanged() => ISubscription<(rightOffset: number) => void>

Returns

ISubscription<(rightOffset: number) => void>


setBarSpacing

To set a new bar spacing

Signature

setBarSpacing(newBarSpacing: number) => void

Parameters

NameType
newBarSpacingnumber

Returns

void


setRightOffset

To set a new right offset

Signature

setRightOffset(offset: number) => void

Parameters

NameType
offsetnumber

Returns

void


usePercentageRightOffset

Object that can be used to read/set/watch whether to use defaultRightOffset or defaultRightOffsetPercentage option for the right offset (margin).

  • false: use defaultRightOffset
  • true: use defaultRightOffsetPercentage

Default: false

Signature

usePercentageRightOffset() => IWatchedValue<boolean>

Returns

IWatchedValue<boolean>


width

Returns the current width of the chart in pixels

Signature

width() => number

Returns

number