Skip to content

charton API


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

Class: DrawingManager ​

Defined in: packages/core/src/drawing/manager.ts:287

Drawing registry, state and pointer handling. Coordinates are plot-space css px.

Constructors ​

Constructor ​

new DrawingManager(host): DrawingManager

Defined in: packages/core/src/drawing/manager.ts:413

Starts without tools; the drawingTools() plugin or register adds them.

Parameters ​

host ​

DrawingHost

Returns ​

DrawingManager

Properties ​

axisLabels ​

axisLabels: boolean = true

Defined in: packages/core/src/drawing/manager.ts:347

Label the selected drawing's prices and times on the axes; see setAxisLabels.


hidden ​

hidden: boolean = false

Defined in: packages/core/src/drawing/manager.ts:345


loading ​

loading: boolean = false

Defined in: packages/core/src/drawing/manager.ts:304

Internal

True while load replaces the drawings, so the chart does not report it as a state:change.


locked ​

locked: boolean = false

Defined in: packages/core/src/drawing/manager.ts:344

Prevent moving/editing drawings.


migrate ​

migrate: DrawingMigration | null = null

Defined in: packages/core/src/drawing/manager.ts:383

Upgrades saved payloads load() cannot read as they are: an unknown version, or an app's own older format. Called at most once per load.


pasteScaling ​

pasteScaling: PasteScaling | null = null

Defined in: packages/core/src/drawing/manager.ts:365

How drawings pasted from another chart through the system clipboard are placed; see PasteScaling. Default null: at their own times and prices.


quickMeasure ​

quickMeasure: boolean = false

Defined in: packages/core/src/drawing/manager.ts:358

Shift+click on empty plot space, with no tool active, starts a temporary date and price measurement that follows the pointer; the next click fixes it, and the click after that, Escape or clearMeasure() removes it. Shift+drag still draws a selection box. The measurement is no drawing: it is not saved, copied or undoable and fires no drawings:change. It looks like the date-price-range tool and needs it registered. Default false.


rememberStyle ​

rememberStyle: boolean = true

Defined in: packages/core/src/drawing/manager.ts:374

A style edit committed with update() becomes the default of the drawing's tool for the fields it changed, so the next drawing of that tool looks the same. Default true; turn off when the app restyles drawings from code and the defaults should stay put.


stayInDrawingMode ​

stayInDrawingMode: boolean = false

Defined in: packages/core/src/drawing/manager.ts:349

Keep the tool active after finishing a drawing.

Accessors ​

access ​

Get Signature ​

get access(): AccessRule | null

Defined in: packages/core/src/drawing/manager.ts:608

The rule setAccess() set, or null when every tool is allowed.

Returns ​

AccessRule | null


below ​

Get Signature ​

get below(): boolean

Defined in: packages/core/src/drawing/manager.ts:2056

Internal

Whether a drawing redraw must repaint the scene: some drawing is below.

Returns ​

boolean


canRedo ​

Get Signature ​

get canRedo(): boolean

Defined in: packages/core/src/drawing/manager.ts:1069

Same as chart.history.canRedo.

Returns ​

boolean


canUndo ​

Get Signature ​

get canUndo(): boolean

Defined in: packages/core/src/drawing/manager.ts:1064

Same as chart.history.canUndo: drawings share the chart's undo history.

Returns ​

boolean


groups ​

Get Signature ​

get groups(): DrawingGroup[]

Defined in: packages/core/src/drawing/manager.ts:854

The named groups, ordered by their lowest drawing. A group is the drawings that share a group; a click on one of them selects them all.

Returns ​

DrawingGroup[]


isBusy ​

Get Signature ​

get isBusy(): boolean

Defined in: packages/core/src/drawing/manager.ts:1554

Returns ​

boolean


isHovering ​

Get Signature ​

get isHovering(): boolean

Defined in: packages/core/src/drawing/manager.ts:1550

Whether the pointer is over a drawing (as of the last move).

Returns ​

boolean


magnet ​

Get Signature ​

get magnet(): boolean

Defined in: packages/core/src/drawing/manager.ts:1203

Whether the magnet is on, weak or strong; see magnetMode.

Returns ​

boolean

Set Signature ​

set magnet(magnet): void

Defined in: packages/core/src/drawing/manager.ts:1208

Same as setMagnet().

Parameters ​
magnet ​

boolean

Returns ​

void


magnetMode ​

Get Signature ​

get magnetMode(): MagnetMode

Defined in: packages/core/src/drawing/manager.ts:1213

How placed and dragged anchors snap to bar values; see setMagnetMode.

Returns ​

MagnetMode


selected ​

Get Signature ​

get selected(): Drawing | null

Defined in: packages/core/src/drawing/manager.ts:617

The selected drawing, or with several selected the last one selected.

Returns ​

Drawing | null


selection ​

Get Signature ​

get selection(): string[]

Defined in: packages/core/src/drawing/manager.ts:622

Ids of the selected drawings, in the order they were selected; the last is selected.

Returns ​

string[]


tool ​

Get Signature ​

get tool(): string | null

Defined in: packages/core/src/drawing/manager.ts:559

Returns ​

string | null


toolKept ​

Get Signature ​

get toolKept(): boolean

Defined in: packages/core/src/drawing/manager.ts:568

The active tool stays active after each drawing because it was set with setTool(type, { keep: true }). False for the cursor, and for a tool kept only by stayInDrawingMode.

Returns ​

boolean

Methods ​

add() ​

add(input): Drawing

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

Parameters ​

input ​

Omit<Drawing, "id"> & object

Returns ​

Drawing


axisMarks() ​

axisMarks(): SelectionAxisMarks | null

Defined in: packages/core/src/drawing/manager.ts:1256

The prices and times the selected drawing, or the one being placed, labels on the axes, with its pane and color. Null when there are none, axis labels are off or drawings are hidden. The chart draws these.

Returns ​

SelectionAxisMarks | null


batch() ​

batch(fn): void

Defined in: packages/core/src/drawing/manager.ts:956

Run fn and record every change it makes as one undo step, with one drawings:change at the end, e.g. to hide or remove several drawings at once. Nested calls join the outer one. Granular events (drawing:update and the like) fire at the end too, once per changed drawing.

Parameters ​

fn ​

() => void

Returns ​

void


bringForward() ​

bringForward(id): void

Defined in: packages/core/src/drawing/manager.ts:919

Move a drawing one step up, past the next drawing of its pane.

Parameters ​

id ​

string

Returns ​

void


bringToFront() ​

bringToFront(id): void

Defined in: packages/core/src/drawing/manager.ts:909

Draw a drawing above every other one.

Parameters ​

id ​

string

Returns ​

void


cancelPreview() ​

cancelPreview(): boolean

Defined in: packages/core/src/drawing/manager.ts:989

Drop the preview() edits not committed yet and show the drawings as they were, e.g. when the user cancels a settings dialog. Adds no undo step. Returns false when nothing was being previewed (or a pointer gesture is in progress, which undo cancels instead).

Returns ​

boolean


clear() ​

clear(): void

Defined in: packages/core/src/drawing/manager.ts:1018

Returns ​

void


clearMeasure() ​

clearMeasure(): boolean

Defined in: packages/core/src/drawing/manager.ts:1520

Remove the quick measurement; false when there is none. See quickMeasure.

Returns ​

boolean


clipboardItems() ​

clipboardItems(): Drawing[]

Defined in: packages/core/src/drawing/manager.ts:677

Internal

What copy() kept, priced as the data source sent the bars (like serialize()), for the system clipboard.

Returns ​

Drawing[]


clone() ​

clone(id): Drawing | null

Defined in: packages/core/src/drawing/manager.ts:998

Copy a drawing (unlocked, outside any group) and select the copy, unless it is hidden or unselectable. Returns it, or null for an unknown id.

Parameters ​

id ​

string

Returns ​

Drawing | null


copy() ​

copy(ids?): number

Defined in: packages/core/src/drawing/manager.ts:643

Keep copies of these drawings (default: the selection) for paste(), replacing what was copied before; later edits do not change them. Returns how many were copied; with none, what was copied before stays.

Parameters ​

ids? ​

readonly string[] = ...

Returns ​

number


cursor() ​

cursor(p): string | null

Defined in: packages/core/src/drawing/manager.ts:1527

Parameters ​

p ​

Point

Returns ​

string | null


deleteSelection() ​

deleteSelection(): boolean

Defined in: packages/core/src/drawing/manager.ts:1513

Remove the selected drawings, as one undo step. False when none are selected or drawings are locked.

Returns ​

boolean


doubleClick() ​

doubleClick(p): boolean

Defined in: packages/core/src/drawing/manager.ts:1467

Parameters ​

p ​

Point

Returns ​

boolean


drawingAt() ​

drawingAt(p): string | null

Defined in: packages/core/src/drawing/manager.ts:1545

Id of the drawing under plot-space p, or null (also while drawings are hidden).

Parameters ​

p ​

Point

Returns ​

string | null


duplicate() ​

duplicate(ids?): Drawing[]

Defined in: packages/core/src/drawing/manager.ts:668

Copy these drawings (default: the selection) in place, like copy() then paste() but leaving what copy() kept alone: unlocked copies on top, selected, the copies of a group in a new group, as one undo step. Returns the copies.

Parameters ​

ids? ​

readonly string[] = ...

Returns ​

Drawing[]


fitRange() ​

fitRange(pane, from, to, positiveOnly, scale?): [number, number] | null

Defined in: packages/core/src/drawing/manager.ts:2067

Internal

Price span the autoscale drawings of pane pane keep in view over the bars from time from to to, or null; with scale, only those drawn on that price scale (see Drawing.indicator). During a gesture the last span stays, so a drawing dragged near the edge does not move the scale under the pointer. positiveOnly skips prices a log scale cannot show.

Parameters ​

pane ​

number

from ​

number

to ​

number

positiveOnly ​

boolean

scale? ​

PriceScale

Returns ​

[number, number] | null


getAll() ​

getAll(): Drawing[]

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

Every drawing, bottom to top.

Returns ​

Drawing[]


getById() ​

getById(id): Drawing | undefined

Defined in: packages/core/src/drawing/manager.ts:778

Parameters ​

id ​

string

Returns ​

Drawing | undefined


getTools() ​

getTools(): DrawingToolDef[]

Defined in: packages/core/src/drawing/manager.ts:446

Returns ​

DrawingToolDef[]


group() ​

group(ids?, name?): string | null

Defined in: packages/core/src/drawing/manager.ts:871

Put these drawings (default: the selection) into one group named name, by default a new name such as 'Group 3', taking them out of the groups they were in. One undo step. Returns the name, or null when no id is known. Throws for an empty name.

Parameters ​

ids? ​

readonly string[] = ...

name? ​

string

Returns ​

string | null


hiddenByInterval() ​

hiddenByInterval(id): boolean

Defined in: packages/core/src/drawing/manager.ts:831

True while the drawing's visibleOn excludes the chart's current interval, so it is not drawn.

Parameters ​

id ​

string

Returns ​

boolean


hitRuns() ​

hitRuns(step): number[]

Defined in: packages/core/src/drawing/manager.ts:2496

Internal

Where the pointer would grab each drawing, sampled at the centre of every step css px cell of its pane: runs of hit cells as flat [x, y, width] triples in plot space, each step px tall. Every drawing the pointer can hit is sampled on its own, so overlaps repeat. For the renderStatsOverlay bounds; costs a hit test per cell per visible drawing.

Parameters ​

step ​

number

Returns ​

number[]


intervalChanged() ​

intervalChanged(): void

Defined in: packages/core/src/drawing/manager.ts:842

Internal

The bar interval or the indicators may have changed: drawings limited to some intervals, or tied to an indicator, show or hide, and tied drawings follow their indicator's pane.

Returns ​

void


isToolAllowed() ​

isToolAllowed(type): boolean

Defined in: packages/core/src/drawing/manager.ts:612

Parameters ​

type ​

string

Returns ​

boolean


keyDown() ​

keyDown(e): boolean

Defined in: packages/core/src/drawing/manager.ts:1482

Gesture keys (Enter, Escape) and the arrow-key nudge; returns true when the key was handled.

Parameters ​

e ​

KeyboardEvent

Returns ​

boolean


leaveHistory() ​

leaveHistory(): void

Defined in: packages/core/src/drawing/manager.ts:1087

Internal

The drawings leave the chart: take their steps out of the shared history.

Returns ​

void


load() ​

load(data): DrawingLoadResult

Defined in: packages/core/src/drawing/manager.ts:1046

Replace all drawings and start a fresh undo history. Malformed drawings are skipped and reported (also through drawings:invalid); the rest load. Ill-typed optional fields and style are dropped from the drawings that load, and reported with their field. Throws, changing nothing, when data is not a drawings payload at all or has a version neither the built-in steps nor migrate can upgrade. Emits drawings:change.

Parameters ​

data ​

unknown

Returns ​

DrawingLoadResult


loadToolDefaults() ​

loadToolDefaults(data): ToolDefaultsLoadError[]

Defined in: packages/core/src/drawing/manager.ts:501

Replace every tool's defaults with saved ones, from serializeToolDefaults(). Tolerant like load(): ill-typed style fields and entries that are not objects are dropped and returned; the rest load. Throws, changing nothing, when data is not an object. Emits tool:defaults-change for each tool whose defaults changed.

Parameters ​

data ​

unknown

Returns ​

ToolDefaultsLoadError[]


moveTo() ​

moveTo(id, index): void

Defined in: packages/core/src/drawing/manager.ts:941

Move a drawing to position index among the drawings of its pane, bottom (0) to top; out-of-range indices clamp. One undo step, like the other reorders, and the drawing takes the layer of the drawing it passes.

Parameters ​

id ​

string

index ​

number

Returns ​

void


paste() ​

paste(): Drawing[]

Defined in: packages/core/src/drawing/manager.ts:658

Add unlocked copies of the drawings copy() kept, in place and on top, and select them, as one undo step. The copies of a group form a new group. Copies for a pane the chart no longer has are left out. Returns the copies; [] when nothing was copied.

Returns ​

Drawing[]


pasteImage() ​

pasteImage(type, text, width, height, at): Drawing | null

Defined in: packages/core/src/drawing/manager.ts:720

Internal

Paste an image as a selected drawing of type over a box of width by height css px, shrunk to fit half the pane, centred on plot point at or the middle of the main pane. Null without the tool.

Parameters ​

type ​

string

text ​

string

width ​

number

height ​

number

at ​

Point & object | null

Returns ​

Drawing | null


pasteItems() ​

pasteItems(items, place?, at?): Drawing[]

Defined in: packages/core/src/drawing/manager.ts:687

Internal

Paste drawings from the system clipboard, priced as the data source sent the bars, like paste(): unlocked copies on top, selected, as one undo step. Drawings of tools this chart lacks are left out. place moves the points of those anchored to data, given the crosshair at.

Parameters ​

items ​

readonly Drawing[]

place? ​

((list, at) => void) | null

at? ​

Point & object | null

Returns ​

Drawing[]


pasteText() ​

pasteText(text, at): Drawing | null

Defined in: packages/core/src/drawing/manager.ts:711

Internal

Paste plain text as a selected text drawing at plot point at, or in the middle of the main pane. Null without a text tool.

Parameters ​

text ​

string

at ​

Point & object | null

Returns ​

Drawing | null


pointerDown() ​

pointerDown(paneIndex, p, modifiers?): boolean

Defined in: packages/core/src/drawing/manager.ts:1289

Returns true when the drawing layer consumed the press (no panning). With shift, a press on a drawing adds it to the selection or takes it out, and a press elsewhere on a pane with drawings starts a selection box.

Parameters ​

paneIndex ​

number

p ​

Point

modifiers? ​

DrawingModifiers = {}

Returns ​

boolean


pointerMove() ​

pointerMove(p, modifiers?): boolean

Defined in: packages/core/src/drawing/manager.ts:1368

Returns true when the drawing layer is handling the gesture. With shift held, the drag keeps horizontal, vertical or at 45°.

Parameters ​

p ​

Point

modifiers? ​

DrawingModifiers = {}

Returns ​

boolean


pointerUp() ​

pointerUp(p, cancelled?, modifiers?): void

Defined in: packages/core/src/drawing/manager.ts:1418

cancelled is a press the browser took over (pointercancel): it is no click.

Parameters ​

p ​

Point

cancelled? ​

boolean = false

modifiers? ​

DrawingModifiers = {}

Returns ​

void


preview() ​

preview(id, patch): void

Defined in: packages/core/src/drawing/manager.ts:976

Show patch on screen without recording it: no undo step and no drawings:change. Use it for live feedback while the user is still choosing (e.g. dragging across a color picker), then call update() with the final value; that records one undo step from the state before the first preview. undo()/redo() before then discard the preview.

Parameters ​

id ​

string

patch ​

DrawingPatch

Returns ​

void


pricedFrom() ​

pricedFrom(drawing, source): Drawing

Defined in: packages/core/src/drawing/manager.ts:1181

drawing of chart drawings source with its prices moved onto the same bars here, where the prices shown may be adjusted differently (see DrawingHost.priceFactor); drawing itself when they are alike.

Parameters ​

drawing ​

Drawing

source ​

DrawingManager

Returns ​

Drawing


priceRanges() ​

priceRanges(): PriceWindow[]

Defined in: packages/core/src/drawing/manager.ts:703

Internal

The prices the main scale of each pane shows, for the system clipboard.

Returns ​

PriceWindow[]


priceScaleOf() ​

priceScaleOf(id): PriceScale | null

Defined in: packages/core/src/drawing/manager.ts:784

Internal

The price scale drawing id reads prices on (see Drawing.indicator), or null when there is no such drawing.

Parameters ​

id ​

string

Returns ​

PriceScale | null


quickFields() ​

quickFields(id): string[]

Defined in: packages/core/src/drawing/manager.ts:553

Up to four style fields the floating toolbar offers for a drawing: the ones registered for its tool with registerToolQuickFields, else the first four plain-valued ones of its tool's styleFields, else the fields its style carries and its tool's settings declare, colours first, topped up with color, line width and line style. [] for an unknown id.

Parameters ​

id ​

string

Returns ​

string[]


redo() ​

redo(): boolean

Defined in: packages/core/src/drawing/manager.ts:1082

Same as chart.history.redo(): reapply the last undone change; during a gesture or preview, only cancel it.

Returns ​

boolean


register() ​

register(tool): void

Defined in: packages/core/src/drawing/manager.ts:420

Parameters ​

tool ​

DrawingToolDef

Returns ​

void


registerToolQuickFields() ​

registerToolQuickFields(type, keys): void

Defined in: packages/core/src/drawing/manager.ts:524

Style fields the floating toolbar shows for tool type, in order (at most four are shown), instead of the ones quickFields derives. null goes back to deriving them.

Parameters ​

type ​

string

keys ​

readonly string[] | null

Returns ​

void


remapPanes() ​

remapPanes(map): void

Defined in: packages/core/src/drawing/manager.ts:1105

Follow a pane reorder or removal: map[oldIndex] is the new index, or -1 when the pane is gone (its drawings are dropped). Applies to the undo history too, and adds no undo step.

Parameters ​

map ​

readonly number[]

Returns ​

void


remove() ​

remove(id): void

Defined in: packages/core/src/drawing/manager.ts:1010

Parameters ​

id ​

string

Returns ​

void


renameGroup() ​

renameGroup(name, to): boolean

Defined in: packages/core/src/drawing/manager.ts:900

Rename group name to to; with a group of that name already there, the two become one. One undo step. False when no drawing is in name or the name is the same; throws for an empty to.

Parameters ​

name ​

string

to ​

string

Returns ​

boolean


render() ​

render(ctx, paneIndex, width, height, below?): void

Defined in: packages/core/src/drawing/manager.ts:1565

Draw drawings of one pane; ctx is translated to the pane's top-left. With below, only the below drawings' bodies, under the series; without, the other drawings and every selected drawing's handles.

Parameters ​

ctx ​

CanvasRenderingContext2D

paneIndex ​

number

width ​

number

height ​

number

below? ​

boolean = false

Returns ​

void


reprice() ​

reprice(price): void

Defined in: packages/core/src/drawing/manager.ts:1160

Follow a change of the prices shown, e.g. a new adjustment of the bars: each point of a data-anchored drawing gets the price price(pane, time, price) returns. Applies to the undo history and the clipboard too, adds no undo step, and drops an unfinished gesture.

Parameters ​

price ​

(pane, time, price) => number

Returns ​

void


select() ​

select(id): void

Defined in: packages/core/src/drawing/manager.ts:1812

Select one drawing by id, replacing the selection, or clear it with null. Unknown, hidden (also by visibleOn) and unselectable drawings are ignored.

Parameters ​

id ​

string | null

Returns ​

void


sendBackward() ​

sendBackward(id): void

Defined in: packages/core/src/drawing/manager.ts:928

Move a drawing one step down, below the previous drawing of its pane.

Parameters ​

id ​

string

Returns ​

void


sendToBack() ​

sendToBack(id): void

Defined in: packages/core/src/drawing/manager.ts:914

Draw a drawing below every other one.

Parameters ​

id ​

string

Returns ​

void


serialize() ​

serialize(): SerializedDrawings

Defined in: packages/core/src/drawing/manager.ts:1029

Drawings to save; those with persist: false are left out. Prices are taken back to the bars as the data source sent them (see the chart's adjustment option), so they load onto the same bars under any mode.

Returns ​

SerializedDrawings


serializeToolDefaults() ​

serializeToolDefaults(): Record<string, DrawingStyle>

Defined in: packages/core/src/drawing/manager.ts:488

The defaults set or remembered per tool, for saving; tools at their own defaultStyle are left out.

Returns ​

Record<string, DrawingStyle>


setAccess() ​

setAccess(allow): void

Defined in: packages/core/src/drawing/manager.ts:600

Limit the tools the user can pick: the rail hides the others and setTool refuses them. allow is the same rule as the chart's access.allow option, asked with { kind: 'drawing', id } per tool; null allows every tool. Drawings added from code with add() are not restricted. The option sets this too.

Parameters ​

allow ​

AccessRule | null

Returns ​

void


setAxisLabels() ​

setAxisLabels(show): void

Defined in: packages/core/src/drawing/manager.ts:1246

Label the selected drawing's prices and times on the axes and highlight the range between them (default on); see DrawingToolDef.axisMarks.

Parameters ​

show ​

boolean

Returns ​

void


setHidden() ​

setHidden(hidden): void

Defined in: packages/core/src/drawing/manager.ts:1189

Parameters ​

hidden ​

boolean

Returns ​

void


setLocked() ​

setLocked(locked): void

Defined in: packages/core/src/drawing/manager.ts:1197

Parameters ​

locked ​

boolean

Returns ​

void


setMagnet() ​

setMagnet(magnet): void

Defined in: packages/core/src/drawing/manager.ts:1221

Turn the magnet off, or on in the mode it last had (strong at first). Emits magnet:change when the mode changes.

Parameters ​

magnet ​

boolean

Returns ​

void


setMagnetMode() ​

setMagnetMode(mode): void

Defined in: packages/core/src/drawing/manager.ts:1232

Snap placed and dragged anchor prices in the main pane to the bar's open, high, low or close: 'strong' always, 'weak' only within a few pixels of one, 'off' never. Holding Ctrl (Cmd on macOS) snaps as 'strong' whatever the mode. Tools with their own snap keep it. Emits magnet:change when the mode changes.

Parameters ​

mode ​

MagnetMode

Returns ​

void


setSelection() ​

setSelection(ids): void

Defined in: packages/core/src/drawing/manager.ts:631

Select these drawings, replacing the selection; [] clears it. Unknown, hidden and unselectable drawings and repeated ids are left out. The last one becomes selected. Emits drawing:select when the selection changed.

Parameters ​

ids ​

readonly string[]

Returns ​

void


setTool() ​

setTool(type, options?): void

Defined in: packages/core/src/drawing/manager.ts:578

Activate drawing tool type, or the cursor with null. The tool goes back to the cursor after one drawing, unless keep is set (or stayInDrawingMode). Throws for an unknown tool, and for one setAccess() denies after firing tool:refuse.

Parameters ​

type ​

string | null

options? ​

SetToolOptions = {}

Returns ​

void


setToolDefaults() ​

setToolDefaults(type, style): void

Defined in: packages/core/src/drawing/manager.ts:480

Set the style new drawings of tool type start with, over the tool's own defaultStyle; it replaces the defaults set or remembered before, and null goes back to the tool's own. Drawings already made keep their style; add() style still wins. The tool need not be registered yet. Throws on an ill-typed style field. Emits tool:defaults-change.

Parameters ​

type ​

string

style ​

DrawingStyle | null

Returns ​

void


setVisible() ​

setVisible(id, visible): void

Defined in: packages/core/src/drawing/manager.ts:816

Show or hide one drawing.

Parameters ​

id ​

string

visible ​

boolean

Returns ​

void


setVisibleOn() ​

setVisibleOn(id, ranges): void

Defined in: packages/core/src/drawing/manager.ts:826

Show a drawing only on bar intervals inside ranges (null or []: every interval), e.g. [{ from: '1m', to: '15m' }]. Elsewhere it stays in the list and in saved drawings but is not drawn, hit-tested or selectable. One undo step; throws on an invalid range, like update().

Parameters ​

id ​

string

ranges ​

readonly IntervalRange[] | null

Returns ​

void


sketch() ​

sketch(paneIndex, p): boolean

Defined in: packages/core/src/drawing/manager.ts:1277

Internal

Start a sketch at p (plot space) on pane paneIndex: the stroke follows pointerMove, and pointerUp places the drawing it reads as. False while another gesture or a tool is active, or drawings are hidden.

Parameters ​

paneIndex ​

number

p ​

Point

Returns ​

boolean


styleFields() ​

styleFields(id): string[]

Defined in: packages/core/src/drawing/manager.ts:540

The style fields a drawing's tool honors, for a style editor: its tool's styleFields, or else color, line width, line style and the keys its settings declare. [] for an unknown id.

Parameters ​

id ​

string

Returns ​

string[]


toolDefaults() ​

toolDefaults(type): DrawingStyle

Defined in: packages/core/src/drawing/manager.ts:469

The style a new drawing of tool type starts with: the tool's defaultStyle under the defaults set with setToolDefaults or remembered from style edits. A copy; {} for a tool without either.

Parameters ​

type ​

string

Returns ​

DrawingStyle


toolLabel() ​

toolLabel(type): string

Defined in: packages/core/src/drawing/manager.ts:457

The name of tool type in the chart's language: the message tool.<type> (e.g. tool.trendline) when the localization option has one, else the tool's label; type itself for a tool that is not registered. A built-in tool registered with a label of the app's own keeps that label in every language; tools of the app's own types take tool.<type> too.

Parameters ​

type ​

string

Returns ​

string


undo() ​

undo(): boolean

Defined in: packages/core/src/drawing/manager.ts:1077

Same as chart.history.undo(): revert the last change, which may be an indicator's; during a gesture or preview, only cancel it. Returns false if nothing changed.

Returns ​

boolean


ungroup() ​

ungroup(ids?): number

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

Dissolve the groups of these drawings (default: the selection): every drawing of those groups leaves its group. One undo step. Returns how many drawings left a group. To take out one drawing only, update its group to ''.

Parameters ​

ids? ​

readonly string[] = ...

Returns ​

number


unregister() ​

unregister(type): void

Defined in: packages/core/src/drawing/manager.ts:439

Remove a tool, e.g. when the plugin that added it is uninstalled. Its drawings stay in the data but are not drawn until a tool of that type is registered again; while it is the active tool, the cursor tool takes over.

Parameters ​

type ​

string

Returns ​

void


update() ​

update(id, patch): void

Defined in: packages/core/src/drawing/manager.ts:804

Parameters ​

id ​

string

patch ​

DrawingPatch

Returns ​

void