Skip to content
EliteChart

resolveReplayStart

Documentation


Documentation / @elitechart/core / resolveReplayStart

code
function resolveReplayStart(bars, opts?): number;

Defined in: replay/replay-state.ts:135

Resolve the starting index when entering replay.

  • atIndex provided → use it directly (clamped).
  • atTime provided → binary-search for the first bar ≥ atTime.
  • Neither → fall back to Math.floor(barCount * 0.75) — a typical "75% through history" anchor so users have some look-forward room.

Parameters

bars

readonly { time: number; }[]

opts?

atIndex?

number

atTime?

number

Returns

number

Example

code
import { resolveReplayStart } from '@elitechart/core';
const idx = resolveReplayStart(bars, { atTime: 1700000000000 });