@pipsend/charts 1.2.2 → 1.3.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/dist/typings.d.ts CHANGED
@@ -22,10 +22,50 @@ declare abstract class DrawingToolBase implements IDrawingTool {
22
22
  unlock(): void;
23
23
  isLocked(): boolean;
24
24
  isVisible(): boolean;
25
+ /** Series the tool is attached to. */
26
+ series(): ISeriesApi<SeriesType>;
25
27
  getState(): DrawingToolState;
26
28
  abstract remove(): void;
27
- abstract serialize(): SerializedDrawingTool;
28
29
  protected abstract _update(): void;
30
+ /**
31
+ * Identity and shared state live here, so no tool can forget to save them:
32
+ * a hidden or locked drawing used to come back visible and unlocked, and
33
+ * every id changed on restore.
34
+ */
35
+ serialize(): SerializedDrawingTool;
36
+ /** Reapply what `serialize()` stored on top of a freshly created tool. */
37
+ applySerializedState(data: SerializedDrawingTool): void;
38
+ /** The tool's own geometry and style. */
39
+ protected abstract _serializeShape(): SerializedDrawingTool;
40
+ /**
41
+ * Interaction contract.
42
+ *
43
+ * These were optional in practice: the manager looked them up at runtime and
44
+ * skipped whatever a tool happened not to implement, so a missing method
45
+ * showed up as a tool that silently could not be hovered or moved. Declared
46
+ * here, the compiler is the one that notices.
47
+ */
48
+ /** Whether the point is over the tool at all. */
49
+ abstract hitTest(x: number, y: number): boolean;
50
+ /**
51
+ * Which part of the tool is under the point — a handle, or the body when the
52
+ * whole object can be dragged. Null when the point grabs nothing.
53
+ */
54
+ abstract hitTestEndpoint(x: number, y: number): DrawingPart | null;
55
+ /**
56
+ * Primary colour of the tool, so a single control can restyle any of them.
57
+ * Tools that colour per level or per segment apply it to all of them.
58
+ */
59
+ abstract setColor(color: string): void;
60
+ abstract color(): string;
61
+ abstract setHovered(hovered: boolean): void;
62
+ abstract isHovered(): boolean;
63
+ abstract setSelected(selected: boolean): void;
64
+ abstract isSelected(): boolean;
65
+ /** Begin a drag of `part`, anchored at the point the pointer grabbed. */
66
+ abstract startDrag(part: any, grab: DragAnchor): void;
67
+ abstract updateDrag(time: Time, price: number): void;
68
+ abstract stopDrag(): void;
29
69
  }
30
70
  declare const areaSeries: SeriesDefinition<"Area">;
31
71
  declare const barSeries: SeriesDefinition<"Bar">;
@@ -43,6 +83,7 @@ declare enum DrawingToolState {
43
83
  export declare class ArrowTool extends DrawingToolBase {
44
84
  private _arrowOptions;
45
85
  private _primitive;
86
+ private _repaint;
46
87
  private _paneView;
47
88
  private _isSelected;
48
89
  private _isHovered;
@@ -62,9 +103,18 @@ export declare class ArrowTool extends DrawingToolBase {
62
103
  drawToCanvas(ctx: CanvasRenderingContext2D, horizontalPixelRatio: number, verticalPixelRatio: number): void;
63
104
  private _drawArrowHead;
64
105
  private _drawCircle;
106
+ setColor(color: string): void;
107
+ color(): string;
65
108
  setSelected(selected: boolean): void;
66
109
  isSelected(): boolean;
67
110
  setHovered(hovered: boolean): void;
111
+ isHovered(): boolean;
112
+ /**
113
+ * Hit test reported to the chart engine, which arbitrates between overlapping
114
+ * primitives by z-order and owns the cursor. Handles come first so they win
115
+ * over the body of the object.
116
+ */
117
+ private _hitTestPrimitive;
68
118
  hitTest(x: number, y: number): boolean;
69
119
  private _distanceToLineSegment;
70
120
  hitTestEndpoint(x: number, y: number): number | null;
@@ -74,66 +124,94 @@ export declare class ArrowTool extends DrawingToolBase {
74
124
  getPoints(): ArrowPoint[];
75
125
  addPoint(point: ArrowPoint): void;
76
126
  isVisible(): boolean;
77
- serialize(): SerializedDrawingTool;
127
+ protected _serializeShape(): SerializedDrawingTool;
78
128
  private _requestUpdate;
79
129
  protected _update(): void;
80
130
  remove(): void;
81
131
  }
132
+ /**
133
+ * Freehand stroke.
134
+ *
135
+ * While drawing, points are sampled and rendered in screen coordinates and only
136
+ * converted to time and price when the stroke ends. The previous version did
137
+ * the opposite — it converted every sample as it arrived and drained them from
138
+ * a buffer one per 16 ms timer tick — so a fast stroke kept drawing seconds
139
+ * after the pointer stopped. Sampling is distance based, which keeps the point
140
+ * count low enough for dragging and hit testing to stay cheap afterwards.
141
+ */
82
142
  export declare class BrushTool extends DrawingToolBase {
83
143
  private _brushOptions;
84
144
  private _primitive;
145
+ private _repaint;
85
146
  private _paneView;
86
147
  private _isSelected;
87
148
  private _isHovered;
149
+ private _drawingModeActive;
88
150
  private _isDrawing;
89
- private _currentStroke;
90
- private _mouseDownHandler;
91
- private _mouseMoveHandler;
92
- private _mouseUpHandler;
93
- private _chartElement;
94
- private _pointBuffer;
95
- private _smoothingInterval;
151
+ private _livePoints;
152
+ private _repaintQueued;
153
+ private _element;
154
+ private _pointerId;
155
+ private _pointerDown;
156
+ private _pointerMove;
157
+ private _pointerUp;
158
+ /** What the engine reports under the pointer, so a press meant for an
159
+ * existing drawing is not swallowed by a new stroke. */
160
+ private _hoveredExternalId;
161
+ private _crosshairHandler;
96
162
  private _isDragging;
97
- private _dragStartPoint;
163
+ private _grab;
164
+ private _moveStartPoints;
98
165
  constructor(context: DrawingContext, options: BrushToolOptions);
99
- private _initializeDrawingMode;
100
- private _startSmoothingInterval;
101
- private _stopSmoothingInterval;
102
- private _processBuffer;
103
- private _flushBuffer;
104
- private _cleanupDrawingHandlers;
105
- private _getPointFromMouseEvent;
106
- private _createPrimitive;
107
- private _createPaneView;
108
- drawToCanvas(ctx: CanvasRenderingContext2D, horizontalPixelRatio: number, verticalPixelRatio: number): void;
109
- private _drawPolyline;
110
- private _drawSmoothCurve;
166
+ startDrawingMode(): void;
111
167
  stopDrawingMode(): void;
112
168
  isDrawingModeActive(): boolean;
113
- setSelected(selected: boolean): void;
114
- isSelected(): boolean;
115
- setHovered(hovered: boolean): void;
169
+ private _onPointerDown;
170
+ private _onPointerMove;
171
+ private _onPointerUp;
172
+ /**
173
+ * Screen samples become time and price once, at the end of the stroke.
174
+ */
175
+ private _finishStroke;
176
+ private _isOverAnotherDrawing;
177
+ private _releasePointer;
178
+ private _toPanePoint;
179
+ private _paneElement;
180
+ /** At most one repaint per frame, however fast the samples arrive. */
181
+ private _queueRepaint;
182
+ drawToCanvas(ctx: CanvasRenderingContext2D, horizontalPixelRatio: number, verticalPixelRatio: number): void;
183
+ private _drawEndpoint;
184
+ private _screenPath;
116
185
  hitTest(x: number, y: number): boolean;
117
- private _distanceToLineSegment;
118
- getPoints(): BrushPoint[];
119
186
  hitTestEndpoint(x: number, y: number): "stroke" | null;
120
- startDrag(target: "stroke"): void;
121
- stopDrag(): void;
187
+ startDrag(target: "stroke", grab: DragAnchor): void;
122
188
  updateDrag(time: Time, price: number): void;
123
- isVisible(): boolean;
124
- serialize(): SerializedDrawingTool;
189
+ stopDrag(): void;
190
+ setColor(color: string): void;
191
+ color(): string;
192
+ setSelected(selected: boolean): void;
193
+ isSelected(): boolean;
194
+ setHovered(hovered: boolean): void;
195
+ isHovered(): boolean;
196
+ private _createPrimitive;
197
+ private _hitTestPrimitive;
125
198
  private _requestUpdate;
126
199
  protected _update(): void;
127
200
  remove(): void;
201
+ protected _serializeShape(): SerializedDrawingTool;
202
+ getPoints(): readonly BrushPoint[];
128
203
  }
129
204
  export declare class CircleTool extends DrawingToolBase {
130
205
  private _circleOptions;
131
206
  private _primitive;
207
+ private _repaint;
132
208
  private _paneView;
133
209
  private _isSelected;
134
210
  private _isHovered;
135
211
  private _isDragging;
136
212
  private _dragTarget;
213
+ private _grab;
214
+ private _moveStart;
137
215
  private _isDrawing;
138
216
  private _clickHandler;
139
217
  private _mouseMoveHandler;
@@ -147,59 +225,58 @@ export declare class CircleTool extends DrawingToolBase {
147
225
  private _drawEdgeHandles;
148
226
  private _drawLabel;
149
227
  private _hexToRgba;
228
+ setColor(color: string): void;
229
+ color(): string;
150
230
  setSelected(selected: boolean): void;
151
231
  isSelected(): boolean;
152
232
  setHovered(hovered: boolean): void;
233
+ isHovered(): boolean;
234
+ /**
235
+ * Hit test reported to the chart engine, which arbitrates between overlapping
236
+ * primitives by z-order and owns the cursor. Handles come first so they win
237
+ * over the body of the object.
238
+ */
239
+ private _hitTestPrimitive;
153
240
  hitTest(x: number, y: number): boolean;
154
241
  hitTestEndpoint(x: number, y: number): "center" | "edge" | null;
155
- startDrag(target: "center" | "edge"): void;
242
+ startDrag(target: "center" | "edge", grab: DragAnchor): void;
156
243
  stopDrag(): void;
157
244
  updateDrag(time: Time, price: number): void;
158
245
  isVisible(): boolean;
159
- serialize(): SerializedDrawingTool;
246
+ protected _serializeShape(): SerializedDrawingTool;
160
247
  private _requestUpdate;
161
248
  protected _update(): void;
162
249
  remove(): void;
163
250
  }
164
251
  /**
165
- * Draggable Price Line - Línea de precio que se puede arrastrar y/o hacer click
166
- */
167
- export declare class DraggablePriceLine {
168
- private _chart;
169
- private _series;
252
+ * A price line that can be dragged and clicked.
253
+ *
254
+ * Input is not handled here: every line on a chart shares a single
255
+ * TradingLineController, which is what guarantees that one gesture moves one
256
+ * line. Hit testing comes from the engine — the line's id travels as the price
257
+ * line's `externalId` — so the hit area matches what is drawn.
258
+ */
259
+ export declare class DraggablePriceLine implements ControllableLine {
260
+ private readonly _chart;
261
+ private readonly _series;
262
+ private readonly _id;
170
263
  private _priceLine;
171
264
  private _options;
172
- private _isDragging;
173
- private _container;
174
- private _unsubscribeHandlers;
175
265
  private _isHovering;
176
266
  private _originalColor;
177
- private _mouseDownPos;
178
- private _mouseDownOnLine;
267
+ private _priceBeforeDrag;
179
268
  constructor(chart: IChartApi, series: ISeriesApi<SeriesType>, options: DraggablePriceLineOptions);
180
- /**
181
- * Resolve the effective title: formatTitle(price) wins over the static title.
182
- */
183
- private _resolveTitle;
184
- private _createPriceLine;
185
- private _setupInteractionHandlers;
186
- private _getPriceFromY;
187
- /**
188
- * Verifica si el mouse está EN la línea (no cerca, sino exactamente sobre ella)
189
- * Usa la API de coordenadas del chart para precisión consistente
190
- * @param e - Mouse event
191
- * @param price - Precio calculado desde la posición Y
192
- */
193
- private _isOnLine;
194
- /**
195
- * Verifica si el mouse está en el área del gráfico (no en el price axis)
196
- */
197
- private _isInChartArea;
198
- /**
199
- * Activa/desactiva el estado de hover (línea negra)
200
- */
201
- private _setHoverState;
202
- private _updatePrice;
269
+ id(): string;
270
+ paneIndex(): number;
271
+ isDraggable(): boolean;
272
+ isClickable(): boolean;
273
+ setHovered(hovered: boolean): void;
274
+ priceAt(paneY: number): number | null;
275
+ beginDrag(): void;
276
+ dragTo(price: number): void;
277
+ commitDrag(): void;
278
+ cancelDrag(): void;
279
+ click(): void;
203
280
  /**
204
281
  * Update the price line options. Any subset of options can be passed.
205
282
  * Title is recomputed from `formatTitle` if available, otherwise from `title`.
@@ -210,22 +287,19 @@ export declare class DraggablePriceLine {
210
287
  * line's price (e.g. live PnL on a fixed entry line). Bypasses formatTitle.
211
288
  */
212
289
  setTitle(text: string): void;
213
- /**
214
- * Get current price
215
- */
216
290
  getPrice(): number;
217
291
  /**
218
292
  * Set price programmatically. Triggers formatTitle if configured.
219
293
  */
220
294
  setPrice(price: number): void;
221
- /**
222
- * Remove the price line and cleanup
223
- */
224
295
  remove(): void;
296
+ getPriceLine(): IPriceLine | null;
225
297
  /**
226
- * Get the underlying price line
298
+ * Resolve the effective title: formatTitle(price) wins over the static title.
227
299
  */
228
- getPriceLine(): IPriceLine | null;
300
+ private _resolveTitle;
301
+ private _createPriceLine;
302
+ private _updatePrice;
229
303
  }
230
304
  /**
231
305
  * Central manager for all drawing tools - TradingView style
@@ -233,6 +307,13 @@ export declare class DraggablePriceLine {
233
307
  */
234
308
  export declare class DrawingToolsManager {
235
309
  private _chart;
310
+ private _series;
311
+ /** Snapshots of the drawings, newest last. */
312
+ private _past;
313
+ private _future;
314
+ /** State as of the last committed change, the one undo goes back to. */
315
+ private _committed;
316
+ private _restoring;
236
317
  private _tools;
237
318
  private _selectedToolId;
238
319
  private _hoveredToolId;
@@ -241,16 +322,25 @@ export declare class DrawingToolsManager {
241
322
  private _clickHandler;
242
323
  private _keyboardHandler;
243
324
  private _mouseMoveHandler;
244
- private _mouseDownHandler;
245
- private _mouseUpHandler;
246
- private _toolIdCounter;
325
+ private _pointerDownHandler;
326
+ private _pointerUpHandler;
327
+ private _pointerCancelHandler;
328
+ private _pointerId;
329
+ /** A press that grabbed a tool already selected it; its click must not undo that. */
330
+ private _gestureHandled;
331
+ /** Latest pointer position in pane coordinates, from the engine. */
332
+ private _panePoint;
333
+ private _interactionsBeforeDrag;
334
+ private readonly _selectionChanged;
247
335
  private _isDragging;
248
336
  private _draggedToolId;
249
- constructor(chart: IChartApi, _series: ISeriesApi<any>, options?: DrawingToolsManagerOptions);
337
+ constructor(chart: IChartApi, series: ISeriesApi<any>, options?: DrawingToolsManagerOptions);
250
338
  /**
251
339
  * Start drawing a new tool of the specified type
252
340
  */
253
341
  startDrawing(type: DrawingToolType): void;
342
+ /** Tool type currently armed for drawing, if any. */
343
+ activeDrawingType(): DrawingToolType | null;
254
344
  /**
255
345
  * Stop drawing mode
256
346
  */
@@ -258,6 +348,11 @@ export declare class DrawingToolsManager {
258
348
  /**
259
349
  * Add a tool to the manager
260
350
  */
351
+ /**
352
+ * Tools are keyed by their own id. They used to be filed under a counter
353
+ * instead, so the id a tool reported and the one the manager answered to
354
+ * were different, and neither survived a restore.
355
+ */
261
356
  addTool(tool: DrawingToolBase, id?: string): string;
262
357
  /**
263
358
  * Remove a tool by ID
@@ -267,6 +362,42 @@ export declare class DrawingToolsManager {
267
362
  * Select a tool by ID
268
363
  */
269
364
  selectTool(id: string): boolean;
365
+ /**
366
+ * Single place where the selection changes, so every path — clicking,
367
+ * grabbing, deleting, clearing — reports it exactly once.
368
+ */
369
+ private _applySelection;
370
+ /**
371
+ * Commits the current drawings as a step that can be undone.
372
+ *
373
+ * Called by the manager on the changes it sees — adding, removing, clearing
374
+ * and finishing a drag. Anything the app changes on a tool directly, such as
375
+ * its colour, should call this afterwards.
376
+ */
377
+ recordChange(): void;
378
+ canUndo(): boolean;
379
+ canRedo(): boolean;
380
+ undo(): boolean;
381
+ redo(): boolean;
382
+ private _applySnapshot;
383
+ /**
384
+ * Notifies every selection change, so consumers do not have to poll for it.
385
+ */
386
+ subscribeSelectionChanged(handler: (selection: DrawingSelection) => void): void;
387
+ unsubscribeSelectionChanged(handler: (selection: DrawingSelection) => void): void;
388
+ /**
389
+ * Screen box of the selected tool, recomputed on demand: it moves whenever
390
+ * the chart is panned or zoomed.
391
+ */
392
+ selectionBounds(): DrawingBounds | null;
393
+ /**
394
+ * Bounds come from the tool's own serialized points, so this works for every
395
+ * tool without each one having to report a box.
396
+ */
397
+ private _boundsOf;
398
+ /** Panes below the first one are offset inside the chart element. */
399
+ private _paneOffsetOf;
400
+ private _emitSelection;
270
401
  /**
271
402
  * Deselect all tools
272
403
  */
@@ -328,12 +459,35 @@ export declare class DrawingToolsManager {
328
459
  private _detachEventHandlers;
329
460
  private _handleClick;
330
461
  private _handleMouseMove;
331
- private _handleMouseDown;
332
- private _handleMouseUp;
462
+ /**
463
+ * Resolve the tool behind an `externalId` reported by the engine's hit test.
464
+ * Ids carry the hovered part after `#`. Returns null for ids belonging to
465
+ * other primitives.
466
+ */
467
+ private _findToolByExternalId;
468
+ private _handlePointerDown;
469
+ private _handlePointerUp;
470
+ /**
471
+ * Pane element of a tool's series. The engine asserts the series has a pane,
472
+ * so the lookup is guarded.
473
+ */
474
+ private _paneElementOf;
475
+ /**
476
+ * Resolve what a pointer event lands on without relying on a previous hover.
477
+ * Coordinates come from each tool's own pane, so tools in secondary panes
478
+ * are hit tested correctly. Overlaps resolve to the first match here, unlike
479
+ * the hover path, which the engine arbitrates by z-order.
480
+ */
481
+ private _hitAtEvent;
482
+ private _releasePointer;
333
483
  private _disableChartInteractions;
334
484
  private _enableChartInteractions;
335
485
  private _handleKeyboard;
336
- private _findToolAtPoint;
486
+ /**
487
+ * Pointer position in time/price space, used as the anchor of a drag gesture.
488
+ * Returns null when the price cannot be resolved, in which case no drag starts.
489
+ */
490
+ private _anchorAt;
337
491
  private _deselectAll;
338
492
  }
339
493
  export declare class FibonacciCalculator {
@@ -381,6 +535,7 @@ export declare class FibonacciCalculator {
381
535
  export declare class FibonacciExtensionTool extends DrawingToolBase {
382
536
  private _fibOptions;
383
537
  private _primitive;
538
+ private _repaint;
384
539
  private _paneView;
385
540
  private _isSelected;
386
541
  private _isHovered;
@@ -398,9 +553,18 @@ export declare class FibonacciExtensionTool extends DrawingToolBase {
398
553
  setPoint2(point: FibonacciExtensionPoint): void;
399
554
  setPoint3(point: FibonacciExtensionPoint): void;
400
555
  isComplete(): boolean;
556
+ setColor(color: string): void;
557
+ color(): string;
401
558
  setSelected(selected: boolean): void;
402
559
  isSelected(): boolean;
403
560
  setHovered(hovered: boolean): void;
561
+ isHovered(): boolean;
562
+ /**
563
+ * Hit test reported to the chart engine, which arbitrates between overlapping
564
+ * primitives by z-order and owns the cursor. Handles come first so they win
565
+ * over the body of the object.
566
+ */
567
+ private _hitTestPrimitive;
404
568
  hitTest(x: number, y: number): boolean;
405
569
  hitTestEndpoint(x: number, y: number): "point1" | "point2" | "point3" | null;
406
570
  startDrag(target: "point1" | "point2" | "point3"): void;
@@ -415,7 +579,7 @@ export declare class FibonacciExtensionTool extends DrawingToolBase {
415
579
  }>;
416
580
  drawToCanvas(ctx: CanvasRenderingContext2D, horizontalPixelRatio: number, verticalPixelRatio: number): void;
417
581
  isVisible(): boolean;
418
- serialize(): SerializedDrawingTool;
582
+ protected _serializeShape(): SerializedDrawingTool;
419
583
  private _requestUpdate;
420
584
  protected _update(): void;
421
585
  remove(): void;
@@ -423,6 +587,7 @@ export declare class FibonacciExtensionTool extends DrawingToolBase {
423
587
  export declare class FibonacciFanTool extends DrawingToolBase {
424
588
  private _fanOptions;
425
589
  private _primitive;
590
+ private _repaint;
426
591
  private _paneView;
427
592
  private _isSelected;
428
593
  private _isHovered;
@@ -441,9 +606,18 @@ export declare class FibonacciFanTool extends DrawingToolBase {
441
606
  private _drawLine;
442
607
  private _drawEndpoint;
443
608
  private _drawLabel;
609
+ setColor(color: string): void;
610
+ color(): string;
444
611
  setSelected(selected: boolean): void;
445
612
  isSelected(): boolean;
446
613
  setHovered(hovered: boolean): void;
614
+ isHovered(): boolean;
615
+ /**
616
+ * Hit test reported to the chart engine, which arbitrates between overlapping
617
+ * primitives by z-order and owns the cursor. Handles come first so they win
618
+ * over the body of the object.
619
+ */
620
+ private _hitTestPrimitive;
447
621
  hitTest(x: number, y: number): boolean;
448
622
  private _distanceToLineSegment;
449
623
  hitTestEndpoint(x: number, y: number): "point1" | "point2" | null;
@@ -451,7 +625,7 @@ export declare class FibonacciFanTool extends DrawingToolBase {
451
625
  stopDrag(): void;
452
626
  updateDrag(time: Time, price: number): void;
453
627
  isVisible(): boolean;
454
- serialize(): SerializedDrawingTool;
628
+ protected _serializeShape(): SerializedDrawingTool;
455
629
  private _requestUpdate;
456
630
  protected _update(): void;
457
631
  remove(): void;
@@ -464,11 +638,13 @@ export declare class FibonacciTool extends DrawingToolBase {
464
638
  private _fibOptions;
465
639
  private _calculator;
466
640
  private _primitive;
641
+ private _repaint;
467
642
  private _metrics;
468
643
  private _paneView;
469
644
  private _drawingManager;
470
645
  private _isComplete;
471
646
  private _isSelected;
647
+ private _isHovered;
472
648
  private _previewPoint;
473
649
  private _isDragging;
474
650
  private _draggedEndpoint;
@@ -484,7 +660,7 @@ export declare class FibonacciTool extends DrawingToolBase {
484
660
  getMetrics(): FibonacciMetrics | null;
485
661
  getLevels(): FibonacciLevel[];
486
662
  isVisible(): boolean;
487
- serialize(): SerializedDrawingTool;
663
+ protected _serializeShape(): SerializedDrawingTool;
488
664
  useExtendedLevels(extended: boolean): void;
489
665
  private _initializeInteractiveMode;
490
666
  private _drawPreview;
@@ -494,9 +670,20 @@ export declare class FibonacciTool extends DrawingToolBase {
494
670
  private _handleDragMove;
495
671
  startDrag(endpoint: "point1" | "point2"): void;
496
672
  stopDrag(): void;
673
+ updateDrag(time: Time, price: number): void;
497
674
  hitTestEndpoint(x: number, y: number): "point1" | "point2" | null;
675
+ setColor(color: string): void;
676
+ color(): string;
498
677
  setSelected(selected: boolean): void;
678
+ setHovered(hovered: boolean): void;
679
+ isHovered(): boolean;
499
680
  isSelected(): boolean;
681
+ /**
682
+ * Hit test reported to the chart engine, which arbitrates between overlapping
683
+ * primitives by z-order and owns the cursor. Handles come first so they win
684
+ * over the body of the object.
685
+ */
686
+ private _hitTestPrimitive;
500
687
  hitTest(x: number, y: number): boolean;
501
688
  remove(): void;
502
689
  destroy(): void;
@@ -506,9 +693,14 @@ export declare class FibonacciTool extends DrawingToolBase {
506
693
  export declare class GanttTool extends DrawingToolBase {
507
694
  private _ganttOptions;
508
695
  private _primitive;
696
+ private _repaint;
509
697
  private _paneView;
510
698
  private _isSelected;
511
699
  private _isHovered;
700
+ private _isDragging;
701
+ private _dragSegmentIndex;
702
+ private _grab;
703
+ private _moveStart;
512
704
  private _hoveredSegmentIndex;
513
705
  constructor(context: DrawingContext, options: GanttToolOptions);
514
706
  private _createPrimitive;
@@ -521,12 +713,28 @@ export declare class GanttTool extends DrawingToolBase {
521
713
  addSegment(segment: GanttSegment): void;
522
714
  removeSegment(index: number): void;
523
715
  getSegments(): GanttSegment[];
716
+ setColor(color: string): void;
717
+ color(): string;
524
718
  setSelected(selected: boolean): void;
525
719
  isSelected(): boolean;
526
720
  setHovered(hovered: boolean): void;
721
+ isHovered(): boolean;
722
+ /**
723
+ * Hit test reported to the chart engine, which arbitrates between overlapping
724
+ * primitives by z-order and owns the cursor.
725
+ */
726
+ private _hitTestPrimitive;
727
+ /**
728
+ * Segments are dragged as a whole along the time axis; the hovered one is
729
+ * resolved by `hitTest`, which records its index.
730
+ */
731
+ hitTestEndpoint(x: number, y: number): "move" | null;
732
+ startDrag(target: "move", grab: DragAnchor): void;
733
+ updateDrag(time: Time, price: number): void;
734
+ stopDrag(): void;
527
735
  hitTest(x: number, y: number): boolean;
528
736
  isVisible(): boolean;
529
- serialize(): SerializedDrawingTool;
737
+ protected _serializeShape(): SerializedDrawingTool;
530
738
  private _requestUpdate;
531
739
  protected _update(): void;
532
740
  remove(): void;
@@ -534,28 +742,40 @@ export declare class GanttTool extends DrawingToolBase {
534
742
  export declare class HorizontalLineTool extends DrawingToolBase {
535
743
  private _hLineOptions;
536
744
  private _primitive;
745
+ private _repaint;
537
746
  private _paneView;
538
747
  private _isSelected;
539
748
  private _isHovered;
540
749
  private _isDragging;
750
+ private _grab;
751
+ private _moveStartPrice;
541
752
  constructor(context: DrawingContext, options: HorizontalLineToolOptions);
542
753
  private _createPrimitive;
543
754
  private _createPaneView;
544
755
  drawToCanvas(ctx: CanvasRenderingContext2D, horizontalPixelRatio: number, verticalPixelRatio: number): void;
545
756
  private _drawLabel;
757
+ setColor(color: string): void;
758
+ color(): string;
546
759
  setSelected(selected: boolean): void;
547
760
  isSelected(): boolean;
548
761
  setHovered(hovered: boolean): void;
762
+ isHovered(): boolean;
763
+ /**
764
+ * Hit test reported to the chart engine, which arbitrates between overlapping
765
+ * primitives by z-order and owns the cursor. Handles come first so they win
766
+ * over the body of the object.
767
+ */
768
+ private _hitTestPrimitive;
549
769
  hitTest(x: number, y: number): boolean;
550
770
  hitTestEndpoint(x: number, y: number): "line" | null;
551
- startDrag(target: "line"): void;
771
+ startDrag(target: "line", grab: DragAnchor): void;
552
772
  stopDrag(): void;
553
773
  updateDrag(time: Time, price: number): void;
554
774
  getPrice(): number | undefined;
555
775
  setPrice(price: number): void;
556
776
  setLabel(text: string): void;
557
777
  isVisible(): boolean;
558
- serialize(): SerializedDrawingTool;
778
+ protected _serializeShape(): SerializedDrawingTool;
559
779
  private _requestUpdate;
560
780
  protected _update(): void;
561
781
  remove(): void;
@@ -572,6 +792,10 @@ export declare class InteractiveLineManager {
572
792
  private _customOptions;
573
793
  constructor(chart: IChartApi, series: ISeriesApi<SeriesType>);
574
794
  private _setupContainer;
795
+ /**
796
+ * Y is measured against the series' own pane, so lines created on a pane
797
+ * below the main one land on the price the user clicked.
798
+ */
575
799
  private _getPriceFromMouseEvent;
576
800
  /**
577
801
  * Activa el modo de creación de líneas por clic
@@ -698,14 +922,15 @@ export declare class PositionTool extends DrawingToolBase {
698
922
  private _positionOptions;
699
923
  private _calculator;
700
924
  private _primitive;
925
+ private _repaint;
701
926
  private _metrics;
702
927
  private _paneView;
703
928
  private _isSelected;
704
929
  private _isHovered;
705
930
  private _isDragging;
706
931
  private _dragTarget;
707
- private _dragStartPrice;
708
- private _dragStartTime;
932
+ private _grab;
933
+ private _moveStart;
709
934
  private _profitRect;
710
935
  private _lossRect;
711
936
  constructor(context: DrawingContext, options: PositionToolOptions);
@@ -740,16 +965,24 @@ export declare class PositionTool extends DrawingToolBase {
740
965
  * Set entry price
741
966
  */
742
967
  setEntryPrice(price: number): void;
743
- serialize(): SerializedDrawingTool;
968
+ protected _serializeShape(): SerializedDrawingTool;
969
+ setColor(color: string): void;
970
+ color(): string;
744
971
  setSelected(selected: boolean): void;
745
972
  isSelected(): boolean;
746
973
  setHovered(hovered: boolean): void;
974
+ isHovered(): boolean;
975
+ /**
976
+ * Hit test reported to the chart engine, which arbitrates between overlapping
977
+ * primitives by z-order and owns the cursor. Handles come first so they win
978
+ * over the body of the object.
979
+ */
980
+ private _hitTestPrimitive;
747
981
  hitTest(x: number, y: number): boolean;
748
982
  hitTestEndpoint(x: number, y: number): "tp" | "sl" | "tp-right" | "sl-right" | "entry" | "move" | null;
749
- startDrag(target: "tp" | "sl" | "tp-right" | "sl-right" | "entry" | "move"): void;
983
+ startDrag(target: "tp" | "sl" | "tp-right" | "sl-right" | "entry" | "move", grab: DragAnchor): void;
750
984
  stopDrag(): void;
751
985
  updateDrag(time: Time, price: number): void;
752
- private _getTimeDelta;
753
986
  private _addTimeDelta;
754
987
  private _requestUpdate;
755
988
  protected _update(): void;
@@ -758,11 +991,13 @@ export declare class PositionTool extends DrawingToolBase {
758
991
  export declare class RectangleTool extends DrawingToolBase {
759
992
  private _rectOptions;
760
993
  private _primitive;
994
+ private _repaint;
761
995
  private _paneView;
762
996
  private _isSelected;
763
997
  private _isHovered;
764
998
  private _isDragging;
765
999
  private _dragTarget;
1000
+ private _grab;
766
1001
  private _dragStartPoint1;
767
1002
  private _dragStartPoint2;
768
1003
  private _isDrawing;
@@ -777,16 +1012,25 @@ export declare class RectangleTool extends DrawingToolBase {
777
1012
  private _drawCornerHandles;
778
1013
  private _drawLabel;
779
1014
  private _hexToRgba;
1015
+ setColor(color: string): void;
1016
+ color(): string;
780
1017
  setSelected(selected: boolean): void;
781
1018
  isSelected(): boolean;
782
1019
  setHovered(hovered: boolean): void;
1020
+ isHovered(): boolean;
1021
+ /**
1022
+ * Hit test reported to the chart engine, which arbitrates between overlapping
1023
+ * primitives by z-order and owns the cursor. Handles come first so they win
1024
+ * over the body of the object.
1025
+ */
1026
+ private _hitTestPrimitive;
783
1027
  hitTest(x: number, y: number): boolean;
784
1028
  hitTestEndpoint(x: number, y: number): "corner1" | "corner2" | "corner3" | "corner4" | "body" | null;
785
- startDrag(target: "corner1" | "corner2" | "corner3" | "corner4" | "body"): void;
1029
+ startDrag(target: "corner1" | "corner2" | "corner3" | "corner4" | "body", grab: DragAnchor): void;
786
1030
  stopDrag(): void;
787
1031
  updateDrag(time: Time, price: number): void;
788
1032
  isVisible(): boolean;
789
- serialize(): SerializedDrawingTool;
1033
+ protected _serializeShape(): SerializedDrawingTool;
790
1034
  private _requestUpdate;
791
1035
  protected _update(): void;
792
1036
  remove(): void;
@@ -839,11 +1083,13 @@ export declare class RulerTool extends DrawingToolBase {
839
1083
  private _rulerOptions;
840
1084
  private _calculator;
841
1085
  private _primitive;
1086
+ private _repaint;
842
1087
  private _metrics;
843
1088
  private _paneView;
844
1089
  private _drawingManager;
845
1090
  private _isComplete;
846
1091
  private _isSelected;
1092
+ private _isHovered;
847
1093
  private _previewPoint;
848
1094
  private _isDragging;
849
1095
  private _draggedEndpoint;
@@ -873,20 +1119,31 @@ export declare class RulerTool extends DrawingToolBase {
873
1119
  * Stop dragging
874
1120
  */
875
1121
  stopDrag(): void;
1122
+ updateDrag(time: Time, price: number): void;
876
1123
  /**
877
1124
  * Check if a point is near an endpoint
878
1125
  */
879
1126
  hitTestEndpoint(x: number, y: number): "point1" | "point2" | null;
880
1127
  private _requestUpdate;
881
1128
  protected _update(): void;
882
- serialize(): SerializedDrawingTool;
1129
+ protected _serializeShape(): SerializedDrawingTool;
1130
+ setColor(color: string): void;
1131
+ color(): string;
883
1132
  setSelected(selected: boolean): void;
1133
+ setHovered(hovered: boolean): void;
1134
+ isHovered(): boolean;
884
1135
  isSelected(): boolean;
885
1136
  isComplete(): boolean;
886
1137
  /**
887
1138
  * Hit test - check if a point is near the ruler line
888
1139
  * Returns true if the point is within tolerance distance from the line
889
1140
  */
1141
+ /**
1142
+ * Hit test reported to the chart engine, which arbitrates between overlapping
1143
+ * primitives by z-order and owns the cursor. Handles come first so they win
1144
+ * over the body of the object.
1145
+ */
1146
+ private _hitTestPrimitive;
890
1147
  hitTest(x: number, y: number): boolean;
891
1148
  /**
892
1149
  * Calculate distance from a point to a line segment
@@ -896,10 +1153,14 @@ export declare class RulerTool extends DrawingToolBase {
896
1153
  export declare class TextTool extends DrawingToolBase {
897
1154
  private _textOptions;
898
1155
  private _primitive;
1156
+ private _repaint;
899
1157
  private _paneView;
900
1158
  private _isSelected;
901
1159
  private _isHovered;
902
1160
  private _isDragging;
1161
+ private _dragTarget;
1162
+ private _grab;
1163
+ private _moveStart;
903
1164
  private _isEditing;
904
1165
  private _clickOutsideHandler;
905
1166
  constructor(context: DrawingContext, options: TextToolOptions);
@@ -915,19 +1176,28 @@ export declare class TextTool extends DrawingToolBase {
915
1176
  private _requestUpdate;
916
1177
  protected _update(): void;
917
1178
  isComplete(): boolean;
1179
+ setColor(color: string): void;
1180
+ color(): string;
918
1181
  setSelected(selected: boolean): void;
919
1182
  isSelected(): boolean;
920
1183
  setHovered(hovered: boolean): void;
1184
+ isHovered(): boolean;
921
1185
  setEditing(editing: boolean): void;
922
1186
  isEditing(): boolean;
1187
+ /**
1188
+ * Hit test reported to the chart engine, which arbitrates between overlapping
1189
+ * primitives by z-order and owns the cursor. Handles come first so they win
1190
+ * over the body of the object.
1191
+ */
1192
+ private _hitTestPrimitive;
923
1193
  hitTest(x: number, y: number): boolean;
924
1194
  hitTestEndpoint(x: number, y: number): "anchor" | null;
925
- startDrag(target: "anchor" | "body"): void;
1195
+ startDrag(target: "anchor" | "body", grab: DragAnchor): void;
926
1196
  stopDrag(): void;
927
1197
  updateDrag(time: Time, price: number): void;
928
1198
  drawToCanvas(ctx: CanvasRenderingContext2D, horizontalPixelRatio: number, verticalPixelRatio: number): void;
929
1199
  private _hexToRgba;
930
- serialize(): SerializedDrawingTool;
1200
+ protected _serializeShape(): SerializedDrawingTool;
931
1201
  remove(): void;
932
1202
  }
933
1203
  export declare class TradingSessionsIndicator {
@@ -963,11 +1233,13 @@ export declare class TradingSessionsIndicator {
963
1233
  export declare class TrendLineTool extends DrawingToolBase {
964
1234
  private _trendOptions;
965
1235
  private _primitive;
1236
+ private _repaint;
966
1237
  private _paneView;
967
1238
  private _isSelected;
968
1239
  private _isHovered;
969
1240
  private _isDragging;
970
1241
  private _dragTarget;
1242
+ private _grab;
971
1243
  private _dragStartPoint1;
972
1244
  private _dragStartPoint2;
973
1245
  private _isComplete;
@@ -979,17 +1251,26 @@ export declare class TrendLineTool extends DrawingToolBase {
979
1251
  drawToCanvas(ctx: CanvasRenderingContext2D, horizontalPixelRatio: number, verticalPixelRatio: number): void;
980
1252
  private _drawPreview;
981
1253
  private _drawEndpoint;
1254
+ setColor(color: string): void;
1255
+ color(): string;
982
1256
  setSelected(selected: boolean): void;
983
1257
  isSelected(): boolean;
1258
+ isHovered(): boolean;
984
1259
  setHovered(hovered: boolean): void;
1260
+ /**
1261
+ * Hit test reported to the chart engine, which arbitrates between overlapping
1262
+ * primitives by z-order and owns the cursor. Geometry comes from
1263
+ * `hitTestEndpoint` so there is a single implementation of it.
1264
+ */
1265
+ private _hitTestPrimitive;
985
1266
  hitTest(x: number, y: number): boolean;
986
1267
  private _distanceToLineSegment;
987
1268
  hitTestEndpoint(x: number, y: number): "point1" | "point2" | "line" | null;
988
- startDrag(target: "point1" | "point2" | "line"): void;
1269
+ startDrag(target: "point1" | "point2" | "line", grab: DragAnchor): void;
989
1270
  stopDrag(): void;
990
1271
  updateDrag(time: Time, price: number): void;
991
1272
  isVisible(): boolean;
992
- serialize(): SerializedDrawingTool;
1273
+ protected _serializeShape(): SerializedDrawingTool;
993
1274
  private _requestUpdate;
994
1275
  protected _update(): void;
995
1276
  remove(): void;
@@ -997,28 +1278,40 @@ export declare class TrendLineTool extends DrawingToolBase {
997
1278
  export declare class VerticalLineTool extends DrawingToolBase {
998
1279
  private _vLineOptions;
999
1280
  private _primitive;
1281
+ private _repaint;
1000
1282
  private _paneView;
1001
1283
  private _isSelected;
1002
1284
  private _isHovered;
1003
1285
  private _isDragging;
1286
+ private _grab;
1287
+ private _moveStartTime;
1004
1288
  constructor(context: DrawingContext, options: VerticalLineToolOptions);
1005
1289
  private _createPrimitive;
1006
1290
  private _createPaneView;
1007
1291
  drawToCanvas(ctx: CanvasRenderingContext2D, horizontalPixelRatio: number, verticalPixelRatio: number): void;
1008
1292
  private _drawLabel;
1293
+ setColor(color: string): void;
1294
+ color(): string;
1009
1295
  setSelected(selected: boolean): void;
1010
1296
  isSelected(): boolean;
1011
1297
  setHovered(hovered: boolean): void;
1298
+ isHovered(): boolean;
1299
+ /**
1300
+ * Hit test reported to the chart engine, which arbitrates between overlapping
1301
+ * primitives by z-order and owns the cursor. Handles come first so they win
1302
+ * over the body of the object.
1303
+ */
1304
+ private _hitTestPrimitive;
1012
1305
  hitTest(x: number, y: number): boolean;
1013
1306
  hitTestEndpoint(x: number, y: number): "line" | null;
1014
- startDrag(target: "line"): void;
1307
+ startDrag(target: "line", grab: DragAnchor): void;
1015
1308
  stopDrag(): void;
1016
1309
  updateDrag(time: Time, price: number): void;
1017
1310
  getTime(): Time | undefined;
1018
1311
  setTime(time: Time): void;
1019
1312
  setLabel(text: string): void;
1020
1313
  isVisible(): boolean;
1021
- serialize(): SerializedDrawingTool;
1314
+ protected _serializeShape(): SerializedDrawingTool;
1022
1315
  private _requestUpdate;
1023
1316
  protected _update(): void;
1024
1317
  remove(): void;
@@ -1261,7 +1554,10 @@ export declare enum TrackingModeExitMode {
1261
1554
  * @param options - ATR configuration
1262
1555
  * @returns The ATR line series
1263
1556
  */
1264
- export declare function applyATR(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: ATROptions): ISeriesApi<"Line">;
1557
+ export declare function applyATR(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: ATROptions): {
1558
+ series: ISeriesApi<"Line">;
1559
+ remove(): void;
1560
+ };
1265
1561
  /**
1266
1562
  * Apply Bollinger Bands indicator to a series
1267
1563
  * @param series - Source series
@@ -1273,6 +1569,7 @@ export declare function applyBollingerBands(series: ISeriesApi<SeriesType>, char
1273
1569
  upper: ISeriesApi<"Line">;
1274
1570
  middle: ISeriesApi<"Line">;
1275
1571
  lower: ISeriesApi<"Line">;
1572
+ remove(): void;
1276
1573
  };
1277
1574
  /**
1278
1575
  * Apply EMA (Exponential Moving Average) indicator to a series
@@ -1281,7 +1578,10 @@ export declare function applyBollingerBands(series: ISeriesApi<SeriesType>, char
1281
1578
  * @param options - EMA configuration options
1282
1579
  * @returns The EMA line series
1283
1580
  */
1284
- export declare function applyEMA(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: EMAOptions): ISeriesApi<"Line">;
1581
+ export declare function applyEMA(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: EMAOptions): {
1582
+ series: ISeriesApi<"Line">;
1583
+ remove(): void;
1584
+ };
1285
1585
  /**
1286
1586
  * Apply MACD indicator to a series
1287
1587
  * @param series - Source series
@@ -1293,6 +1593,7 @@ export declare function applyMACD(series: ISeriesApi<SeriesType>, chart: IChartA
1293
1593
  macd: ISeriesApi<"Line">;
1294
1594
  signal: ISeriesApi<"Line">;
1295
1595
  histogram: ISeriesApi<"Histogram">;
1596
+ remove(): void;
1296
1597
  };
1297
1598
  /**
1298
1599
  * Apply OBV (On-Balance Volume) indicator to a series
@@ -1301,7 +1602,10 @@ export declare function applyMACD(series: ISeriesApi<SeriesType>, chart: IChartA
1301
1602
  * @param options - OBV configuration
1302
1603
  * @returns The OBV line series
1303
1604
  */
1304
- export declare function applyOBV(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: OBVOptions): ISeriesApi<"Line">;
1605
+ export declare function applyOBV(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: OBVOptions): {
1606
+ series: ISeriesApi<"Line">;
1607
+ remove(): void;
1608
+ };
1305
1609
  /**
1306
1610
  * Apply RSI indicator to a series
1307
1611
  * @param series - Source series to calculate RSI from
@@ -1309,7 +1613,10 @@ export declare function applyOBV(series: ISeriesApi<SeriesType>, chart: IChartAp
1309
1613
  * @param options - RSI configuration options
1310
1614
  * @returns The RSI line series
1311
1615
  */
1312
- export declare function applyRSI(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: RSIOptions): ISeriesApi<"Line">;
1616
+ export declare function applyRSI(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: RSIOptions): {
1617
+ series: ISeriesApi<"Line">;
1618
+ remove(): void;
1619
+ };
1313
1620
  /**
1314
1621
  * Apply SMA (Simple Moving Average) indicator to a series
1315
1622
  * @param series - Source series to calculate SMA from
@@ -1317,7 +1624,10 @@ export declare function applyRSI(series: ISeriesApi<SeriesType>, chart: IChartAp
1317
1624
  * @param options - SMA configuration options
1318
1625
  * @returns The SMA line series
1319
1626
  */
1320
- export declare function applySMA(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: SMAOptions): ISeriesApi<"Line">;
1627
+ export declare function applySMA(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: SMAOptions): {
1628
+ series: ISeriesApi<"Line">;
1629
+ remove(): void;
1630
+ };
1321
1631
  /**
1322
1632
  * Apply Stochastic Oscillator indicator to a series
1323
1633
  * @param series - Source series
@@ -1328,6 +1638,7 @@ export declare function applySMA(series: ISeriesApi<SeriesType>, chart: IChartAp
1328
1638
  export declare function applyStochastic(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: StochasticOptions): {
1329
1639
  k: ISeriesApi<"Line">;
1330
1640
  d: ISeriesApi<"Line">;
1641
+ remove(): void;
1331
1642
  };
1332
1643
  /**
1333
1644
  * Apply Volume indicator to a series
@@ -1337,7 +1648,10 @@ export declare function applyStochastic(series: ISeriesApi<SeriesType>, chart: I
1337
1648
  * @param options - Volume configuration
1338
1649
  * @returns The Volume histogram series
1339
1650
  */
1340
- export declare function applyVolume(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: VolumeOptions): ISeriesApi<"Histogram">;
1651
+ export declare function applyVolume(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: VolumeOptions): {
1652
+ series: ISeriesApi<"Histogram">;
1653
+ remove(): void;
1654
+ };
1341
1655
  /**
1342
1656
  * Apply WMA (Weighted Moving Average) indicator to a series
1343
1657
  * @param series - Source series to calculate WMA from
@@ -1345,14 +1659,21 @@ export declare function applyVolume(series: ISeriesApi<SeriesType>, chart: IChar
1345
1659
  * @param options - WMA configuration options
1346
1660
  * @returns The WMA line series
1347
1661
  */
1348
- export declare function applyWMA(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: WMAOptions): ISeriesApi<"Line">;
1662
+ export declare function applyWMA(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: WMAOptions): {
1663
+ series: ISeriesApi<"Line">;
1664
+ remove(): void;
1665
+ };
1349
1666
  /**
1350
1667
  * Automatically calculate pip configuration based on price
1351
1668
  * This is completely generic and works for any instrument
1352
1669
  */
1353
1670
  export declare function calculatePipConfig(price: number): PipConfig;
1671
+ /**
1672
+ * Horizontal coordinate of a time, including times beyond the last bar.
1673
+ */
1674
+ export declare function coordinateFromTime(chart: IChartApi, series: ISeriesApi<SeriesType>, time: Time | undefined | null): number | null;
1354
1675
  export declare function createArrowTool(context: DrawingContext, options: ArrowToolOptions): ArrowTool;
1355
- export declare function createBrushTool(context: DrawingContext, options: BrushToolOptions): BrushTool;
1676
+ export declare function createBrushTool(context: DrawingContext, options?: BrushToolOptions): BrushTool;
1356
1677
  /**
1357
1678
  * This function is the simplified main entry point of the Lightweight Charting Library with time points for the horizontal scale.
1358
1679
  *
@@ -1693,11 +2014,17 @@ export declare function setVolumeProfileData(indicator: VolumeProfileIndicator,
1693
2014
  time: Time;
1694
2015
  volume: number;
1695
2016
  }>): void;
2017
+ /**
2018
+ * Time at a horizontal coordinate, extrapolated past the last bar.
2019
+ */
2020
+ export declare function timeFromCoordinate(chart: IChartApi, series: ISeriesApi<SeriesType>, x: number): Time | null;
1696
2021
  /**
1697
2022
  * Returns the current version as a string. For example `'1.0.0'`.
1698
2023
  */
1699
2024
  export declare function version(): string;
1700
2025
  export interface ATROptions {
2026
+ /** Pane the indicator is drawn in. Defaults to its historical value. */
2027
+ paneIndex?: number;
1701
2028
  period?: number;
1702
2029
  color?: string;
1703
2030
  }
@@ -2122,6 +2449,8 @@ export interface BaselineStyleOptions {
2122
2449
  lastPriceAnimation: LastPriceAnimationMode;
2123
2450
  }
2124
2451
  export interface BollingerBandsOptions {
2452
+ /** Pane the indicator is drawn in. Defaults to its historical value. */
2453
+ paneIndex?: number;
2125
2454
  period?: number;
2126
2455
  stdDev?: number;
2127
2456
  colorUpper?: string;
@@ -2136,7 +2465,10 @@ export interface BrushToolOptions extends DrawingToolOptions {
2136
2465
  points?: BrushPoint[];
2137
2466
  color?: string;
2138
2467
  lineWidth?: number;
2468
+ /** Draw the stroke as curves through the sampled points. */
2139
2469
  smoothing?: boolean;
2470
+ /** Minimum distance in pixels between sampled points. */
2471
+ sampleDistance?: number;
2140
2472
  onUpdate?: () => void;
2141
2473
  onRemove?: () => void;
2142
2474
  onComplete?: () => void;
@@ -2358,6 +2690,23 @@ export interface CircleToolOptions extends DrawingToolOptions {
2358
2690
  onUpdate?: () => void;
2359
2691
  onRemove?: () => void;
2360
2692
  }
2693
+ /**
2694
+ * What the controller needs from a line to drive it. Kept to plain values and
2695
+ * public methods so the build-time property mangler cannot rename them apart.
2696
+ */
2697
+ export interface ControllableLine {
2698
+ id(): string;
2699
+ paneIndex(): number;
2700
+ isDraggable(): boolean;
2701
+ isClickable(): boolean;
2702
+ setHovered(hovered: boolean): void;
2703
+ priceAt(paneY: number): number | null;
2704
+ beginDrag(): void;
2705
+ dragTo(price: number): void;
2706
+ commitDrag(): void;
2707
+ cancelDrag(): void;
2708
+ click(): void;
2709
+ }
2361
2710
  /** Structure describing a crosshair line (vertical or horizontal) */
2362
2711
  export interface CrosshairLineOptions {
2363
2712
  /**
@@ -2478,6 +2827,18 @@ export interface CustomStyleOptions {
2478
2827
  */
2479
2828
  color: string;
2480
2829
  }
2830
+ /**
2831
+ * Pointer position captured when a drag gesture starts. Whole-object moves are
2832
+ * computed as an offset from this anchor, so the object keeps its position
2833
+ * relative to the cursor instead of snapping one of its points under it.
2834
+ *
2835
+ * `time` is null when the gesture starts past the last bar, where the time scale
2836
+ * has no value to report; in that case the object only moves vertically.
2837
+ */
2838
+ export interface DragAnchor {
2839
+ time: Time | null;
2840
+ price: number;
2841
+ }
2481
2842
  export interface DraggablePriceLineOptions {
2482
2843
  price: number;
2483
2844
  color: string;
@@ -2486,13 +2847,14 @@ export interface DraggablePriceLineOptions {
2486
2847
  title?: string;
2487
2848
  axisLabelVisible?: boolean;
2488
2849
  draggable?: boolean;
2850
+ /** Colour applied while the pointer is over the line. */
2851
+ hoverColor?: string;
2489
2852
  onDragStart?: (price: number) => void;
2490
2853
  onDragMove?: (price: number) => void;
2491
2854
  onDragEnd?: (price: number) => void;
2492
2855
  /**
2493
- * Fires when the user clicks the line without dragging it.
2494
- * Triggered on mouseup if the mouse moved less than CLICK_TOLERANCE_PX
2495
- * from the initial mousedown position. Works regardless of `draggable`.
2856
+ * Fires when the user clicks the line without dragging it. Works regardless
2857
+ * of `draggable`.
2496
2858
  */
2497
2859
  onClick?: (price: number) => void;
2498
2860
  /**
@@ -2507,6 +2869,16 @@ export interface DraggablePriceLineOptions {
2507
2869
  */
2508
2870
  formatTitle?: (price: number) => string;
2509
2871
  }
2872
+ /**
2873
+ * Where a tool sits on screen, in pixels relative to the chart element, so a
2874
+ * floating UI can be anchored to it.
2875
+ */
2876
+ export interface DrawingBounds {
2877
+ left: number;
2878
+ top: number;
2879
+ right: number;
2880
+ bottom: number;
2881
+ }
2510
2882
  /**
2511
2883
  * Context passed to drawing tools
2512
2884
  */
@@ -2514,6 +2886,11 @@ export interface DrawingContext {
2514
2886
  chart: IChartApi;
2515
2887
  series: ISeriesApi<SeriesType>;
2516
2888
  }
2889
+ /** Payload of a selection change. Null id means nothing is selected. */
2890
+ export interface DrawingSelection {
2891
+ id: string | null;
2892
+ bounds: DrawingBounds | null;
2893
+ }
2517
2894
  /**
2518
2895
  * Base options for all drawing tools
2519
2896
  */
@@ -2543,6 +2920,8 @@ export interface DrawingUtils {
2543
2920
  readonly setLineStyle: (ctx: CanvasRenderingContext2D, lineStyle: LineStyle) => void;
2544
2921
  }
2545
2922
  export interface EMAOptions {
2923
+ /** Pane the indicator is drawn in. Defaults to its historical value. */
2924
+ paneIndex?: number;
2546
2925
  period?: number;
2547
2926
  color?: string;
2548
2927
  }
@@ -4726,6 +5105,8 @@ export interface LocalizationOptionsBase {
4726
5105
  tickmarksPercentageFormatter?: TickmarksPercentageFormatterFn;
4727
5106
  }
4728
5107
  export interface MACDOptions {
5108
+ /** Pane the indicator is drawn in. Defaults to its historical value. */
5109
+ paneIndex?: number;
4729
5110
  fastPeriod?: number;
4730
5111
  slowPeriod?: number;
4731
5112
  signalPeriod?: number;
@@ -4778,6 +5159,8 @@ export interface MouseEventParams<HorzScaleItem = Time> {
4778
5159
  sourceEvent?: TouchMouseEventData;
4779
5160
  }
4780
5161
  export interface OBVOptions {
5162
+ /** Pane the indicator is drawn in. Defaults to its historical value. */
5163
+ paneIndex?: number;
4781
5164
  color?: string;
4782
5165
  data?: any[];
4783
5166
  }
@@ -5238,6 +5621,8 @@ export interface PrimitiveHoveredItem {
5238
5621
  isBackground?: boolean;
5239
5622
  }
5240
5623
  export interface RSIOptions {
5624
+ /** Pane the indicator is drawn in. Defaults to its historical value. */
5625
+ paneIndex?: number;
5241
5626
  period?: number;
5242
5627
  color?: string;
5243
5628
  }
@@ -5293,6 +5678,8 @@ export interface RulerToolOptions extends DrawingToolOptions {
5293
5678
  onRemove?: () => void;
5294
5679
  }
5295
5680
  export interface SMAOptions {
5681
+ /** Pane the indicator is drawn in. Defaults to its historical value. */
5682
+ paneIndex?: number;
5296
5683
  period?: number;
5297
5684
  color?: string;
5298
5685
  lineWidth?: number;
@@ -5302,7 +5689,13 @@ export interface SMAOptions {
5302
5689
  * with everything needed to recreate a tool.
5303
5690
  */
5304
5691
  export interface SerializedDrawingTool {
5692
+ /** Identity of the tool, so it survives a save and restore. */
5693
+ id?: string;
5305
5694
  type: string;
5695
+ /** Hidden tools used to come back visible. */
5696
+ visible?: boolean;
5697
+ /** Locked tools used to come back unlocked. */
5698
+ locked?: boolean;
5306
5699
  points: Array<{
5307
5700
  price: number;
5308
5701
  time: Time | null;
@@ -5758,6 +6151,8 @@ export interface SolidColor {
5758
6151
  color: string;
5759
6152
  }
5760
6153
  export interface StochasticOptions {
6154
+ /** Pane the indicator is drawn in. Defaults to its historical value. */
6155
+ paneIndex?: number;
5761
6156
  kPeriod?: number;
5762
6157
  dPeriod?: number;
5763
6158
  colorK?: string;
@@ -6118,6 +6513,8 @@ export interface VerticalLineToolOptions extends DrawingToolOptions {
6118
6513
  onRemove?: () => void;
6119
6514
  }
6120
6515
  export interface VolumeOptions {
6516
+ /** Pane the indicator is drawn in. Defaults to its historical value. */
6517
+ paneIndex?: number;
6121
6518
  colorUp?: string;
6122
6519
  colorDown?: string;
6123
6520
  }
@@ -6141,6 +6538,8 @@ export interface VolumeProfileOptions {
6141
6538
  position?: "left" | "right";
6142
6539
  }
6143
6540
  export interface WMAOptions {
6541
+ /** Pane the indicator is drawn in. Defaults to its historical value. */
6542
+ paneIndex?: number;
6144
6543
  period?: number;
6145
6544
  color?: string;
6146
6545
  }
@@ -6324,6 +6723,11 @@ export type DataItem<HorzScaleItem> = SeriesDataItemTypeMap<HorzScaleItem>[Serie
6324
6723
  export type DeepPartial<T> = {
6325
6724
  [P in keyof T]?: T[P] extends (infer U)[] ? DeepPartial<U>[] : T[P] extends readonly (infer X)[] ? readonly DeepPartial<X>[] : DeepPartial<T[P]>;
6326
6725
  };
6726
+ /**
6727
+ * A grabbable part of a tool: a named handle ('point1', 'body', 'tp'…) or an
6728
+ * index, as the arrow and gantt tools report.
6729
+ */
6730
+ export type DrawingPart = string | number;
6327
6731
  export type DrawingToolType = "ruler" | "fibonacci" | "position" | "trendline" | "rectangle";
6328
6732
  /**
6329
6733
  * Green component of the RGB color value