The active horizontal-scale behavior.
The active localization bundle.
The cursor the top canvas shows when no drag is in progress.
The currently-configured indicators, in render order.
The current markers, in draw order.
The attached primitives, in attach order.
The active theme's background color. Exposed so the off-screen SVG export (chartEngineToSVG) can paint a guaranteed full-bleed backdrop matching the on-screen chart. Read-only — set the theme via setTheme.
Top canvas — for event listeners
Called by PanZoomController on mousedown/mouseup so the engine knows
whether to honor setIdleCursor writes or defer them. Internal API,
not exported.
Attach a programmatic overlay primitive (rendered at its z-tier).
Detach a primitive by id. Returns true if one was removed.
The current replay cap (virtual buffer end), or null when not replaying.
Hide crosshair and show last candle in legend
Topmost primitive whose hitTest passes at (x, y) in CSS pixels,
searched in reverse paint order (last attached wins). Used to route
drags to draggable price lines.
Optionaltolerance: numberHighest buffer index currently visible to the user — effectiveLength - 1
(or -1 on an empty buffer). Equals the last buffer index when no replay
cap is active. Consumers that resolve a pointer / visible-range index into
a candle (click, range callbacks, markers, crosshair) must clamp to this so
replay never leaks a not-yet-revealed (future) bar.
Render the chart layer into a caller-supplied 2D-context-like sink — the seam the vector SVG export (chartEngineToSVG) renders through.
Runs the exact same per-frame geometry pipeline as a real render (visible
window, non-uniform coordinate mapping, autoscale, left-scale extent,
conflation) and then paints the chart layer via _paintChartLayer,
so the SVG matches what's on screen. It does NOT touch the live canvases,
dirty flags, or the UI/crosshair layers — it's a pure read of current
state into the passed ctx.
Kept dependency-free (no SVG-shim import here) so it adds nothing to the base bundle; the shim lives in the separately-imported export module. No-ops when no buffer is set.
Mark chart + UI for re-render
Drop the resting-legend index. The index is absolute, so after a buffer eviction shifts every index the chart must re-derive it on the next hover rather than show the (now wrong) candle for a frame.
Switch the primary price-series rendering style (built-in or custom).
Attach a DrawingLayer whose drawings will be rendered on top of
the price area. Pass null to detach. The chart takes no input
events for the drawing layer — consumers listen on topCanvas
and drive creation via layer.addPoint(...) themselves.
Route indicator-compute and render errors through the host's
onError callback instead of swallowing them silently.
Replace the horizontal-scale behavior (time / price / custom). Controls how the X axis is labeled. Pass a TimeScaleBehavior (default), PriceScaleBehavior, or a custom one. A supplied TimeScaleBehavior inherits the chart's current resolution so daily/weekly charts don't fall back to intraday HH:mm labels.
Install the localization bundle (C6). Updates the canvas aria-label
immediately and requests a render so legend labels / the go-to-live pill
pick up the new strings. Passing the result of a no-locale createI18n()
restores the default English, locale-agnostic behavior.
Host-supplied priceFormat / volumeFormat still take priority over the
bundle's locale-aware number formatters (see _legendPriceFormat etc.) —
i18n only fills in where the host hasn't overridden formatting.
Override the resting cursor on the top canvas. Used by drawing tools
in consumer code to signal "click to place a point" — e.g. 'crosshair'
for selection, 'cell' or 'copy' while a trend line is being drawn.
PanZoomController still temporarily switches to 'grabbing' during an
active drag and back to the idle cursor on release, so mouse-up after
a drag does not clobber the tool's cursor choice.
Pass null to restore the default 'crosshair'.
Replace the indicator set. Indicators with placement: 'overlay'
are drawn on top of the price series in deterministic palette
order. Indicators with placement: 'pane' are not yet rendered
(pane layout integration is a future phase) — they still compute
their values, which is useful for code paths that want to read
getIndicatorSeries(id) without rendering.
Optionalfn: (price: number) => stringSet the replay-mode virtual buffer end (C1), or null to disable replay
and render the full buffer again. A non-null cap is clamped into
[1, buffer.length] so the renderer always has at least one — and never
more than the real number of — candles to show. Passing null is the
default-equivalent state; the next render is bit-for-bit identical to a
chart that never entered replay.
Does not itself request a render — the caller (ReplayController) decides when to repaint so a seek+render is a single frame.
Optionalfn: (price: number) => stringSnapshot the current chart state as a flat PNG data URL. Composites all three canvas layers onto a single offscreen canvas so the result is independent of DOM state.
Synchronous. Returns a data:image/png;base64,... string suitable
for <img src>, download links, or uploading to a backend. Returns
null if the browser refuses to provide a 2D context on the
offscreen canvas (should never happen outside of sandboxed iframes).
Zero-copy slice of the candles currently inside the visible window
[startIndex, startIndex + visibleCount), clamped to the effective
(replay-capped) buffer end and EXCLUDING the +1 render-only bar — so it
matches the bars the user actually sees. Returns null when no buffer is
set or the window is empty.
This is the seam an optional, attach-only overlay (C4 Volume Profile) reads
its source data through without ever importing the buffer: the controller
holds a () => engine.visibleCandleView() closure and the primitive folds
the returned typed arrays into price bins. Tiny + buffer-delegating, so it
adds nothing meaningful to the base bundle (the profile module itself is
never statically imported here, so it tree-shakes out).
The drawing layer currently being rendered, or null.