Constructors

Accessors

Methods

addEventMarkers addIndicator addPriceLine addPrimitive addSeries alertState applyOptions applySize axisChromeOptions beginPick brandingOptions canvasOptions coordinateToPrice coordinateToTime crosshairMode crosshairSnapToBar destroy downloadScreenshot drawingState emit eventMarkers eventOptions exportSVG fitContent getDataContext getState getVisibleLogicalRange gridOptions hasBarsProvider hasSnapshotProvider hasTrading historyLoadComplete indicatorLegendCollapsed indicators invalidate invalidateRequestedData legendIconSize maximizedPane maximizePane movablePrimaryPane moveIndicator moveInSeriesStack movePane movePriceAxis navigationOptions off on once paneCollapsed panes paneWeight plotRect priceAxisLayout priceAxisPlacement priceAxisState priceOnlyAutoScale priceScaleDefaults priceScaleOptions priceToCoordinate primaryBars primaryPaneIndex primarySeries primarySeriesInfo removeIndicator removePane removePrimitive reorderIndicator resetScale restoreState seriesStack seriesStyle seriesTransform seriesType setAlertState setAutoScale setAxisChromeOptions setBarsProvider setBranding setCanvasOptions setDataContext setDrawingState setEventGroups setEventGroupVisible setEventMarkerOptions setEventOptions setEvents setGridOptions setHistoryLoader setIndicatorLegendCollapsed setLegendIconSize setLinkedCrosshairIndex setNavigationOptions setPaneCollapsed setPaneWeight setPlacementMode setPriceAxisAutoFit setPriceAxisLockRatio setPriceAxisOptions setPriceAxisPlacement setPriceFormatter setPriceOnlyAutoScale setPriceScaleOptions setPrimaryPaneIndex setPrimitiveStackAbove setSeriesPriceScale setSeriesTransform setSeriesType setSessionCalendar setStatusLineOptions setTheme setTickSchedule setTimeFormatter setTimezone setTradingSettings setVisibleLogicalRange setWatermarkOptions snapPrice statusLineOptions subscribeClick subscribeCrosshairMove subscribeDrag takeScreenshot theme tickSchedule timeToCoordinate timezone tradeHost tradingSettings watermarkOptions

Constructors

Accessors

  • get hasOpenInterest(): undefined | boolean
  • Instrument capability from the host. A missing bar reading does not change it.

    Returns undefined | boolean

  • get isDestroyed(): boolean
  • 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.

    Returns boolean

  • get rendererKind(): RenderBackendKind
  • 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').

    Returns RenderBackendKind

Methods

  • Add 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).

    Parameters

    Returns IndicatorApi

  • Parameters

    • width: number
    • height: number

    Returns void

  • 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.

    Parameters

    Returns PickHandle

  • 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.

    Parameters

    Returns PickHandle

  • 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.

    Parameters

    • y: number
    • paneIndex: number = ...

    Returns null | number

  • Container-relative x (media px) to UTC seconds.

    Parameters

    • x: number

    Returns number

  • Crosshair behaviour ('normal' or 'magnet'). Set it via applyOptions.

    Returns CrosshairMode

  • Whether the vertical crosshair snaps to an existing primary bar's center.

    Returns boolean

  • 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.

    Parameters

    • filename: string = 'chart.png'

    Returns void

  • The opaque drawings slot in the chart state. The base engine only round-trips it; the drawing tier reads and writes it.

    Returns unknown

  • Put an event on the chart's bus, for every listener of that name.

    Parameters

    • event: string
    • payload: unknown

    Returns void

    Removed in 3.0.0. The bus carries the chart's own events. Announce an instrument with setDataContext, drive a link group with LinkGroup.setSymbol, setInterval and setChartType (all three since 2.5.10), and keep events of your own on your own emitter.

  • 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.

    Parameters

    Returns string

  • Fit all bars into view (no-arg convenience; bar count from the data).

    Returns void

  • 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.

    Returns ChartState & ChartSettingsState & { timezone: string }

  • Current grid options, visibility first (it is the one field always set).

    Returns { horzLines: boolean; vertLines: boolean } & Partial<GridOptions>

  • Whether a bars provider is registered, so a host can grey what needs one.

    Returns boolean

  • Whether the configured provider supplies explicit availability snapshots.

    Returns boolean

  • Whether the trade layer exists yet. Reading chart.trading creates one, which subscribes to clicks and drags and so makes every ns-resize price line draggable, so anything that merely inspects the chart (a settings dialog) asks this first.

    Returns boolean

  • Call after a history-paging load resolves to re-enable the trigger.

    Returns void

  • Whether study legend rows are replaced by their applied-instance count.

    Returns boolean

  • 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.

    Returns readonly IndicatorApi[]

  • Parameters

    • build: (mask: InvalidateMask) => void

    Returns void

  • Announce changed requested data without replacing a provider or price bars.

    Returns void

  • The maximized pane index, or null when none is.

    Returns null | number

  • Expand one pane to fill the chart, hiding the others. Calling it again (or on another pane) puts the stack back exactly as it was, since the stored weights were never disturbed.

    Parameters

    • index: number

    Returns boolean

  • Whether the price pane may leave the top of the stack, see ChartOptions.movablePrimaryPane. False unless the host opted in, and while it is false the price pane stays at slot 0 for the life of the chart.

    Returns boolean

  • 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.

    Parameters

    Returns boolean

  • 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.

    Parameters

    Returns boolean

  • 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.

    Parameters

    • index: number
    • direction: -1 | 1

    Returns boolean

  • 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.

    Parameters

    • paneIndex: number
    • from: "left" | "right"
    • to: "left" | "right"

    Returns boolean

    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.

  • Remove one listener, or (when cb is omitted) every listener for an event.

    Type Parameters

    Parameters

    Returns void

  • Parameters

    • event: string
    • Optionalcb: (payload: unknown) => void

    Returns void

    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.

    Type Parameters

    Parameters

    Returns () => void

  • Parameters

    • event: string
    • cb: (payload: unknown) => void

    Returns () => void

    Removed in 3.0.0. Use a ChartEventMap name, or add yours to it by declaration merging (since 2.6.0).

  • Whether a pane is collapsed to its header strip. The primary price pane never is.

    Parameters

    • index: number

    Returns boolean

  • 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.

    Parameters

    • paneIndex: number

    Returns null | PlotRect

  • Active price columns in pane CSS coordinates, ordered nearest the plot on each side.

    Parameters

    • paneIndex: number = ...

    Returns readonly PriceAxisSlot[]

  • 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.

    Parameters

    Returns null | PriceAxisState

  • Whether only the primary series contributes to autoscale on its current scale.

    Returns boolean

  • 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.

    Returns Partial<PriceScaleOptions>

  • 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.

    Parameters

    • price: number
    • paneIndex: number = ...

    Returns null | number

  • The primary series' bars as drawn, without allocating a history copy on each live update: a transformed series' elements, which its handle's getData does not return.

    Returns readonly Bar[]

  • 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.

    Returns number

  • The primary price series: the first one added, and the one the magnet crosshair, the OHLC legend, the market-replay controller and a settings dialog's Symbol tab all describe. Null until a price series exists.

    Returns null | SeriesApi

  • 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.

    Returns null | { style: Readonly<SeriesStyle>; type: SeriesType }

  • 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.

    Parameters

    Returns boolean

  • 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.

    Parameters

    Returns boolean

  • Change study stacking order among studies on the same pane. A study whose policy is not movable stays unless options.force is set.

    Parameters

    Returns boolean

  • Restore the preferred visible bar count and re-enable auto-scaling on every price axis (undoing any pan/zoom or manual axis drag). Same as double-clicking the chart.

    Returns void

  • 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.

    Parameters

    Returns RestoreReport

  • 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.

    Parameters

    • paneIndex: number = ...

    Returns string[]

  • Put every pane's price axis back under autoscale, or pin it where it is. PriceScale.setAutoScale alone changes nothing on screen until something else asks for a frame; this re-measures and repaints.

    Parameters

    • on: boolean

    Returns void

  • 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.

    Parameters

    Returns void

  • Parameters

    • id: string
    • visible: boolean

    Returns void

  • 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.

    Parameters

    • events: readonly ChartEvent[]
    • OptionalpaneIndex: number

    Returns void

  • Grid lines at runtime: visibility of each axis, plus its colour, dash, width and spacing. Omitted fields keep their current value. Repaints every pane.

    Parameters

    Returns void

  • Register a callback fired when the user pans near the left (oldest) edge.

    Parameters

    • loader: () => void

    Returns void

  • A display preference only; studies retain visibility, calculation and subscription state.

    Parameters

    • on: boolean

    Returns void

  • 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.

    Parameters

    • size: number

    Returns void

  • 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.

    Parameters

    • index: null | number

    Returns void

  • 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.

    Parameters

    Returns void

  • 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.

    Parameters

    • index: number
    • collapsed: boolean

    Returns boolean

  • Set a pane's relative height weight. Panes share the chart height in proportion to their weights, so only the ratio matters.

    Parameters

    • index: number
    • weight: number

    Returns void

  • 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.

    Parameters

    • active: boolean

    Returns void

  • 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.

    Parameters

    Returns void

  • 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.

    Parameters

    Returns boolean

  • 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.

    Parameters

    Returns void

  • Set 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.

    Parameters

    • fn: null | (price: number) => string

    Returns void

  • Keep manual ranges and ratio locks while choosing which data auto-fit measures.

    Parameters

    • on: boolean

    Returns void

  • 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.

    Parameters

    Returns void

  • 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.

    Parameters

    • index: number

    Returns boolean

  • 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.

    Parameters

    Returns boolean

  • 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.

    Parameters

    Returns boolean

  • 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.

    Parameters

    Returns boolean

  • 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.

    Parameters

    Returns boolean

  • 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.

    Parameters

    Returns void

  • 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.

    Parameters

    Returns void

  • 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.

    Parameters

    Returns void

  • 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).

    Parameters

    • fn: undefined | (utcSeconds: number, tickMark?: TickMarkType) => string

    Returns void

  • 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.

    Parameters

    • zone: string

    Returns void

  • Recolour the trade layer. Safe before it exists: the patch is held and handed over the moment chart.trading builds the controller.

    Parameters

    Returns void

  • 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.

    Parameters

    • paneIndex: number
    • price: number

    Returns number

  • 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.

    Parameters

    • cb: (externalId: string) => void

    Returns () => void

  • 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.

    Parameters

    Returns () => void

  • 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.

    Parameters

    • onDrag: (externalId: string, price: number, time: number) => void
    • OptionalonDragEnd: (externalId: string, price: number, time: number) => void

    Returns () => void

  • Flatten 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.

    Returns HTMLCanvasElement

  • UTC seconds to container-relative x (media px). The inverse of _xToTime.

    Parameters

    • time: number

    Returns number

  • 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.

    Parameters

    • OptionalpaneIndex: number

    Returns { addPrimitive(p: IPrimitive): void; removePrimitive(p: IPrimitive): void }

  • Trade-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.

    Returns TradingColors