TimeScale
Defined in: core/src/scale/time-scale.ts:46
An immutable linear time scale. Pixel values are unrounded floats: rounding to
device pixels is the renderer’s job. Dates and durations coming back from pixels are rounded
to whole milliseconds; snapping to a step is a separate concern (scale/snap).
Members are plain functions (no this), so they can be passed around unbound. The object is
frozen: zooming returns a new scale.
Properties
Section titled “Properties”dateToX
Section titled “dateToX”
readonlydateToX: (t) =>number
Defined in: core/src/scale/time-scale.ts:57
Horizontal position of a date: (t - origin) * pxPerDay / DAY, may be negative.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”number
direction
Section titled “direction”
readonlydirection:ScaleDirection
Defined in: core/src/scale/time-scale.ts:55
Writing direction as configured. 'rtl' currently behaves like 'ltr'.
durationToPx
Section titled “durationToPx”
readonlydurationToPx: (ms) =>number
Defined in: core/src/scale/time-scale.ts:61
Width in pixels of a fixed duration in milliseconds (sign preserved).
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”number
origin
Section titled “origin”
readonlyorigin:DateTimeMs
Defined in: core/src/scale/time-scale.ts:51
The date at x = 0. TimeScale.zoom keeps it a whole number of milliseconds (it
rounds the shifted origin), so it is an integer whenever the created scale’s origin is.
pxPerDay
Section titled “pxPerDay”
readonlypxPerDay:number
Defined in: core/src/scale/time-scale.ts:53
Pixels per floating day (24 h).
pxToDuration
Section titled “pxToDuration”
readonlypxToDuration: (px) =>number
Defined in: core/src/scale/time-scale.ts:63
Fixed duration in milliseconds covered by a pixel width, rounded to the nearest ms.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”number
xToDate
Section titled “xToDate”
readonlyxToDate: (x) =>DateTimeMs
Defined in: core/src/scale/time-scale.ts:59
The date at a horizontal position, rounded to the nearest millisecond.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”
readonlyzoom: (pxPerDay,anchor) =>TimeScale
Defined in: core/src/scale/time-scale.ts:72
A scale with another pxPerDay where the date under anchor.x stays at anchor.x
(the origin moves). The new origin is rounded to a whole millisecond, so the anchor date
stays within half a millisecond of anchor.x: a sub-pixel shift at any realistic zoom
(under 0.06 px at 10 000 px per day). Direction is kept.
Parameters
Section titled “Parameters”pxPerDay
Section titled “pxPerDay”number
anchor
Section titled “anchor”Returns
Section titled “Returns”TimeScale
Throws
Section titled “Throws”RangeError for a non-positive or non-finite pxPerDay or a non-finite anchor.x.