Skip to content

charton API


charton API / @chart-on/core / index / AnnotationManager

Class: AnnotationManager ​

Defined in: packages/core/src/annotations/manager.ts:265

Programmatic annotations: bar markers, price lines, time bands, price zones and text labels. Order, position, alert and draft lines and trade fills come from the trading() plugin's layers. Separate from user drawings: never serialized, never on the drawing undo stack. Coordinates are chart-space css px (plot-relative x); points handed to callbacks are chart-root css px.

Constructors ​

Constructor ​

new AnnotationManager(host): AnnotationManager

Defined in: packages/core/src/annotations/manager.ts:326

Parameters ​

host ​

AnnotationHost

Returns ​

AnnotationManager

Accessors ​

alertLines ​

Get Signature ​

get alertLines(): readonly AlertLine[]

Defined in: packages/core/src/annotations/manager.ts:774

Alert lines; none without trading().

Returns ​

readonly AlertLine[]


draftLines ​

Get Signature ​

get draftLines(): readonly DraftLine[]

Defined in: packages/core/src/annotations/manager.ts:779

Order drafts; none without trading().

Returns ​

readonly DraftLine[]


isBusy ​

Get Signature ​

get isBusy(): boolean

Defined in: packages/core/src/annotations/manager.ts:926

Returns ​

boolean


isHovering ​

Get Signature ​

get isHovering(): boolean

Defined in: packages/core/src/annotations/manager.ts:922

Whether the pointer is over a line, a layer's annotation or a bar marker (as of the last move).

Returns ​

boolean


markerFilter ​

Get Signature ​

get markerFilter(): Readonly<MarkerFilter>

Defined in: packages/core/src/annotations/manager.ts:602

Returns ​

Readonly<MarkerFilter>


options ​

Get Signature ​

get options(): Readonly<AnnotationOptions>

Defined in: packages/core/src/annotations/manager.ts:380

Returns ​

Readonly<AnnotationOptions>


priceLines ​

Get Signature ​

get priceLines(): readonly PriceLine[]

Defined in: packages/core/src/annotations/manager.ts:764

Returns ​

readonly PriceLine[]


priceZones ​

Get Signature ​

get priceZones(): readonly PriceZone[]

Defined in: packages/core/src/annotations/manager.ts:756

Returns ​

readonly PriceZone[]


textLabels ​

Get Signature ​

get textLabels(): readonly TextLabel[]

Defined in: packages/core/src/annotations/manager.ts:760

Returns ​

readonly TextLabel[]


timeBands ​

Get Signature ​

get timeBands(): readonly TimeBand[]

Defined in: packages/core/src/annotations/manager.ts:752

Returns ​

readonly TimeBand[]


tradeGroups ​

Get Signature ​

get tradeGroups(): readonly TradeGroup[]

Defined in: packages/core/src/annotations/manager.ts:633

Copies of the fills grouped per bar and side, as drawn.

Returns ​

readonly TradeGroup[]


tradeLines ​

Get Signature ​

get tradeLines(): readonly TradeLine[]

Defined in: packages/core/src/annotations/manager.ts:769

Order and position lines; none without trading().

Returns ​

readonly TradeLine[]


tradeOptions ​

Get Signature ​

get tradeOptions(): Readonly<TradeMarkerOptions>

Defined in: packages/core/src/annotations/manager.ts:642

Returns ​

Readonly<TradeMarkerOptions>

Methods ​

[SET_SOURCE_MARKS]() ​

[SET_SOURCE_MARKS](markers): void

Defined in: packages/core/src/annotations/manager.ts:483

Replace the data source's marks, drawn on the main series in a set of their own: setMarkers, getMarkers and clear() leave them alone, while setMarkerFilter and marker folding apply to them as to every set. Invalid markers are skipped. Keyed by a symbol the package does not export, so only the chart calls it; apps hide them with the marks option.

Parameters ​

markers ​

readonly BarMarker[]

Returns ​

void


[SET_TIME_MARKS]() ​

[SET_TIME_MARKS](markers): void

Defined in: packages/core/src/annotations/manager.ts:499

Replace the data source's time-axis markers: the timeAxis ones of markers (sorted by time). Keyed like SET_SOURCE_MARKS.

Parameters ​

markers ​

readonly SourceMarker[]

Returns ​

void


addAlertLine() ​

addAlertLine(options): AlertLine

Defined in: packages/core/src/annotations/manager.ts:719

Add a price alert; dragging and the remove button are opt-in through its callbacks.

Parameters ​

options ​

Partial<AlertLineOptions> & Pick<AlertLineOptions, "price">

Returns ​

AlertLine


addLayer() ​

addLayer(name, create): () => void

Defined in: packages/core/src/annotations/manager.ts:682

Internal

Add a layer under name, made with what the manager gives it; one with the same name is replaced. Returns a function that removes it.

Parameters ​

name ​

string

create ​

(h) => AnnotationLayer

Returns ​

() => void


addPriceLine() ​

addPriceLine(options): PriceLine

Defined in: packages/core/src/annotations/manager.ts:706

Parameters ​

options ​

Partial<PriceLineOptions> & Pick<PriceLineOptions, "price">

Returns ​

PriceLine


addPriceZone() ​

addPriceZone(options): PriceZone

Defined in: packages/core/src/annotations/manager.ts:743

Shade the band between two prices, below the series; fromTime / toTime limit it to bars.

Parameters ​

options ​

Partial<PriceZoneOptions> & Pick<PriceZoneOptions, "from" | "to">

Returns ​

PriceZone


addTextLabel() ​

addTextLabel(options): TextLabel

Defined in: packages/core/src/annotations/manager.ts:748

Pin a text box to a time and price, above the series and drawings.

Parameters ​

options ​

Partial<TextLabelOptions> & Pick<TextLabelOptions, "time" | "text" | "price">

Returns ​

TextLabel


addTimeBand() ​

addTimeBand(options): TimeBand

Defined in: packages/core/src/annotations/manager.ts:738

Shade the full pane height from the bar of from to the bar of to (one bar when to is left out), below the series.

Parameters ​

options ​

TimeBandOptions

Returns ​

TimeBand


addTrade() ​

addTrade(trade, options?): void

Defined in: packages/core/src/annotations/manager.ts:618

Add one fill, or replace the fill with its id; only its bar is regrouped.

Parameters ​

trade ​

Trade

options? ​
source? ​

string

Returns ​

void


addTradeLine() ​

addTradeLine(options): TradeLine

Defined in: packages/core/src/annotations/manager.ts:714

Add an order (default) or position line; defaults depend on kind.

Parameters ​

options ​

Partial<TradeLineOptions> & Pick<TradeLineOptions, "price" | "side">

Returns ​

TradeLine


alertsCrossed() ​

alertsCrossed(from, to, series?): AlertCrossing[]

Defined in: packages/core/src/annotations/manager.ts:789

Alert lines of series (default: the main series) that a price moving from from to to crossed, e.g. the previous and the new last price of a live update. Hidden lines count too: visibility is display only. The chart never calls this itself; triggering alerts is up to the app.

Parameters ​

from ​

number

to ​

number

series? ​

Series<object>

Returns ​

AlertCrossing[]


applyOptions() ​

applyOptions(patch): void

Defined in: packages/core/src/annotations/manager.ts:361

Layer options: label and marker clustering. Fields left out keep their value.

Parameters ​

patch ​

Partial<Omit<AnnotationOptions, "cluster" | "markerCluster">> & object

Returns ​

void


applyTradeOptions() ​

applyTradeOptions(patch): void

Defined in: packages/core/src/annotations/manager.ts:638

Marker variant, size, count text and more for fills. Fields left out keep their value.

Parameters ​

patch ​

Partial<TradeMarkerOptions>

Returns ​

void


cancelGesture() ​

cancelGesture(): boolean

Defined in: packages/core/src/annotations/manager.ts:887

Abort the current gesture; a dragged line returns to its original price.

Returns ​

boolean


clear() ​

clear(): void

Defined in: packages/core/src/annotations/manager.ts:803

Remove all markers, lines, bands, zones and labels. Shape plots, event markers and the data source's marks stay.

Returns ​

void


clearTrades() ​

clearTrades(source?): void

Defined in: packages/core/src/annotations/manager.ts:623

Remove the fills of source, or all fills.

Parameters ​

source? ​

string

Returns ​

void


cursor() ​

cursor(p): string | null

Defined in: packages/core/src/annotations/manager.ts:905

Parameters ​

p ​

Point

Returns ​

string | null


getMarkers() ​

getMarkers(series?): BarMarker[]

Defined in: packages/core/src/annotations/manager.ts:407

Parameters ​

series? ​

Series<object>

Returns ​

BarMarker[]


getTrades() ​

getTrades(source?): Trade[]

Defined in: packages/core/src/annotations/manager.ts:628

Copies of the fills of source, or of every source.

Parameters ​

source? ​

string

Returns ​

Trade[]


keyDown() ​

keyDown(e): boolean

Defined in: packages/core/src/annotations/manager.ts:898

Escape restores the price during a drag, else discards pending changes. Returns true when handled.

Parameters ​

e ​

KeyboardEvent

Returns ​

boolean


mainChanged() ​

mainChanged(): void

Defined in: packages/core/src/annotations/manager.ts:797

Internal

Called by the chart when its main series changes: alerts without a series follow it to its pane.

Returns ​

void


pointerDown() ​

pointerDown(p, touch?): boolean

Defined in: packages/core/src/annotations/manager.ts:821

Returns true when a line or button took the press (no panning, no drawing). touch widens the travel that still counts as a click.

Parameters ​

p ​

Point

touch? ​

boolean = false

Returns ​

boolean


pointerMove() ​

pointerMove(p): void

Defined in: packages/core/src/annotations/manager.ts:838

Drag, or update hover state; null when the pointer left the plot.

Parameters ​

p ​

Point | null

Returns ​

void


pointerUp() ​

pointerUp(p): void

Defined in: packages/core/src/annotations/manager.ts:859

Parameters ​

p ​

Point

Returns ​

void


removeMarker() ​

removeMarker(id, series?): boolean

Defined in: packages/core/src/annotations/manager.ts:434

Remove the marker with id from the set of series (default: the main series). Returns false when there is none.

Parameters ​

id ​

string

series? ​

Series<object>

Returns ​

boolean


render() ​

render(ctx): void

Defined in: packages/core/src/annotations/manager.ts:935

Plot-area drawing for every pane, clipped to each pane.

Parameters ​

ctx ​

CanvasRenderingContext2D

Returns ​

void


renderLabels() ​

renderLabels(ctx): void

Defined in: packages/core/src/annotations/manager.ts:954

Price-axis labels and tooltips; drawn unclipped after the axes.

Parameters ​

ctx ​

CanvasRenderingContext2D

Returns ​

void


setEventMarkers() ​

setEventMarkers(markers): void

Defined in: packages/core/src/annotations/manager.ts:467

Internal

The chart's own event markers on the main series, oldest first; empty removes them. Laid out, filtered and folded like the app's sets, but they stay out of getMarkers, setMarkers and clear.

Parameters ​

markers ​

BarMarker[]

Returns ​

void


setMarkerFilter() ​

setMarkerFilter(filter): void

Defined in: packages/core/src/annotations/manager.ts:597

Draw only the markers of filter.kinds at filter.minSeverity or above, in every set, the data source's marks included; the sets stay as they are. null or {} draws all.

Parameters ​

filter ​

MarkerFilter | null

Returns ​

void


setMarkers() ​

setMarkers(markers, series?): void

Defined in: packages/core/src/annotations/manager.ts:390

Replace the markers of series (default: the main series). Throws, changing nothing, on an invalid marker or an id that appears twice.

Parameters ​

markers ​

readonly BarMarker[]

series? ​

Series<object>

Returns ​

void


setPlotMarkers() ​

setPlotMarkers(series, markers): void

Defined in: packages/core/src/annotations/manager.ts:453

Internal

The markers of an indicator's shape plots, oldest first; empty removes them. They are laid out, filtered and folded like the app's sets but stay out of getMarkers. markers is the caller's: it passes it again after every change.

Parameters ​

series ​

Series

markers ​

BarMarker[]

Returns ​

void


setTrades() ​

setTrades(trades, options?): void

Defined in: packages/core/src/annotations/manager.ts:613

Replace the account fills of source (default 'default'). Fills on one bar and side draw as one marker at their volume-weighted price. Sources let separate parts of an app own their fills.

Parameters ​

trades ​

readonly Trade[]

options? ​
source? ​

string

Returns ​

void


startOrderDraft() ​

startOrderDraft(options): DraftLine

Defined in: packages/core/src/annotations/manager.ts:728

Start composing an order on the chart. The draft's price, take-profit and stop-loss drag freely, clicks on its quantity and type emit draft:edit, and its place button (or commit()) emits order:create.

Parameters ​

options ​

Partial<DraftLineOptions> & Pick<DraftLineOptions, "price" | "side">

Returns ​

DraftLine


syncTrades() ​

syncTrades(sync): object

Defined in: packages/core/src/annotations/manager.ts:652

Apply fills, order lines and position lines from one snapshot in one go, e.g. after a socket reconnect, so the chart never shows half of it. Everything is checked first: an invalid entry throws and changes nothing. Returns the new order and position lines.

Parameters ​

sync ​

TradeSync

Returns ​

object

orders ​

orders: TradeLine[]

positions ​

positions: TradeLine[]


timeMarkDown() ​

timeMarkDown(p, touch?): boolean

Defined in: packages/core/src/annotations/manager.ts:514

A press on the time axis (plot space): taken over a badge while markClick has listeners.

Parameters ​

p ​

Point

touch? ​

boolean = false

Returns ​

boolean


timeMarkMove() ​

timeMarkMove(p): boolean

Defined in: packages/core/src/annotations/manager.ts:505

Hover over the time axis (plot space), null when the pointer is elsewhere. True over a badge that takes clicks.

Parameters ​

p ​

Point | null

Returns ​

boolean


updateMarker() ​

updateMarker(id, patch, series?): boolean

Defined in: packages/core/src/annotations/manager.ts:416

Change the marker with id in the set of series (default: the main series), keeping the rest. Returns false when there is no such marker. Throws, changing nothing, when the result is invalid.

Parameters ​

id ​

string

patch ​

Partial<Omit<BarMarker, "id">>

series? ​

Series<object>

Returns ​

boolean