[Drawings]

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

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

Tools

Tool idKindGeometry
cursorSelect / pan mode (not a drawable)
hlinehlineHorizontal price
trendtrendTwo points
rayrayTwo points (extends)
rectrectTwo corners
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.

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.

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/pine-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