charton API / @chart-on/core / index / ChartEvents
Interface: ChartEvents
Defined in: packages/core/src/chart.ts:1018
Events emitted by the chart, by name, with their payloads: pointer and crosshair input, view and scale changes, data loading, drawings, indicators, errors and more. Subscribe with chart.on.
Extends
Properties
access:change
access:change:
object
Defined in: packages/core/src/drawing/manager.ts:92
setAccess() changed which tools are allowed; allow is the new rule, null for all.
allow
allow:
AccessRule|null
Inherited from
annotations:cluster
annotations:cluster:
ClusterClickEvent
Defined in: packages/core/src/chart.ts:1126
A cluster of folded order labels was clicked (see annotations.applyOptions({ overlap: 'cluster' })), after its onClusterClick. The UI package lists the orders unless defaultPrevented.
appearance:change
appearance:change:
ChartAppearance
Defined in: packages/core/src/chart.ts:1168
applyOptions changed the theme or the grid; the payload is chart.appearance(). Persist on this.
baseline:change
baseline:change:
BaselineChangeEvent
Defined in: packages/core/src/baseline-handle.ts:18
The user dragged a baseline series' base handle on the price axis.
Inherited from
BaselineEvents.baseline:change
chart:contextmenu
chart:contextmenu:
ChartContextMenuEvent
Defined in: packages/core/src/chart.ts:1086
Right click (or the keyboard menu key) on a plot, an axis or a drawing, or a touch long press on a plot with touchInspect: 'off'. While the contextMenu feature is on and this event has a listener, the browser's own menu is suppressed.
chart:destroy
chart:destroy:
Record<string,never>
Defined in: packages/core/src/chart.ts:1062
destroy() was called; the chart is still intact while listeners run.
chart:error
chart:error:
object
Defined in: packages/core/src/chart.ts:1096
An event listener threw (code 'listener-failed', the thrown error as cause, the event name in context.event). The other listeners and the frame still ran. Without a listener here the error is logged instead.
error
error:
ChartError
chart:resize
chart:resize:
object
Defined in: packages/core/src/chart.ts:1060
The chart's size changed (css px).
height
height:
number
width
width:
number
compare:error
compare:error:
object
Defined in: packages/core/src/chart.ts:1090
A compared symbol failed to load; error is as in data:error.
error
error:
ChartError
symbol
symbol:
string
context:lost
context:lost:
object
Defined in: packages/core/src/chart.ts:1154
The GPU context was lost; the series stop drawing until it is restored. reason is 'budget' when the chart gave it up for the page's context budget (see setContextBudget), 'browser' for a driver reset or the browser's own context limit.
reason
reason:
ContextLossReason
context:restore-failed
context:restore-failed:
object
Defined in: packages/core/src/chart.ts:1158
The GPU context came back but could not be set up; the series stay blank. Recreate the chart to recover.
error
error:
ChartError
context:restored
context:restored:
object
Defined in: packages/core/src/chart.ts:1156
The GPU context is back and the chart redraws.
reason
reason:
ContextLossReason
crosshair:move
crosshair:move:
CrosshairEvent|null
Defined in: packages/core/src/chart.ts:1029
data:bar
data:bar:
object
Defined in: packages/core/src/data/types.ts:301
A live bar was merged (replaced the last bar or appended).
appended
appended:
boolean
bar
bar:
Bar
Inherited from
data:dropped
data:dropped:
DataDroppedEvent
Defined in: packages/core/src/chart.ts:1147
A bar or point was left out: older than the series' last one in update or from a live feed, invalid data from a data source, or a duplicate time removed by setData(..., { normalize: true }) or a source load.
data:error
data:error:
object
Defined in: packages/core/src/data/types.ts:286
A load failed. error.code is 'unknown-symbol', 'load-failed', 'history-failed' or 'reset-failed', with the data source's own error as cause; a ChartError the source threw itself (e.g. 'invalid-interval') is kept. 'unknown-symbol' means the source's symbol threw, whatever the reason. kind says which load failed: 'initial', 'history', or 'reset' (a refetch after a source reset, a reconnect or chart.reload()).
error
error:
ChartError
interval
interval:
Interval
kind
kind:
DataLoadKind
symbol
symbol:
string
Inherited from
data:loaded
data:loaded:
object
Defined in: packages/core/src/data/types.ts:277
Bars changed after a load; bars is the full series now on the chart.
bars
bars: readonly
Bar[]
interval
interval:
Interval
kind
kind:
DataLoadKind
symbol
symbol:
SymbolInfo
Inherited from
data:loading
data:loading:
object
Defined in: packages/core/src/data/types.ts:275
interval
interval:
Interval
kind
kind:
DataLoadKind
symbol
symbol:
string
Inherited from
data:quote
data:quote:
object
Defined in: packages/core/src/data/types.ts:303
The data source sent a bid/ask quote for the current symbol.
quote
quote:
Quote
symbol
symbol:
string
Inherited from
data:reconnect
data:reconnect:
object
Defined in: packages/core/src/data/types.ts:307
The live stream is back after gap seconds; missed bars are refetched unless the gap is too long.
gap
gap:
number
Inherited from
data:reconnecting
data:reconnecting:
object
Defined in: packages/core/src/data/types.ts:305
The source's live stream dropped and is reconnecting; since is when it went down.
since
since:
number
Inherited from
data:reset
data:reset:
object
Defined in: packages/core/src/data/types.ts:322
Bars were refetched after the source reported a reset (onReset); range is undefined for the whole series.
interval
interval:
Interval
range
range:
ResetRange|undefined
symbol
symbol:
SymbolInfo
Inherited from
data:snapshot
data:snapshot:
object
Defined in: packages/core/src/data/types.ts:320
A cached snapshot of the requested symbol and interval was painted while its load runs (see the cache option). data:loaded follows when the load lands; its bars replace the snapshot's unless they are the same.
bars
bars: readonly
Bar[]
interval
interval:
Interval
savedAt
savedAt:
number
symbol
symbol:
SymbolInfo
Inherited from
data:stale
data:stale:
object
Defined in: packages/core/src/data/types.ts:314
Bars on screen may be out of date: an outage outlasted maxGapFillSeconds (reason: 'outage', gap its length), or a load failed while a cached snapshot was shown and the snapshot stays ('reconcile', gap its age). Both in seconds.
gap
gap:
number
reason
reason:
"outage"|"reconcile"
Inherited from
data:warning
data:warning:
object
Defined in: packages/core/src/data/types.ts:293
A load landed with something missing. error.code is 'adjustments-failed' when adjustments failed for the bars of that load (kind): they show unadjusted, and the next load of the symbol and interval asks again. cause is the data source's error.
error
error:
ChartError
interval
interval:
Interval
kind
kind:
DataLoadKind
symbol
symbol:
string
Inherited from
draft:edit
draft:edit:
DraftEditEvent
Defined in: packages/core/src/chart.ts:1131
A draft's quantity or type was clicked (see annotations.startOrderDraft). The UI package opens a keypad or a type menu unless defaultPrevented.
drawing:bounds
drawing:bounds:
object
Defined in: packages/core/src/drawing/manager.ts:108
The selected drawing's on-screen box (plot-space css px) changed while rendering; rect is null when it is out of view or nothing is selected.
id
id:
string|null
rect
rect:
Rect|null
Inherited from
drawing:click
drawing:click:
object
Defined in: packages/core/src/drawing/manager.ts:128
A press and release on a drawing without dragging it.
id
id:
string
Inherited from
drawing:create
drawing:create:
object
Defined in: packages/core/src/drawing/manager.ts:116
A drawing was added, by the user, add(), clone(), undo or redo.
drawing
drawing:
Drawing
Inherited from
drawing:dblclick
drawing:dblclick:
object
Defined in: packages/core/src/drawing/manager.ts:129
id
id:
string
Inherited from
DrawingEvents.drawing:dblclick
drawing:remove
drawing:remove:
object
Defined in: packages/core/src/drawing/manager.ts:126
A drawing was removed, by the user, remove(), clear(), undo, redo or removing its pane.
id
id:
string
Inherited from
drawing:select
drawing:select:
object
Defined in: packages/core/src/drawing/manager.ts:103
The selection changed: ids in the order they were selected, id the last of them (the one selected returns), or null when nothing is.
id
id:
string|null
ids
ids:
string[]
Inherited from
drawing:update
drawing:update:
object
Defined in: packages/core/src/drawing/manager.ts:118
A drawing changed; changes lists every kind of change, change is the first.
change
change:
DrawingChange
changes
changes:
DrawingChange[]
drawing
drawing:
Drawing
Inherited from
drawing:update-progress
drawing:update-progress:
object
Defined in: packages/core/src/drawing/manager.ts:124
A drawing changed on screen but the change is not committed yet: the user is dragging it, an anchor or a handle, or preview() was called. Fires on every step; the drawing:update at the end commits.
id
id:
string
Inherited from
DrawingEvents.drawing:update-progress
drawings:change
drawings:change:
object
Defined in: packages/core/src/drawing/manager.ts:110
Any create/update/remove — persist on this.
drawings
drawings:
Drawing[]
Inherited from
drawings:invalid
drawings:invalid:
object
Defined in: packages/core/src/drawing/manager.ts:114
load() skipped saved drawings that were malformed; the valid ones loaded.
errors
errors:
DrawingLoadError[]
Inherited from
DrawingEvents.drawings:invalid
drawings:visibility
drawings:visibility:
object
Defined in: packages/core/src/drawing/manager.ts:112
setHidden() hid or showed every drawing; hidden is the new drawings.hidden.
hidden
hidden:
boolean
Inherited from
DrawingEvents.drawings:visibility
frame:render
frame:render:
RenderStats
Defined in: packages/core/src/chart.ts:1160
A frame was drawn, with what it cost. Only fires while the renderStats or renderStatsOverlay option is on, with the statsOverlay() plugin.
frame:slow
frame:slow:
object
Defined in: packages/core/src/chart.ts:1166
Frames have kept coming slower than about 29 a second for a while (frameTime is the smoothed gap in ms), so the app may offer the lowPower option. Fires once per slow spell, and not while lowPower is on.
frameTime
frameTime:
number
grouping:change
grouping:change:
GroupingState|null
Defined in: packages/core/src/chart.ts:1068
The view started or stopped grouping bars, or changed how many per bucket; see chart.grouping.
history:change
history:change:
object
Defined in: packages/core/src/drawing/manager.ts:131
The undo/redo history changed — refresh undo/redo buttons on this.
canRedo
canRedo:
boolean
canUndo
canUndo:
boolean
Inherited from
history:request
history:request:
object
Defined in: packages/core/src/chart.ts:1070
Viewport neared the oldest bar: prepend older data to the main series.
before
before:
number
indicator:add
indicator:add:
object
Defined in: packages/core/src/indicators/manager.ts:33
indicator
indicator:
Indicator
Inherited from
indicator:change
indicator:change:
object
Defined in: packages/core/src/indicators/manager.ts:39
Inputs or visibility changed through the handle, or the indicator went live or pending because its definition was registered or unregistered.
indicator
indicator:
Indicator
Inherited from
IndicatorEvents.indicator:change
indicator:error
indicator:error:
object
Defined in: packages/core/src/indicators/manager.ts:44
compute or update threw (the plots show no values), or restored state did not fit the definition and defaults replaced the parts that didn't.
error
error:
unknown
indicator
indicator:
Indicator
Inherited from
IndicatorEvents.indicator:error
indicator:refuse
indicator:refuse:
object
Defined in: packages/core/src/indicators/manager.ts:53
add() or duplicate() refused an indicator: the access rule (access.allow) said no ('blocked'), or the chart already holds limit indicators ('limit'). The call throws after this fires; apps show an upgrade prompt or a notice here.
reason
reason:
IndicatorRefusal
type
type:
string
Inherited from
IndicatorEvents.indicator:refuse
indicator:remove
indicator:remove:
object
Defined in: packages/core/src/indicators/manager.ts:34
indicator
indicator:
Indicator
Inherited from
IndicatorEvents.indicator:remove
indicator:status
indicator:status:
object
Defined in: packages/core/src/indicators/manager.ts:46
The load state of an indicator's external data, or its message, changed (see Indicator.status).
indicator
indicator:
Indicator
message
message:
string|null
status
status:
IndicatorStatus
Inherited from
IndicatorEvents.indicator:status
indicators:access-change
indicators:access-change:
object
Defined in: packages/core/src/indicators/manager.ts:55
setAccess() or setLimit() was called: which indicators may be added changed.
allow
allow:
AccessRule|null
limit
limit:
number|null
Inherited from
IndicatorEvents.indicators:access-change
interval:change
interval:change:
object
Defined in: packages/core/src/data/types.ts:299
A load landed at another interval than the one shown before (previous is null on the first load), or at another one than requested. Emitted after data:loaded.
interval
interval:
Interval
previous
previous:
Interval|null
reason
reason:
IntervalChangeReason
requested
requested:
Interval
Inherited from
localization:change
localization:change:
object
Defined in: packages/core/src/chart.ts:1051
chart.localization was replaced: by applyOptions({ localization }), or by installing or uninstalling the localization() plugin; locale is its locale option.
locale
locale:
string|undefined
magnet:change
magnet:change:
object
Defined in: packages/core/src/drawing/manager.ts:90
setMagnetMode() or setMagnet() changed the magnet; mode is the new magnetMode.
mode
mode:
MagnetMode
Inherited from
marker:click
marker:click:
MarkerPointerEvent
Defined in: packages/core/src/chart.ts:1112
A bar marker was clicked or tapped. While this has listeners, markers take presses instead of panning.
marker:hover
marker:hover:
MarkerPointerEvent
Defined in: packages/core/src/chart.ts:1108
The pointer entered a bar marker (annotations.setMarkers), or tapped it on touch.
marker:hover-end
marker:hover-end:
MarkerLeaveEvent
Defined in: packages/core/src/chart.ts:1110
The pointer left the bar marker.
order:create
order:create:
OrderCreateEvent
Defined in: packages/core/src/chart.ts:1133
A draft was committed: place this order, then show it with addTradeLine.
panes:change
panes:change:
object
Defined in: packages/core/src/chart.ts:1075
Panes were added, removed, reordered, resized, maximized, collapsed or hidden. heights are normalized stretch weights (see getPaneHeights).
collapsed
collapsed:
boolean[]
heights
heights:
number[]
hidden
hidden:
boolean[]
maximized
maximized:
number
plot:click
plot:click:
ChartPointerEvent
Defined in: packages/core/src/chart.ts:1079
Press and release in a plot without dragging, unless a drawing took the press.
plot:dblclick
plot:dblclick:
ChartPointerEvent
Defined in: packages/core/src/chart.ts:1088
Double-click in a plot, unless a drawing handled it (e.g. text editing).
plus:click
plus:click:
PlusButtonEvent
Defined in: packages/core/src/chart.ts:1180
The "+" button by the crosshair price label was pressed. The button only shows while this has a listener (and features.plusButton is on).
replay:change
replay:change:
ReplayState
Defined in: packages/core/src/chart.ts:1184
A bar replay started, stepped, played, paused, changed speed or stopped; see chart.replay.
scale:change
scale:change:
PriceScaleState
Defined in: packages/core/src/chart.ts:1031
A price scale's mode, inversion or autoscale flag changed.
selection:change
selection:change:
object
Defined in: packages/core/src/chart.ts:1100
What is selected changed: drawings, an indicator or nothing (see getSelection).
selection
selection:
ChartSelection
series:add
series:add:
object
Defined in: packages/core/src/chart.ts:1056
A series joined the chart: any add* call, a compared symbol, or an indicator's series (with its indicator).
indicator
indicator:
Indicator<Record<string,InputValue>> |null
series
series:
Series
series:error
series:error:
SeriesErrorEvent
Defined in: packages/core/src/chart.ts:1077
A custom series hook threw. The series is skipped for that frame; reported once until the hook succeeds again.
series:hover
series:hover:
SeriesHoverEvent
Defined in: packages/core/src/chart.ts:1098
The pointer moved onto a different series (or off all of them).
series:options
series:options:
object
Defined in: packages/core/src/chart.ts:1058
series.applyOptions changed a series; patch is what was passed.
patch
patch:
object
series
series:
Series
series:remove
series:remove:
object
Defined in: packages/core/src/chart.ts:1182
A series left the chart: removeSeries, its indicator or pane removed, or a legend remove button.
indicator
indicator:
Indicator<Record<string,InputValue>> |null
series
series:
Series
series:settings
series:settings:
object
Defined in: packages/core/src/chart.ts:1175
A legend row's settings button was pressed; open your settings UI. The button only shows while something listens for this event.
indicator
indicator:
Indicator<Record<string,InputValue>> |null
series
series:
Series
series:visibility
series:visibility:
object
Defined in: packages/core/src/chart.ts:1170
A series was shown or hidden: setVisible with a new value, or a legend row's eye button.
series
series:
Series
visible
visible:
boolean
sourcemarkers:change
sourcemarkers:change:
object
Defined in: packages/core/src/data/types.ts:342
chart.sourceMarkers changed: a batch landed, markers far from the view were let go, or they were dropped (a new load, another source, both options turned off). markers is the new, frozen list.
markers
markers: readonly
SourceMarker[]
Inherited from
DataEvents.sourcemarkers:change
sourcemarkers:click
sourcemarkers:click:
object
Defined in: packages/core/src/chart.ts:1121
A data source marker (DataSource.markers) was clicked or tapped, on its bar or on the time axis: copies of the marker, or of the markers folded into it or its badge, and the pointer in chart-root css px. In the sourcemarkers:* family with the getter's other events. While this has listeners, markers take presses instead of panning and badges instead of the axis drag.
markers
markers:
SourceMarker[]
point
point:
Point
sourcemarkers:error
sourcemarkers:error:
object
Defined in: packages/core/src/data/types.ts:336
markers failed: error.code is 'markers-failed', with the source's error as cause. The chart asks again after retryIn ms (1, 2, 4, 8, then 16 seconds); after five failures in a row retryIn is null and it asks again only after a reset of the shown bars, turning the marks or timeMarks option back on, or the next symbol or interval.
error
error:
ChartError
interval
interval:
Interval
retryIn
retryIn:
number|null
symbol
symbol:
string
Inherited from
DataEvents.sourcemarkers:error
sourcemarkers:loaded
sourcemarkers:loaded:
object
Defined in: packages/core/src/data/types.ts:328
The data source's markers answered for from (inclusive) to to (exclusive). markers are the valid ones it sent within that range (frozen), dropped counts the invalid ones left out.
dropped
dropped:
number
from
from:
number
interval
interval:
Interval
markers
markers: readonly
SourceMarker[]
symbol
symbol:
SymbolInfo
to
to:
number
Inherited from
DataEvents.sourcemarkers:loaded
state:change
state:change:
object
Defined in: packages/core/src/chart.ts:1028
Something worth saving changed: drawings, indicators, the main series style, panes or price scales, the symbol or interval (once loaded), the theme or grid, or the visible range. Loading never fires it: loadLayout (until its ready settles), drawings.load and indicators.load are quiet. Edits made while a layout's symbol loads are reported once it has. Fires once per change; debounce before saving, or use autosave.
reason
reason:
StateChangeReason
status:change
status:change:
StatusChangeEvent
Defined in: packages/core/src/chart.ts:1139
setStatus set or cleared the in-pane status (the data source sets it while loading, for no data and for errors). A listener that calls preventDefault() hides the chart's own text for that status.
symbol:change
symbol:change:
object
Defined in: packages/core/src/chart.ts:1047
setSymbol (or a layout load) switched to another symbol. Fires once per accepted switch, before its load starts; data:* events follow the load. previous is null on the first symbol.
previous
previous:
string|null
symbol
symbol:
string
theme:change
theme:change:
object
Defined in: packages/core/src/chart.ts:1064
applyOptions({ theme }) changed the resolved theme.
theme
theme:
ChartTheme
timezone:change
timezone:change:
object
Defined in: packages/core/src/chart.ts:1049
The time axis timezone changed: the timezone option, or the symbol's own with applySymbolTimezone.
previous
previous:
string
timezone
timezone:
string
tool:change
tool:change:
object
Defined in: packages/core/src/drawing/manager.ts:88
The active tool changed (null = cursor); kept is toolKept.
kept
kept:
boolean
tool
tool:
string|null
Inherited from
tool:defaults-change
tool:defaults-change:
object
Defined in: packages/core/src/drawing/manager.ts:137
The style new drawings of tool start with changed, through setToolDefaults, loadToolDefaults or a remembered style edit. defaults is the new toolDefaults(tool).
defaults
defaults:
DrawingStyle
tool
tool:
string
Inherited from
DrawingEvents.tool:defaults-change
tool:refuse
tool:refuse:
object
Defined in: packages/core/src/drawing/manager.ts:98
setTool() refused a tool setAccess() denies, e.g. a press on a disabled rail button. The call throws after this fires; apps show an upgrade prompt or a notice here.
tool
tool:
string
Inherited from
trade:click
trade:click:
TradePointerEvent
Defined in: packages/core/src/chart.ts:1106
A fill marker was clicked or tapped. While this has listeners, markers take presses instead of panning.
trade:hover
trade:hover:
TradePointerEvent
Defined in: packages/core/src/chart.ts:1102
The pointer entered a fill marker (annotations.setTrades), or tapped it on touch.
trade:hover-end
trade:hover-end:
Record<string,never>
Defined in: packages/core/src/chart.ts:1104
The pointer left the fill marker.
ui:notify
ui:notify:
NotifyEvent
Defined in: packages/core/src/chart.ts:1141
chart.notify was called. The UI package shows a toast unless defaultPrevented.
view:change
view:change:
object
Defined in: packages/core/src/chart.ts:1041
Something that moves chart coordinates changed: pan, zoom, resize, pane layout, a price scale's range or mode, or the bars. Fires at most once per frame, after it is drawn; re-place HTML positioned with coordinateFor and friends. fromIndex/toIndex are the fractional logical indices at the plot edges; rightOffset is the space after the last bar, in bars; from/to the times of the first and last visible bar, as getVisibleRange gives them (null without bars).
barSpacing
barSpacing:
number
from
from:
number|null
fromIndex
fromIndex:
number
rightOffset
rightOffset:
number
to
to:
number|null
toIndex
toIndex:
number
viewport:clamp
viewport:clamp:
ViewportClampEvent
Defined in: packages/core/src/chart.ts:1066
setVisibleTimeRange, fitContent, scrollToRealtime or resetView asked for more than the viewport bounds allow.