Skip to content

charton API


charton API / @chart-on/core / index / Timeline

Interface: Timeline ​

Defined in: packages/core/src/timeline.ts:17

Maps bar times to logical indices. Before the first bar it extrapolates by the bar interval; after the last it follows the projected bar calendar (see projectNext).

Properties ​

interval ​

interval: number = 60

Defined in: packages/core/src/timeline.ts:20

Bar interval in seconds (smallest recent gap).


session ​

session: CompiledSession | null = null

Defined in: packages/core/src/timeline.ts:34


shift ​

shift: number = 0

Defined in: packages/core/src/timeline.ts:31

Bars added at the front by prepend since the last set: an index taken when this was s is index + (shift - s) now. Lets caches keyed on the times array (which append and prepend keep) tell the two apart.


times ​

times: number[] = []

Defined in: packages/core/src/timeline.ts:18


weights ​

weights: Uint8Array

Defined in: packages/core/src/timeline.ts:22

Tick weight per bar (a view of weightBuf, which has room to grow at both ends).


zone ​

zone: Zone = UTC

Defined in: packages/core/src/timeline.ts:33

Timezone and session that tick weights (day, month, year boundaries) follow.

Accessors ​

lastIndex ​

Get Signature ​

get lastIndex(): number

Defined in: packages/core/src/timeline.ts:186

Returns ​

number


length ​

Get Signature ​

get length(): number

Defined in: packages/core/src/timeline.ts:182

Returns ​

number

Methods ​

append() ​

append(time): void

Defined in: packages/core/src/timeline.ts:48

Add a bar newer than the last one. Only the new bar's tick weight is computed and storage grows geometrically, so streaming stays O(1) per bar.

Parameters ​

time ​

number

Returns ​

void


indexFromTime() ​

indexFromTime(time): number

Defined in: packages/core/src/timeline.ts:212

Fractional index for any time, extrapolated outside the data range.

Parameters ​

time ​

number

Returns ​

number


indexOf() ​

indexOf(time): number

Defined in: packages/core/src/timeline.ts:191

Exact index of time, or -1.

Parameters ​

time ​

number

Returns ​

number


prepend() ​

prepend(times): void

Defined in: packages/core/src/timeline.ts:65

Add bars older than the first one; times ascending. Tick weights are computed for the new bars and the old first bar only (it now has a bar before it), and weight storage keeps headroom in front, so a page costs O(page) apart from moving the times array once.

Parameters ​

times ​

readonly number[]

Returns ​

void


projected() ​

projected(count): readonly number[]

Defined in: packages/core/src/timeline.ts:115

Projected times of the count bars after the last one, oldest first (fewer when the projection is capped). The array is cached; do not change it.

Parameters ​

count ​

number

Returns ​

readonly number[]


projectedWeights() ​

projectedWeights(count): Uint8Array

Defined in: packages/core/src/timeline.ts:135

Tick weights of the count projected bars, the first measured from the last real bar.

Parameters ​

count ​

number

Returns ​

Uint8Array


set() ​

set(times): void

Defined in: packages/core/src/timeline.ts:37

Replace every time; the timeline takes ownership of the array. O(n).

Parameters ​

times ​

number[]

Returns ​

void


setZone() ​

setZone(zone, session): void

Defined in: packages/core/src/timeline.ts:85

Parameters ​

zone ​

Zone

session ​

CompiledSession | null

Returns ​

void


slotOf() ​

slotOf(time): number

Defined in: packages/core/src/timeline.ts:201

Exact index of time among the bars, or past the last bar among the projected ones (see projected), so items placed on future bar times (a forecast) have a slot. -1 when time is on neither.

Parameters ​

time ​

number

Returns ​

number


timeFromIndex() ​

timeFromIndex(index): number

Defined in: packages/core/src/timeline.ts:227

Time at a (rounded) index, extrapolated outside the data range.

Parameters ​

index ​

number

Returns ​

number