Attach a programmatic overlay primitive (watermark, price line, custom
band) rendered at its z-tier. Primitives are runtime annotations — they
are not included in saveLayoutState.
Remove every alert and its price line.
Remove every drawing from the auto-managed layer.
Remove all markers.
Remove the watermark, if one is set.
Create a horizontal price line at a fixed price, with a right-axis label
pill, optionally draggable. Returns a handle to move/restyle/remove it.
Correct under any price-scale mode (positions via the viewport). Price
lines are runtime-only — not included in saveLayoutState.
Delete the selected drawing, if any. Returns true if one was removed.
Clean up all resources. Idempotent — safe to call more than once.
Detach a primitive by id. Returns true if one was removed.
Zoom out so the entire buffer is visible at once, from the start.
Reset zoom to the default candleWidth and go to live.
All alerts in insertion order (fired one-shot alerts read active: false).
Get the underlying buffer
Access the chart's auto-managed DrawingLayer. Returns the same
instance that startDrawing / getDrawings / loadDrawings
operate on, unless the host replaced it via setDrawingLayer.
Serialize the auto-managed drawing layer to a snapshot array.
Read the indicator configs last passed through setIndicatorConfigs.
Returns an empty array if the host used the legacy
setIndicators(Indicator[]) path — in that case the chart has no
way to reverse-engineer configs from arbitrary Indicator subclasses.
Read the indicator set currently rendering.
The current markers, in draw order.
Read the current price-axis scale mode.
The attached primitives, in attach order.
Id of the currently-selected drawing, or null.
Get the viewport
Scroll to the live edge and resume following new candles.
True while replay mode is engaged (a virtual buffer cap is active).
Replace all drawings with a fresh snapshot list. Unknown drawing
kinds are silently skipped (same semantics as
DrawingLayer.fromSnapshot).
Restore chart state from a previously saved layout or full state.
Accepts both LayoutState and FullState — when data is
present it is loaded via setData, otherwise the current buffer
is preserved and only the visual/interaction layer is updated.
Throws ValidationError on unknown schema version.
Restore order is critical — changing it can leave the viewport clamped, indicators stale, or a rogue paint frame rendered against the wrong chartType. See the M1 spec for the rationale.
Pause automatic replay playback.
Begin/resume automatic replay playback. No-op until startReplay.
Prepend older candles to the buffer without resetting the viewport.
Call this from your onLoadMoreHistory handler when you've fetched
more historical data. The user's current startIndex is shifted by
the number of candles that were actually added, so visually the
same candles stay under the cursor.
Redo the last undone drawing mutation. Returns true if applied.
Register a custom primary-series type as a first-class citizen — it
participates in autoscale (via its priceRange), conflation, and the
crosshair. Use setChartType(def.type) to activate it. Register before
loadState if a saved chart references the custom type (otherwise the
load falls back to candles at render time).
Remove an alert by id (and its price line). Returns true if removed.
Remove a marker by id. Returns true if one was removed.
Force a render
Serialize the chart including the full data window. Use for workspace persistence or bug reproduction where the recipient should not need a transport to rehydrate. Typical size ranges from 100 KB to 1 MB depending on buffer length.
Serialize the chart's layout (without data) to a JSON-safe object.
The result is small enough to round-trip through a URL query
parameter after base64 encoding — typical size is a few hundred
bytes. Use saveFullState when you also need the data window.
getIndicatorConfigs() returns an empty array if the host used
the legacy setIndicators(Indicator[]) path — save/load then
round-trips visual state but not indicators. Prefer
setIndicatorConfigs for framework wrappers.
Jump replay to a specific bar index (clamped into range).
Select a drawing by id, or clear the selection with null.
Hit-test the auto-managed drawings at a canvas point (in CSS pixels
relative to the chart container) and select the topmost match — or
clear the selection if nothing is hit. Returns the selected drawing's
id, or null. Wire this to a click/pointerdown handler.
Optionaltolerance: numberSwitch the primary price-series rendering style (built-in or custom).
Switch crosshair mode at runtime: 'normal' (free Y) or 'magnet'
(snap Y to the nearest OHLC level of the candle under the cursor).
Set data directly (without transport).
By default, fully resets the buffer and scrolls the viewport to the live edge — the correct behavior when the user has just switched symbols or timeframes.
Pass { preserveView: true } to keep the viewport's current
startIndex, candleWidth, and autoFollow state. This is what
framework wrappers (React/Vue) want when they re-dispatch the same
data array as a prop change: the user's pan/zoom position should
not jump to the right edge every time React re-renders.
Optionalopts: { preserveView?: boolean }Attach (or clear) a drawing layer rendered above the price series.
Replace the horizontal-scale behavior, controlling how the X axis is labeled — time (default), price/strike (options charts), or custom. Note: the crosshair X-label still uses the time formatter for now.
Override the resting cursor on the top canvas. Drawing tools use this
to give the user visual feedback that a tool is selected — e.g.
'cell' for "click to place a point", or 'copy' for a ray tool.
Pass null to restore the default 'crosshair'.
Replace the indicator set using declarative configs. This is the
recommended path for React/Vue wrappers: the chart remembers the
configs so saveLayoutState() can round-trip them without the
wrapper having to track indicators out-of-band.
Replace the indicator set on the chart with pre-constructed instances.
Advanced use only — most hosts should call setIndicatorConfigs
instead so the chart can serialize the indicators through
saveLayoutState. Calling this method clears the internal
IndicatorConfig[] mirror, so subsequent saveLayoutState calls
will return indicators: [] even though the chart is still
rendering them.
Switch localization at runtime (C6): rebuilds the i18n bundle from the
given BCP-47 locale (or undefined for the locale-agnostic defaults)
and optional messages overrides, updating the aria-label, axis
number/date formatting, legend, and pills, then repaints. Pass no args to
reset to the English, locale-agnostic baseline.
Optionallocale: stringOptionalmessages: Partial<Messages>Replace all candle-anchored markers (buy/sell arrows, event flags).
Markers are pinned by time, so they survive history loads and
maxCandles eviction. Markers are runtime annotations — they are not
included in saveLayoutState; persist them yourself if needed.
Install a double-click callback that fires with the HoverInfo for the
cursor position (or null outside the plot). Additive — the chart's
built-in double-click reset (fit-visible / reset price scale) still runs.
Install a hover callback that fires on every crosshair snap.
Switch the price-axis scale mode:
'linear' — equal price deltas are equal pixel deltas (default)'log' — equal ratios are equal pixel deltas (BTC-over-years)'percentage' — axis reads % change vs. the first visible candle'indexedTo100' — first visible candle anchored at 100Clears any manual (dragged) price scale so the new mode auto-fits.
Set replay playback speed in bars per second.
Set (or replace) a faint background watermark — text (symbol/timeframe)
or an image (logo), painted behind the grid and series. Runtime-only;
not included in saveLayoutState.
Begin an interactive drawing workflow. The next click event
routed through the host's click handler should call
drawingLayer.addPoint({ index, price }). When the drawing
completes (enough anchors), it is finalized automatically.
Supported tools (see DrawingTool):
trendline (2 points)hline (1 point — horizontal price line)vline (1 point — vertical index line)rectangle (2 points — diagonal corners)ray (2 points — semi-infinite line)fib (2 points — Fibonacci retracement levels)fibext (3 points — Fibonacci extension targets)channel (3 points — equidistant channel)arrow (2 points — arrow segment)parallelchannel (3 points — bounded parallel channel)regression (2 points — least-squares channel ±2σ over the span)pitchfork (3 points — Andrews' pitchfork)fibfan (2 points — Fibonacci fan rays)measure (2 points — price/percent/bar ruler)Enter bar-by-bar replay mode (C1), revealing history up to fromIndex
(default 0 — start from the first bar). The chart then shows only the
revealed prefix; advance with playReplay/stepReplay or
jump with seekReplay. Leave replay with stopReplay.
OptionalfromIndex: numberReveal/hide one replay bar (forward default true).
Optionalforward: booleanLeave replay mode: clears the virtual buffer cap so the full buffer renders again, stops playback, and repaints. Safe to call when not in replay (no-ops the cap clear).
Switch to a different symbol/resolution
Snapshot the chart as a PNG data URL. Returns null if the
browser cannot provide a 2D context (sandboxed iframe).
Undo the last drawing add/remove/clear. Returns true if applied.
Zero-copy view over the candles currently in the visible window
(excludes the +1 render-only bar). Returns null when there is no data
or the window is empty. Primarily the data seam an optional, attach-only
overlay (C4 Volume Profile via VolumeProfileController) reads through —
delegates to ChartEngine.visibleCandleView.
Add a price alert (C3). Returns the created Alert (with its generated
a_<n>id and resolvedcondition). An active alert is drawn as a dashed amber price line; it fires once on the realtime close-price tick that satisfies its condition, invokingChartConfig.onAlertand removing its line (one-shot — see removeAlert / re-add to re-arm). Alerts are included insaveLayoutState.