True once destroy() has run. Anything holding a chart it did not create
(a link group, a controller, a host cache) needs to know the object is a
corpse before it calls into it: inferring it from a side effect such as an
empty pane list works only for as long as nothing else can empty one.
The name rendererKind shipped under; the same value.
Removed in 3.0.0. Use Chart.rendererKind (since 2.0.0), which reports the same backend.
The render backend the chart is painting series with right now: what the
first pane was given, which is the renderer option unless its factory
declined (no WebGL2 on this device) and the 2D backend stood in, and
canvas2d from the moment a GPU backend degrades ('renderer:fallback').
The keyboard shortcut manager (null when shortcuts are disabled).
The data-driven trading layer: push positions/orders/trades and the chart
renders pills + markers, emitting trading:* events on interaction. Created
on first access.
Add an earnings/dividend/split event-marker strip to a pane, the primary price pane by default.
OptionalpaneIndex: numberAdd a registered indicator. Built-in descriptors live in the lazy
openalgo-charts/indicators tier: import it (or register your own with
registerIndicator) before calling this.
'onchart' indicators overlay the price pane; 'pane' indicators get a new
pane of their own unless paneIndex says otherwise. The returned handle
recomputes automatically whenever the source data changes.
import 'openalgo-charts/indicators';
const macd = chart.addIndicator('macd', { fastPeriod: 8 });
macd.setSettings({ fastPeriod: 12 });
macd.remove();
options.policy restricts what the user may do with the study (see
IndicatorPolicy); the host keeps changing it with { force: true }.
options.instanceId gives the study that id instead of a new one, so a
host that brings a removed study back (an undo) brings back its identity:
the studies that read its output and the alerts that name it find it
again. An id a study on this chart holds now throws, since two studies
cannot answer to one id; the id of a removed study is free to take back.
options.barSource 'underlying' has a study on a transformed chart
compute on the host's bars rather than the elements drawn (see
IndicatorApi.setBarSource).
Add a horizontal price line (order/SL/TP/alert/level) to a pane. Omitting the pane means the primary price pane, wherever it sits.
OptionalpaneIndex: numberPublic: attach any primitive (indicators, profiles, custom overlays) to a pane, the primary price pane when none is named, or to a chart anchor.
Optionalwhere: number | PrimitivePlacementAdd a series and return its data handle.
Detached JSON state, also available when no alert controller is attached.
Apply a subset of chart options at runtime (theme, grid, formatters, crosshair mode) without recreating the chart.
The axis-chrome switches as they stand.
Arm the next plot click to answer with a price, a bar time, or both as a
'point', handed to cb. Returns a cancel function; arming another pick
on this chart cancels the pending one. pick:start and pick:end bracket
it so a host can show its own cursor while the pick is live. A target's
pane limits where the click counts and its scale is the one a price, a
point's included, is read on. See input/pick for why this does not touch
placement mode.
Optionaloptions: PickOptionsArm the next plot click to answer with a price, a bar time, or both as a
'point', handed to cb. Returns a cancel function; arming another pick
on this chart cancels the pending one. pick:start and pick:end bracket
it so a host can show its own cursor while the pick is live. A target's
pane limits where the click counts and its scale is the one a price, a
point's included, is read on. See input/pick for why this does not touch
placement mode.
Optionaloptions: PickOptionsHost branding options, excluded from saved chart state.
The Canvas option block as it stands (theme fallbacks are not folded in).
Map a container-relative media-px Y back to a price on a pane (inverse of priceToCoordinate). Null where that is, for the same panes. Both default to the primary price pane wherever it sits.
Composite the full chart (all panes + overlays) and trigger a PNG download. This is what the screenshot keyboard shortcut runs; call it from a toolbar button for a reliable "save image": the browser's native right-click "Save image as…" captures only the topmost (transparent overlay) canvas.
The chart-owned strip, or null before events or strip options are supplied.
The chart as a standalone SVG document: every pane's base and overlay paint, in the order the DOM stacks them, run once into a serialising context at pixel ratio 1. Text stays text (selectable, searchable) and lines stay lines, so the file scales without the blur a PNG picks up.
Nothing transient is in it: no crosshair, no hover state, no drag. What is
in it is exactly what the renderers, primitives and drawing tools draw,
because it is the same code drawing. A primitive that paints through a
call with no vector form (a bitmap logo, a shadow) is simply thinner in
the export; see SvgContext for the list.
Returns the string only. Saving it is the host's job, the way
downloadScreenshot is the host-facing half of takeScreenshot:
new Blob([svg], { type: 'image/svg+xml' }) and an anchor is all it takes.
Optional instrument identity supplied by the host, never inferred from bars.
Capture the chart's serialisable state: viewport, grid, crosshair mode,
pane weights and price scales, indicator instances, and a drawings slot
the drawing tier fills. JSON-safe.
Series data is not captured: the app owns that (it knows the symbol, the timeframe, and the feed). Series descriptors are, so an app that rebuilds its own series can re-apply their styling and placement.
The current visible logical range.
Current grid options, visibility first (it is the one field always set).
Every live indicator instance, in renderer stacking order.
Flushes any pending recompute first. Indicator maths is deferred to the frame, so a caller that updates a bar and reads a value back in the same turn would otherwise see the previous tick's numbers.
Move an existing study to an existing pane or a new pane at panes().length.
A study whose policy is not movable stays unless options.force is set.
Move a source or study directly above or below another entry of the same
pane's series band (see seriesStack). A study keeps its other bands'
layers in the new study order, so its fills, levels and markers follow.
The drawings placed above an entry travel with it. False, with nothing
changed, for an entry of another pane, a move that changes nothing, or a
study whose policy is not movable unless options.force is set.
Move a pane up or down one slot, swapping it with its neighbour.
By default the primary price pane is pinned at the top, as it always was:
a move that would take it off slot 0, or put a study pane above it, is
refused, so a host that means the price pane when it passes 0 keeps
meaning it. With movablePrimaryPane on, any pane moves, the price pane
included, and any pane can displace it: the price pane is then an identity
rather than a slot (see primaryPaneIndex), and everything that means
"the price pane" follows it. Returns false for an unknown slot, a
direction other than -1 or 1, a move off either end, or a pinned price pane.
Move a pane's price axis to the other strip, taking the series that map to
it and everything the axis was set to. Returns false when that side carries
nothing, or when the other side is already occupied: one strip draws one
axis (see Pane.moveSeriesScale), which is what movable reports.
Removed in 3.0.0. Use Chart.setPriceAxisPlacement (since 2.5.4), which moves a scale's column and keeps its id; this method instead swaps the built-in side scales and reassigns their series and studies.
Current navigation preferences, safe to save as JSON.
Remove one listener, or (when cb is omitted) every listener for an event.
Optionalcb: (payload: ChartEventMap[K]) => voidOptionalcb: (payload: unknown) => voidRemoved in 3.0.0. Use a ChartEventMap name, or add yours to it by declaration merging (since 2.6.0).
Subscribe to a chart event, typed by its ChartEventMap name. Returns an unsubscribe function.
Removed in 3.0.0. Use a ChartEventMap name, or add yours to it by declaration merging (since 2.6.0).
Subscribe to the next occurrence of an event, then unsubscribe. Returns a function that cancels it first.
Removed in 3.0.0. Use a ChartEventMap name, or add yours to it by declaration merging (since 2.6.0).
A pane's plot in container px: left and top from the container's
top-left corner, inside the price axis columns and above the time axis,
and the size a primitive on that pane paints into. What a host lays an
overlay against, and what a drawing pinned to the screen is a fraction of.
Null for a pane with no plot on screen: one collapsed to its header
strip, one hidden behind a maximized pane, or no pane at that index.
The pane is scaled first, the way a price conversion scales it: a caller that places something on the plot reads the pane's prices next, and a pane no frame has painted yet (just made, or just moved) still holds its placeholder range.
Active price columns in pane CSS coordinates, ordered nearest the plot on each side.
Detached visible placement. Hidden named scales retain their independent range.
State of one price axis, for a host rendering a menu over it: what is currently on, and which items are worth offering. Null for a pane that does not exist.
active false is a scale no series maps to: the ladder on an empty chart,
or the side a menu was raised on before anything was plotted there. That is
a row to render disabled with its state visible, not one to leave out.
The chart-wide price-scale defaults: every field setPriceScaleOptions,
the priceScale construction option and the canvas margins have set, and
what a pane added later starts from. priceScaleOptions() reads the price
pane's own scale instead, which a change made to that one axis moves and
this does not, so the two together tell a chart-wide change from a
one-axis one. minMove here reaches only the panes that quote the
instrument. A detached copy; empty when nothing was ever set.
The primary pane's price-scale options (what the Scales tab reads), wherever it sits.
Map a price to a container-relative Y in media (CSS) px, for positioning DOM
overlays (order panels, tooltips) over a pane. Returns null if the pane
doesn't exist or is collapsed to its header strip, which plots no price.
The inverse is coordinateToPrice.
Where the primary price pane sits in the stack, counted from the top. The
primary pane is the one the chart is built with. It holds the price series
a host adds without naming a pane and the on-chart studies, and it is what
every call that defaults to "the price pane" means: addSeries,
addPriceLine, addEventMarkers, addPrimitive, tradeHost, the
coordinate calls, comparisons, and a drawing magnet or price alert. It is
0 until something moves it, and always 0 on a chart without
movablePrimaryPane; it is never removed and never collapsed.
Type and live style of the primary series, for a settings dialog: the type
decides which controls apply (a candle has borders, a line has a dash), and
the style is the object applyOptions patches.
Remove one indicator instance by its handle id. Returns true if it existed
and went; a study whose policy is not removable stays unless
options.force is set.
Remove a pane, everything drawn in it, and any indicator that lives there. The primary price pane is never removable, in whatever slot it sits: removing it would leave the chart with no price series to describe and nothing for a series, a price line or an on-chart study to default to. A study pane is removable in any slot, the top one included.
Returns false when the index is out of range or names the primary pane,
and when it holds a study whose policy is not removable unless
options.force is set.
Remove a primitive from whichever pane holds it.
Change study stacking order among studies on the same pane. A study whose
policy is not movable stays unless options.force is set.
Re-apply a state captured by getState. Restores grid, crosshair mode,
pane weights and price scales, indicators, and the viewport: everything
the chart is the source of truth for.
It does not recreate series: the chart has no way to know their data.
The returned report lists the series descriptors it saw so the caller can
rebuild them (addSeries(s.type, { paneIndex: s.paneIndex, style: s.style }))
and then feed them.
Restore the viewport after your data lands: logical ranges index bars, so
a range applied to an empty chart means nothing. Call restoreState again
(or setVisibleLogicalRange) once the series are populated.
The series band of a pane, back to front: 'source:primary' where the
price source is on this pane, and 'indicator:<id>' for each study that
lives on it and plots a series here, in the order they paint. The same
ids as the object inventory. Host series and a study's plots placed on
another pane paint in the band too, in their own slots, but are not
entries of it.
Frozen style snapshot, including renderer defaults, or null for an unavailable handle.
The transform a series was given, or null for none and for a handle not live on this chart.
Live renderer type, or null for a foreign, removed or destroyed series handle.
Runtime snapshot. JSON safety of opaque payloads is checked when state is read.
Turn the axis-strip chrome on or off, and hand it a clock. Merges field by field, so switching the countdown on leaves the corner clock alone.
Register, replace or remove (null) the provider indicators reach through
requestBars. Read at request time, so an indicator added before the
provider was set is served once one exists.
Replace chart-owned branding. Manually attached primitives are independent.
The Canvas option block (grid, crosshair, scale text/lines, plot margins). Each sub-block merges field by field, so setting one grid colour leaves the rest of the grid alone.
Clear the previous source bars before changing context, then load the new source.
Configure clustering without replacing event data or group visibility.
Turn event types on/off. Unlisted types stay visible.
Hand the chart the corporate-action / news calendar and let it own the
strip. The difference from addEventMarkers is who filters: holding the
full list here is what lets setEventOptions (the settings dialog's Events
switches) turn a type off and back on without the host re-supplying data.
OptionalpaneIndex: numberGrid lines at runtime: visibility of each axis, plus its colour, dash, width and spacing. Omitted fields keep their current value. Repaints every pane.
How large a legend's action buttons are drawn, in media px.
Chart-wide rather than per legend: the rows stack against the height the buttons need, so two sizes on one pane would stack against two different heights and overlap. The primitive holds it to a range it can actually draw.
Update the readout under a link group's separately drawn crosshair. The physical pointer takes precedence. This never emits a pointer move event, so hosts do not interpret it as drawing input or echo it to another group.
A new default count or spacing immediately restores that view without dropping history.
getState saves these preferences, so the change is announced with layout:change;
a pan or zoom switch also fires objects:change, as it always has.
Fold a pane to a header strip, or open it again. A collapsed pane keeps everything it holds: its series still take data, its studies still recompute, and its drawings, scales and stored weight are untouched, so opening it brings back exactly the height it had. The strip shows one legend row, the pane's first study row with the control that opens it, ahead of any row the host placed there, and on the bottom pane the time axis; nothing else in it paints or answers the pointer, and no coordinate conversion maps a price onto it.
The primary price pane stays open in whatever slot it sits, top, middle or bottom: it carries the price the chart exists to show, and a chart always keeps one open pane for its furniture and the time navigator. Collapse is a property of a pane rather than a slot, so a fold travels with its pane through a move, and a study pane moved above the price pane, to slot 0, folds like any other. Collapsing the maximized pane ends the maximize, since a strip cannot fill the chart; maximizing a collapsed pane shows it whole until the maximize ends. Returns false for the primary pane, an unknown index, a value that is not a boolean, or no change.
Turn pointer gestures into anchor placement instead of panning. A host arms
this while a drawing tool is active: a press no longer scrolls the chart, and
a press-drag-release is reported as two click events (press point, then
release point, the latter tagged viaDrag) so a two-point shape can be drawn
in one gesture. DrawingController drives this for you.
Auto-fit one axis: its range tracks the data again, or stays where the user
left it. Turning it on releases any ratio lock on that axis, for the reason
given in setAutoScale.
Pin one axis' price-per-bar ratio: zooming the time axis then rescales the prices with it, so a trend drawn at 45 degrees stays at 45 degrees. The axis goes manual, because auto-fit would re-fit the data every frame and undo the ratio being held.
Returns whether the axis is now in the state asked for. Locking fails on a scale nothing has measured: there is no ratio to hold on an empty pane, or on one whose series plot no values at all.
Options for one pane's scale (mode, invert, tick size, margins) rather than every pane's. The four modes are one field, so picking one drops the previous by construction: a menu renders them as a single choice.
Move or reorder a scale without changing its ID, sources, formatter or range.
Optionalorder: numberSet a custom price formatter for every pane's axis labels, last-price tag, and price-line labels at runtime (e.g. switch to a currency format). Pass null to restore the default tick-size-aware formatting.
Price-scale options for every pane (mode, inverted, tick size, margins), and the default new panes inherit.
scope says how far a chart-wide setting reaches:
'primary' (default): each pane's right scale only. A mode change
wants this: rebasing a volume overlay quotes percent change in lots.'axes': every scale that draws a ladder, so the left axis moves with
the right. Plot margins want this.'all': the hidden overlay scales too. Almost nothing should: an
overlay's margins are its creator's placement, see Pane.axisScales.minMove is the one field no scope carries onto a pane that does not quote
the instrument, whichever scope is asked for: see _scalePatchFor. Every
other field is a property of the axis and reaches exactly as far as scope
says.
Move the primary price pane to another slot, for example below its
studies. It goes one adjacent move at a time, so each step is an ordinary
movePane with its own paneMoved event: drawings, alerts and anything a
host keys by slot follow it the way they follow any other move. Weights,
scales, a fold or a maximize stay with the panes that own them. Returns
false for a slot that does not exist or the slot it already holds, and
always false on a chart built without movablePrimaryPane, where the price
pane stays at the top: that option is the one switch for every move.
Paint an attached primitive inside the series band of its pane, directly
above the source or study above names (an id from seriesStack), or
pass null to return it to its own z-order band. While that entry plots
no series on the primitive's pane it paints in its own band. A drawing
layer is the case this exists for. False for a primitive on no pane.
Assign a host-owned series to a scale on its current pane without replacing it. Both scales retain their configuration. Explicit series formatting applies to the target as it does when adding a series, including a shared target scale. Returns false for invalid IDs, unchanged assignments, unavailable handles or indicator-owned plots, whose pane-bound visuals must move with the whole study.
Have the chart apply a price-driven transform (Heikin Ashi, Renko, range
bars, line break, point and figure or Kagi, once openalgo-charts/transform
is imported) to a series, or draw its bars as given again with null. The
series keeps taking the host's own bars through setData, update and
prependData, and getData hands those back; the chart draws the elements
and forms them again on every tick. Studies read the elements unless one is
set to the underlying bars (IndicatorApi.setBarSource). A new transform
type selects its renderer; setSeriesType afterwards keeps the transform.
Returns false for an unchanged choice or an unavailable handle. An unknown
type or an invalid option throws before anything changes.
Change a live series' renderer without replacing its handle, data or attachments.
Explicit styles survive; inherited renderer defaults give way to the new type.
It never transforms data: a point-figure or kagi renderer draws the bars
it is given, which is how a host that prepares its own elements keeps
working, and setSeriesTransform is how the chart applies one itself.
Returns false for an unchanged type or a foreign, removed or destroyed handle.
An unregistered type throws before any state changes.
Lay the time axis past the last bar out in these trading hours, or drop them with null, and repaint every pane, so a drawing already placed past the last bar moves to the time it now means.
This is the call for a host setting hours on its own: a SessionCalendar
or an Instrument it holds, or any object with sessionFrom.
Instrument.applyTo and SessionCalendar.applyTo come here too.
chart.dataLayer.setSessionCalendar sets the same hours and asks for no
frame, for a host about to load bars or move the view anyway, either of
which repaints.
Per-field status-line switches, applied to every pane legend on the chart: the host's symbol row and the indicator rows alike, which is what makes one switch mean the same thing everywhere. Merges field by field.
Swap the palette at runtime (dark/light toggle) without recreating the chart.
Hand the chart the instrument's price-dependent ticks, for a host that
keeps its own instrument metadata rather than calling
Instrument.applyTo. Price alerts and anything else rounding through
snapPrice on the price pane then land in the band a price falls
in, and the trading layer's order and bracket drags take the same
schedule, now or when it is built. Null restores the constant tick. It
describes the loaded instrument, so it is not part of the saved state.
Set a custom time-axis + crosshair label formatter (UTC seconds -> string)
at runtime. Pass undefined to go back to the default labels, which follow
the chart's timezone (IST unless set).
Change the zone the time axis and crosshair label in, without rebuilding the chart: a terminal switching from an NSE symbol to a US one needs exactly this. Throws on a name the runtime does not recognise, rather than quietly labelling in the old zone, because a chart showing the wrong hours is the kind of wrong nobody notices until it costs money.
Recolour the trade layer. Safe before it exists: the patch is held and
handed over the moment chart.trading builds the controller.
Restore a saved logical range (e.g. preserve the user's zoom across a data reload).
Patch background text preferences. Boolean input changes visibility only.
A price rounded to the tick the pane's own axis is written with, or, on the price pane of an instrument with a tick schedule, to the tick of the band the price falls in.
A dragged alert's price comes from a pointer, and a pixel maps to a price with a dozen decimals behind it: dropped where the axis reads 1255.90 it was stored as 1255.8706204379562, a price the instrument cannot trade at and a number nothing in the interface could show. The scale already knows the tick, because it is the one the axis is written with, so this is the chart's answer rather than something every host works out again.
A scale holds one tick, and with a schedule that is the grid every band lies on: 105.87 is on a 0.01 grid and still no price in a 0.25 band. So the price pane, whose prices are the instrument's, asks the schedule. Another pane is in a study's own units, which no schedule describes.
A scale with no declared tick rounds nothing: there is no tick to round to and inventing one would move a price somebody chose.
Subscribe to clicks on hit-testable primitives (markers, events, lines),
with the primitive's externalId. Every subscriber hears every click, the
trade layer's among them; the function returned unsubscribes this one.
Before 2.6.0 each call replaced the previous callback, so a host that subscribes again on the same chart calls the returned function first.
Subscribe to crosshair movement for an OHLC legend / tooltip. The callback
fires with the hovered bar of the primary price series on every move, and
with all-null fields when the pointer leaves the plot. A linked crosshair
also updates the readout, with source 'linked' and no pointer coordinates.
Several may subscribe, as with subscribeClick; the function returned
unsubscribes this one.
Subscribe to drags of draggable primitives (order / SL / TP lines, drawing handles). Fires per move and on release.
time is the UTC seconds under the cursor, interpolated between bars and
extrapolated past the right edge, so a two-axis drag (a trendline endpoint,
a projection) has a usable time even where the gapless axis has no bar.
Price-only consumers can simply ignore it.
Several may subscribe, as with subscribeClick; the function returned
unsubscribes this pair. While any subscription holds, a price line whose
cursor is ns-resize drags instead of panning the chart.
OptionalonDragEnd: (externalId: string, price: number, time: number) => voidFlatten every pane's base + overlay canvas into one opaque canvas (device px). The chart renders as stacked layered canvases, so the browser's native right-click "Save image" only captures the layer under the pointer (usually the transparent crosshair overlay): use this to export the full chart.
The active palette. Swap it with setTheme.
The instrument's tick schedule, or null for a constant tick, the default.
Instrument.applyTo sets it from the instrument's tickBands.
A host for the (lazy-loaded) trade layer to attach/detach its primitives on a pane. Without an index it follows the primary price pane, resolved at each attach, so an order line drawn after the price pane moved still lands beside the candles.
OptionalpaneIndex: numberTrade-layer colours, whether or not the controller has been created. Once
it exists it is the single answer (a host may set colours on it directly);
before that, the held patch is folded onto the defaults. The fold is needed
because the two shapes name a colour differently: the patch says
longColor, the resolved palette says long.
JSON-safe preferences. Automatic text remains blank in this snapshot.
Instrument capability from the host. A missing bar reading does not change it.