Drawings
Anchors, handles, lifecycle, and serialization — the model behind every drawing tool.
A drawing is a user-placed annotation pinned to the chart's
data-space — anchored by (time, price) pairs, not by pixel
coordinates. This is what makes drawings track their underlying bars
when you pan, zoom, or change resolution.
Quick example
How it works
Every drawing has three layers:
- Anchors — one to N
(time, price)tuples. A trend line has two; a Fibonacci retracement has two; a rectangle has two; a polyline has many. Anchors live in data-space. - Handles — visual grab points rendered at each anchor. Click one and drag to repoint the anchor. Drawings render handles only while selected.
- Style — color, line width, dash pattern, fill, font size.
Stored on the drawing itself; modifiable via the
floating drawing toolbar
or
patchDrawing(id, style).
The full catalog (40+ tools) is at concepts/drawings-catalog.
Lifecycle
A drawing fires three events through useChartStore:
drawing:createwhen committeddrawing:updateon every patch / dragdrawing:deleteon removal
Serialization
Drawings serialize to plain JSON. The schema is the same array that's persisted to localStorage and round-trips through cloud sync in Phase 2.
See persistence for the storage contract.
Variations
Add a trend line programmatically
Lock every existing drawing
API
| Action | Method |
|---|---|
| Add | useChartStore.addDrawing(drawing) |
| Patch | useChartStore.patchDrawing(id, patch) |
| Remove | useChartStore.removeDrawing(id) |
| Read | useChartStore.drawings |