hyperprop-charting-library 0.1.134 → 0.1.135

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/docs/API.md CHANGED
@@ -482,11 +482,27 @@ chart.setActiveDrawingTool("fib-retracement"); // first click starts, second cli
482
482
  chart.setActiveDrawingTool("fib-extension"); // three clicks: trend start, trend end, projection origin
483
483
  chart.setActiveDrawingTool("long-position"); // single click drops a long risk/reward box
484
484
  chart.setActiveDrawingTool("short-position"); // single click drops a short risk/reward box
485
+ chart.setActiveDrawingTool("measure"); // next drag (or click-move-click) measures; see below
485
486
  chart.setActiveDrawingTool(null); // back to normal cursor/pan
486
487
  ```
487
488
 
488
489
  Use `getDrawings()` / `setDrawings()` for persistence.
489
490
 
491
+ ### Measure tool (TradingView-style ruler)
492
+
493
+ `"measure"` is transient — the only tool that never creates a drawing. Drag
494
+ (or click, move, click) across the plot to get a translucent box with
495
+ direction arrows and a stats pill: signed price change, % move, tick count
496
+ (when `tickSize` is configured), bar count, and wall-clock duration. Blue for
497
+ an up measurement, red for down.
498
+
499
+ - The overlay stays pinned to its bars/prices through pans and zooms.
500
+ - It clears on the next click, on Escape, on `cancelDrawing()`, or when the
501
+ active tool changes; it is never emitted through `onDrawingsChange`.
502
+ - After each measurement the chart reverts to the cursor (one-shot, like
503
+ TradingView) and reports it via `onActiveDrawingToolChange`.
504
+ - Shortcut: **Shift+drag** on the plot measures without arming the tool.
505
+
490
506
  ---
491
507
 
492
508
  ## `ChartInstance` Methods
@@ -522,8 +538,9 @@ Use `getDrawings()` / `setDrawings()` for persistence.
522
538
  - `cancelDrawing(): boolean` — abort an in-progress multi-click drawing (between the first click and the final point, e.g. a half-drawn trendline/ray/fib). Returns `true` if a draft was cancelled. Wire it to Escape.
523
539
  - Hold **Shift** while drawing or dragging an endpoint of a `trendline`/`ray` to constrain it to the nearest 0/45/90° angle (e.g. a perfectly horizontal line).
524
540
  - `setMagnetMode(mode): void` / `getMagnetMode()` — magnet/snap for all drawing tools. `"none"` off, `"weak"` snaps to a candle's OHLC only when the cursor is near a value, `"strong"` always snaps to the nearest OHLC of the bar under the cursor. Holding Cmd/Ctrl while drawing/dragging forces strong snapping regardless of the mode.
525
- - `setActiveDrawingTool(tool: DrawingToolType | null): void` (`DrawingToolType` = `"horizontal-line" | "vertical-line" | "trendline" | "ray" | "fib-retracement"`)
541
+ - `setActiveDrawingTool(tool: DrawingToolType | null): void` (`DrawingToolType` = `"horizontal-line" | "vertical-line" | "trendline" | "ray" | "fib-retracement" | "fib-extension" | "long-position" | "short-position" | "price-range" | "rectangle" | "text" | "note" | "measure"`)
526
542
  - `getActiveDrawingTool(): DrawingToolType | null`
543
+ - `onActiveDrawingToolChange(handler: ((tool: DrawingToolType | null) => void) | null): void` — fires whenever the active tool changes, including the chart auto-reverting to the cursor after a tool completes (all tools do this when their shape is placed; `measure` does it after every measurement). Keeps host toolbars in sync without polling.
527
544
  - `setDrawings(drawings: DrawingObjectOptions[]): void`
528
545
  - `getDrawings(): DrawingObjectOptions[]`
529
546
  - `addDrawing(drawing: DrawingObjectOptions): string`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperprop-charting-library",
3
- "version": "0.1.134",
3
+ "version": "0.1.135",
4
4
  "description": "Lightweight TypeScript charting core",
5
5
  "type": "module",
6
6
  "main": "./dist/hyperprop-charting-library.cjs",