Drawings

Interactive chart annotations in AXIS—tools, persistence, and how they differ from Pine script drawings.

This page

Drawings

AXIS supports user drawings (interactive tools on the chart) and script drawings (objects returned by the engine). They share a canvas layer but different lifecycles.

Abstract

ClassOriginCleared whenPersisted
User drawingsDrawing toolbarExplicit delete / clearYes (store.drawings in pynescript.axis.v1)
Script drawingsEngine drawings[]Next Run (re-applied)No (recomputed)

Conceptual model

Diagram

Rendering…

Fibonacci retracement drawn on BTCUSDT with the drawing toolbar Placing a trend line on the AXIS chart

Tools

Left drawing tool rail: cursor, trend, shapes, fib, measure
Tool idKindGeometry
cursorSelect / pan mode (not a drawable)
hlinehlineHorizontal price
vlinevlineVertical time
trendtrendTwo points
rayrayTwo points (extends)
extendextendExtended line
rectrectTwo corners
ellipseellipseEllipse / oval
arrowarrowDirectional segment
fibfibTwo points; levels 0, 0.236, 0.382, 0.5, 0.618, 0.786, 1
measuremeasureTwo points (delta readout)
texttextAnchor + label

Colors: default accent #939fff, up/down/measure variants in DRAWING_COLORS.

Style bar and per-tool settings

The floating style bar (next to the rail) edits the selected drawing, or the defaults for the active tool when nothing is selected. Last-used extras are stored per tool (drawingPrefs.byKind).

ControlWhereTools
Color / width / dashStyle barAll place tools
Custom colorStyle bar native pickerAll place tools
FillStyle bar sliderShapes, ranges, fib, highlighter, positions
Extend L / RStyle bar arrowsTrend, ray, extend, info line, channel, fib
Show priceStyle bar $Horizontal/vertical lines, fib labels
LockStyle bar (selection)Selected drawing
Text / font sizeSettings popover (gear); double-click on chartText, note, callout, flag, price label
Fib levels / reverse / %Settings popoverFibonacci family
Risk/rewardSettings popoverLong / short
Arrow capsSettings popoverTrend, ray, arrow, forecast

Gear button: axis-drawing-settings. Popover: axis-drawing-settings-popover.

Layers & templates

  • Layers panel lists user drawings (select, hide, delete)
  • Templates: save/load drawing packs (axis.drawingTemplates.v1)
  • Duplicate / tag symbol helpers for multi-chart workflows

Interface surface

  • Toolbar on chart host (DrawingToolbar)
  • Active tool in store; layer sync via createEffect on store.drawingTool
  • Pane manager hosts price chart; drawings bind to time/price coordinates (not pixel-only)

Workflows

Annotate a level

  1. Select Horizontal line.
  2. Click price.
  3. Reload page—line remains (persisted drawings array).

Fibonacci between swing points

  1. Select Fib.
  2. Click swing low → swing high (or reverse).
  3. Levels render from FIB_LEVELS.

After Run with Pine lines/labels

  1. Run script that emits drawings.
  2. Layer clears previous script drawings, then applies new set.
  3. User drawings remain.

Script drawings (engine → chart)

Engine drawings[] map through pyne-drawings.ts before paint:

Engine surfaceChart behavior
line / box / label / polylineSVG geometry on the script’s pane scale
linefill / line_fillFilled quad between two line endpoints
force_overlay (line/box/label)Paint on the price pane even when the script is overlay=false
barcolor seriesNot SVG — per-bar candle body/wick tint via plot-visuals

Non-overlay scripts place ordinary geometry on the indicator pane Y-scale; user toolbar drawings always stay on price.

Internals

PathRole
frontend/src/chart/drawing-types.tsTool ids, types, fib levels
frontend/src/chart/drawing-layer.tsInteraction + render
frontend/src/chart/DrawingToolbar.tsxUI
frontend/src/chart/pyne-drawings.tsMap engine drawings → layer
frontend/src/chart/ChartHost.tsxMount / dispose

Invariants

  1. User drawings ≠ strategy results; deleting drawings does not alter lastRun.
  2. Time base is bar time (unix-compatible chart times).
  3. cursor never creates geometry.
  4. Persistence omits bars/logs but includes drawings—large freehand-less sets only.

Failure modes

SymptomFix
Clicks do nothingTool is cursor; chart empty (no bars/time scale)
Drawings vanish on RunThose were script drawings—re-run or convert notes to user tools
Lost after wipeCleared site data / different browser profile

See also