lightweight-charts-drawing 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.1 (08/10/2026)
4
+
5
+ ### Added
6
+
7
+ - Core `vwapLast(drawing, bars)` (`src/core/kinds/data-series`): the anchored
8
+ VWAP and its deviation at the last bar of any bars of the symbol, not only
9
+ a chart's. `vwapLastValue` is unchanged.
10
+
11
+ ## 0.5.0 (08/10/2026)
12
+
13
+ ### Added
14
+
15
+ - `DrawingManager.setHidden(id, hidden)`: hide / show one drawing without
16
+ removing it (the drawing's `hidden` flag, saved with it).
17
+ - `DrawingManager.setDrawingsVisible(visible)` / `drawingsVisible()` and the
18
+ `visibility` event: hide / show every drawing at once (TradingView "Hide
19
+ all drawings"). Not saved, the drawings are untouched. Hiding disarms the
20
+ tool; arming a tool shows the drawings again.
21
+ - Demo: hide all button, hide button in the selection bar.
22
+
23
+ ### Fixed
24
+
25
+ - A drawing that stops being shown (`hidden`, per-interval visibility) leaves
26
+ the selection and the hover: Delete could remove a drawing that was not
27
+ drawn.
28
+
3
29
  ## 0.4.0 (02/10/2026)
4
30
 
5
31
  ### Added
package/README.md CHANGED
@@ -61,6 +61,8 @@ intraday of date labels), `stayInDrawingMode` (TV Keep drawing).
61
61
  | `setTool(kind \| null, { glyph? })`, `tool()` | arm / disarm a tool (`kind` from docs/TOOLS.md) |
62
62
  | `setMagnet(mode)`, `setInterval(i)`, `setStayInDrawingMode(on)` | settings |
63
63
  | `add(drawing)`, `update(drawing)`, `remove(id)`, `clear()`, `get(id)`, `drawings()` | drawings |
64
+ | `setHidden(id, hidden)` | hide / show one drawing without removing it (the drawing's `hidden` flag, saved with it) |
65
+ | `setDrawingsVisible(visible)`, `drawingsVisible()` | hide / show every drawing at once (TV "Hide all drawings"; not saved, the drawings are untouched) |
64
66
  | `select(ids)`, `selection()` | selection (multi-select with Ctrl / Cmd) |
65
67
  | `bringToFront(id)`, `sendToBack(id)` | z-order |
66
68
  | `toggleAnchored(id)` | TV "Anchor drawing" for Text, Pin and Table: the drawing keeps its pane position when the chart scrolls (`isAnchorable(kind)`) |
@@ -71,6 +73,7 @@ intraday of date labels), `stayInDrawingMode` (TV Keep drawing).
71
73
  | `redraw()`, `destroy()` | |
72
74
 
73
75
  Events: `change`, `add`, `update`, `remove`, `selection`, `tool`,
76
+ `visibility` (every drawing hidden / shown again),
74
77
  `textEdit` (a text tool was placed or double-clicked: open your editor at
75
78
  the given pane point and `update` the drawing's `text`), `tableEdit` (a click
76
79
  on a cell of the selected table: open your editor over the given cell box),
@@ -84,6 +87,10 @@ steps / square boxes and magnet off, Ctrl / Cmd inverts the magnet; Escape
84
87
  drops pending points, then the tool, then the selection; Delete removes the
85
88
  selection (locked drawings stay).
86
89
 
90
+ Drawing flags: `locked` (selectable, but no drag and no Delete) and `hidden`
91
+ (not drawn, hit or selected). A drawing that gets hidden leaves the
92
+ selection. Arming a tool while every drawing is hidden shows them again.
93
+
87
94
  The host keeps what is not drawing logic: undo stack, storage, settings
88
95
  dialogs, text / table editors, toolbar, context menu.
89
96
 
package/dist/index.d.ts CHANGED
@@ -183,6 +183,8 @@ export declare class DrawingManager {
183
183
  private readonly listeners;
184
184
  private list;
185
185
  private selected;
186
+ /** TV "Hide all drawings": off = nothing is drawn or hit (not saved). */
187
+ private visible;
186
188
  private hovered;
187
189
  private spec;
188
190
  private glyph;
@@ -206,6 +208,7 @@ export declare class DrawingManager {
206
208
  on(event: "remove", cb: DrawingManagerEvents["remove"]): () => void;
207
209
  on(event: "selection", cb: DrawingManagerEvents["selection"]): () => void;
208
210
  on(event: "tool", cb: DrawingManagerEvents["tool"]): () => void;
211
+ on(event: "visibility", cb: DrawingManagerEvents["visibility"]): () => void;
209
212
  on(event: "textEdit", cb: DrawingManagerEvents["textEdit"]): () => void;
210
213
  on(event: "gestureEnd", cb: DrawingManagerEvents["gestureEnd"]): () => void;
211
214
  on(event: "tableEdit", cb: DrawingManagerEvents["tableEdit"]): () => void;
@@ -217,12 +220,20 @@ export declare class DrawingManager {
217
220
  tool(): DrawingKind | null;
218
221
  setMagnet(mode: MagnetMode): void;
219
222
  setInterval(interval: string | undefined): void;
223
+ /** TV "Hide all drawings": hide / show every drawing without touching
224
+ * them (the drawings' own `hidden` flag and the saved JSON stay as they
225
+ * are). Hiding disarms the tool and clears the selection. */
226
+ setDrawingsVisible(visible: boolean): void;
227
+ drawingsVisible(): boolean;
220
228
  setStayInDrawingMode(on: boolean): void;
221
229
  drawings(): readonly Drawing[];
222
230
  get(id: string): Drawing | undefined;
223
231
  /** Add a drawing (default style of its kind when none); returns its id. */
224
232
  add(nd: NewDrawing | Drawing): string;
225
233
  update(d: Drawing): void;
234
+ /** Hide / show one drawing (its `hidden` flag, saved with it): a hidden
235
+ * drawing is not drawn, hit or selected. */
236
+ setHidden(id: string, hidden: boolean): void;
226
237
  remove(id: string): void;
227
238
  clear(): void;
228
239
  /** Z-order (TV Visual order): the list order is the draw order. */
@@ -287,6 +298,9 @@ export declare class DrawingManager {
287
298
  private changed;
288
299
  private reorder;
289
300
  private shown;
301
+ /** Drawings that are no longer shown leave the selection and the hover:
302
+ * Delete must not remove a drawing the user cannot see. */
303
+ private dropHidden;
290
304
  private paneSize;
291
305
  /** Pointer position in pane coordinates. */
292
306
  private panePoint;
@@ -334,6 +348,9 @@ export declare type DrawingManagerEvents = {
334
348
  selection: (ids: readonly string[]) => void;
335
349
  /** The armed tool changed (null = none). */
336
350
  tool: (kind: DrawingKind | null) => void;
351
+ /** Every drawing was hidden or shown again (setDrawingsVisible, or a tool
352
+ * armed while they were hidden). */
353
+ visibility: (visible: boolean) => void;
337
354
  /** A text tool was placed (or double-clicked): the host opens its editor
338
355
  * at `screen` (pane coordinates) and calls update with the text. */
339
356
  textEdit: (d: Drawing, screen: Pt) => void;
@@ -1474,9 +1491,8 @@ declare type WithId<T> = T & {
1474
1491
  closed?: boolean;
1475
1492
  /** Locked drawings can be selected but not dragged or deleted via Delete-key. */
1476
1493
  locked?: boolean;
1477
- /** Hidden drawings are not rendered or hit-tested. Toggle via context menu;
1478
- * unhiding from the chart requires re-selecting through the ObjectTreePanel
1479
- * (not yet built). */
1494
+ /** Hidden drawings are not rendered, hit-tested or selected; the flag is
1495
+ * saved with the drawing (DrawingManager.setHidden). */
1480
1496
  hidden?: boolean;
1481
1497
  /** Per-interval visibility matrix (Settings → Visibility). Absent = always
1482
1498
  * visible (the default for drawings saved before this field existed). */