@rekurt/openkline - v0.2.0
    Preparing search index...

    Class ReplayController

    Bar-by-bar history playback (C1, "Replay mode"). Drives the engine's replay cap so the chart reveals candles progressively from some start index up to the live edge.

    Replay is strictly opt-in: until start is called the controller touches nothing, and stop clears the cap so the chart renders the full buffer exactly as before. The controller owns a single timer (started by play, stopped by pause/stop/destroy); the timer reveals one bar per tick and auto-pauses once the newest bar is shown.

    The controller positions the viewport so the just-revealed bar sits at the live edge (it scrolls to index + 1, treating the revealed prefix as the whole buffer), so playback visually tracks the revealing candle the same way the live feed tracks new appends.

    Interaction with maxCandles eviction: while a cap is active the host's _enforceMaxCandles is a no-op (the cap is an absolute index; head-eviction would silently shift which bar it points at). A long replay session under a live feed therefore lets the buffer grow past maxCandles until stop — an intentional, bounded trade-off in favor of a stable cap.

    Index

    Constructors

    Accessors

    Methods

    • Begin (or resume) automatic playback. No-op when not started, already playing, or already at the last bar. Reveals one bar every 1000 / barsPerSecond ms and auto-pauses on reaching the newest bar.

      Returns void

    • Jump directly to index (clamps into [0, length - 1]). Engages replay if not already active. Does not change the playing state, except that seeking to the last bar while playing auto-pauses.

      Parameters

      • index: number

      Returns void

    • Change playback speed (bars per second), clamped to a sane positive range. Restarts the running timer with the new interval so a speed change takes effect immediately mid-playback.

      Parameters

      • barsPerSecond: number

      Returns void

    • Enter replay mode and reveal up to (and including) fromIndex — default 0, i.e. start from the very first bar. Clamps fromIndex into [0, length - 1]. No-op on an empty buffer. Does not start playback; call play (or step) to advance. Re-calling start while already playing stops the timer first.

      Parameters

      • fromIndex: number = 0

      Returns void

    • Reveal/hide one bar. forward (default true) advances toward the live edge; false steps back toward the start. Clamps at both ends. Auto- pauses if a forward step reaches the newest bar. Stepping while not yet started implicitly engages replay at the resulting index.

      Parameters

      • forward: boolean = true

      Returns void

    • Leave replay mode entirely: stop the timer, clear the engine's replay cap (so the full buffer renders again), and repaint. Emits one final onChange(index, false) so a host can reset its UI. Idempotent-ish — safe to call when not started.

      Returns void