acttrader-charts 1.0.20 → 1.0.21
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/{MACD-BDbBplVs.d.cts → MACD-DGFPNwy9.d.cts} +21 -0
- package/dist/{MACD-BDbBplVs.d.ts → MACD-DGFPNwy9.d.ts} +21 -0
- package/dist/index.cjs +381 -139
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +103 -5
- package/dist/index.d.ts +103 -5
- package/dist/index.js +381 -139
- package/dist/index.js.map +1 -1
- package/dist/indicators/index.d.cts +2 -2
- package/dist/indicators/index.d.ts +2 -2
- package/dist/webview/chart.html +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ChartConfig, O as OHLCVBar, I as IIndicator, a as ChartEventMap, T as Timeframe, S as SeriesType, b as ChartState, D as DrawingToolType, c as IDrawing, d as IWebSocketAdapter, e as TradeLevelType, A as AnyLevel, f as DrawingPoint, g as ScaleManager, V as Viewport, P as PriceRange$1, h as DrawingHandle, i as SerializedDrawing, j as Tick, k as StreamStatus } from './MACD-
|
|
2
|
-
export { l as ActiveIndicatorState, B as BollingerBands, m as BottomBarColors, n as BottomBarLabels, o as BottomBarUiConfig, p as CanvasColorSettings, q as ChartLabels, r as ChartMiscLabels, s as ChartTheme, t as ChartThemeUi, u as CrosshairPosition, v as CrosshairUiConfig, w as DARK_THEME, x as DEFAULT_BOTTOM_BAR_CONFIG, y as DEFAULT_CROSSHAIR_CONFIG, z as DEFAULT_DRAWING_TOOLBAR_CONFIG, E as DEFAULT_INDICATOR_OVERLAY_CONFIG, F as DEFAULT_LABELS, G as DEFAULT_PRICE_AXIS_CONFIG, H as DEFAULT_TIME_AXIS_CONFIG, J as DEFAULT_TOP_BAR_CONFIG, K as DEFAULT_TRADE_BUTTON_CONFIG, L as DEFAULT_UI_CONFIG, M as DataLoaderParams, N as DeepPartial, Q as DeepPartialChartTheme, R as DialogLabels, U as DrawingToolbarColors, W as DrawingToolbarLabels, X as DrawingToolbarUiConfig, Y as Duration, Z as EMA, _ as IndicatorOverlayColors, $ as IndicatorOverlayUiConfig, a0 as IndicatorParams, a1 as IndicatorResult, a2 as IndicatorStateEntry, a3 as LIGHT_THEME, a4 as MACD, a5 as OhlcLabels, a6 as OrderSubmit, a7 as Padding, a8 as PendingOrderLevel, a9 as PositionLevel, aa as PositionRenderStyle, ab as PriceAxisUiConfig, ac as RSI, ad as SMA, ae as Theme, af as ThemeOverrides, ag as TimeAxisUiConfig, ah as TopBarColors, ai as TopBarLabels, aj as TopBarUiConfig, ak as TradeButtonUiConfig, al as TradeDisplayFilter, am as TradeLabels, an as TradeLevel, ao as TradeLevelColors, ap as TradePanelColors, aq as UiConfig, ar as deepMergeTheme, as as resolveCssVarsInTheme, at as resolveLabels, au as resolveUiConfig } from './MACD-
|
|
1
|
+
import { C as ChartConfig, O as OHLCVBar, I as IIndicator, a as ChartEventMap, T as Timeframe, S as SeriesType, b as ChartState, D as DrawingToolType, c as IDrawing, d as IWebSocketAdapter, e as TradeLevelType, A as AnyLevel, f as DrawingPoint, g as ScaleManager, V as Viewport, P as PriceRange$1, h as DrawingHandle, i as SerializedDrawing, j as Tick, k as StreamStatus } from './MACD-DGFPNwy9.cjs';
|
|
2
|
+
export { l as ActiveIndicatorState, B as BollingerBands, m as BottomBarColors, n as BottomBarLabels, o as BottomBarUiConfig, p as CanvasColorSettings, q as ChartLabels, r as ChartMiscLabels, s as ChartTheme, t as ChartThemeUi, u as CrosshairPosition, v as CrosshairUiConfig, w as DARK_THEME, x as DEFAULT_BOTTOM_BAR_CONFIG, y as DEFAULT_CROSSHAIR_CONFIG, z as DEFAULT_DRAWING_TOOLBAR_CONFIG, E as DEFAULT_INDICATOR_OVERLAY_CONFIG, F as DEFAULT_LABELS, G as DEFAULT_PRICE_AXIS_CONFIG, H as DEFAULT_TIME_AXIS_CONFIG, J as DEFAULT_TOP_BAR_CONFIG, K as DEFAULT_TRADE_BUTTON_CONFIG, L as DEFAULT_UI_CONFIG, M as DataLoaderParams, N as DeepPartial, Q as DeepPartialChartTheme, R as DialogLabels, U as DrawingToolbarColors, W as DrawingToolbarLabels, X as DrawingToolbarUiConfig, Y as Duration, Z as EMA, _ as IndicatorOverlayColors, $ as IndicatorOverlayUiConfig, a0 as IndicatorParams, a1 as IndicatorResult, a2 as IndicatorStateEntry, a3 as LIGHT_THEME, a4 as MACD, a5 as OhlcLabels, a6 as OrderSubmit, a7 as Padding, a8 as PendingOrderLevel, a9 as PositionLevel, aa as PositionRenderStyle, ab as PriceAxisUiConfig, ac as RSI, ad as SMA, ae as Theme, af as ThemeOverrides, ag as TimeAxisUiConfig, ah as TopBarColors, ai as TopBarLabels, aj as TopBarUiConfig, ak as TradeButtonUiConfig, al as TradeDisplayFilter, am as TradeLabels, an as TradeLevel, ao as TradeLevelColors, ap as TradePanelColors, aq as UiConfig, ar as deepMergeTheme, as as resolveCssVarsInTheme, at as resolveLabels, au as resolveUiConfig } from './MACD-DGFPNwy9.cjs';
|
|
3
3
|
|
|
4
4
|
declare class ChartEngine {
|
|
5
5
|
private wrapper;
|
|
@@ -82,6 +82,13 @@ declare class ChartEngine {
|
|
|
82
82
|
/** Pending resize — committed only after mouse moves past DRAW_GESTURE_THRESHOLD. */
|
|
83
83
|
private _pendingDrawResize;
|
|
84
84
|
private static readonly DRAW_GESTURE_THRESHOLD;
|
|
85
|
+
/**
|
|
86
|
+
* Pending trade-level drag — committed only after mouse moves past TRADE_DRAG_PIXEL_THRESHOLD.
|
|
87
|
+
* A mouseup before the threshold means it was a click: route to _openTradeLevelEditForm instead
|
|
88
|
+
* of finishing a zero-delta drag (which would otherwise stage a spurious pending change).
|
|
89
|
+
*/
|
|
90
|
+
private _pendingTradeDrag;
|
|
91
|
+
private static readonly TRADE_DRAG_PIXEL_THRESHOLD;
|
|
85
92
|
private paneHeightOverrides;
|
|
86
93
|
private separatorDrag;
|
|
87
94
|
private readonly priceAxisWidth;
|
|
@@ -90,6 +97,24 @@ declare class ChartEngine {
|
|
|
90
97
|
private pricePanOffset;
|
|
91
98
|
private _displayedPriceRange;
|
|
92
99
|
private _lockedAutoFitBase;
|
|
100
|
+
/**
|
|
101
|
+
* When setState() restores a persisted viewport but data isn't loaded yet,
|
|
102
|
+
* we stash the desired time window here and apply it from loadData() once
|
|
103
|
+
* bars are available. Cleared after one application.
|
|
104
|
+
*/
|
|
105
|
+
private _pendingViewportRestore;
|
|
106
|
+
/**
|
|
107
|
+
* Debounces viewport/priceScale stateChange emissions during continuous
|
|
108
|
+
* gestures (pan, wheel-zoom, price-scale drag). Pan/zoom don't emit
|
|
109
|
+
* stateChange directly because doing so per-frame would be wasteful; this
|
|
110
|
+
* timer coalesces bursts so the persisted viewport catches up a few ms
|
|
111
|
+
* after the user stops interacting. Paired with the consumer's own
|
|
112
|
+
* debounce (e.g. CRM's 800ms save) for minimal traffic.
|
|
113
|
+
*/
|
|
114
|
+
private _viewportPersistTimer;
|
|
115
|
+
/** Schedules a stateChange emission so viewport/priceScale changes made by
|
|
116
|
+
* pan/zoom/price-scale drag reach persistence. Coalesces rapid calls. */
|
|
117
|
+
private scheduleViewportPersist;
|
|
93
118
|
private axisDrag;
|
|
94
119
|
private subPaneScaleFactors;
|
|
95
120
|
private _mobileCrosshairActive;
|
|
@@ -288,17 +313,63 @@ declare class ChartEngine {
|
|
|
288
313
|
* Includes timeframe, chart type, active indicators (with params), and drawings.
|
|
289
314
|
*/
|
|
290
315
|
getState(): ChartState;
|
|
316
|
+
/**
|
|
317
|
+
* Captures the current viewport as a {startTime, endTime} timestamp pair,
|
|
318
|
+
* preserving sub-bar fractional position. Returns undefined only when no
|
|
319
|
+
* bars are loaded (viewport has no meaningful time anchor).
|
|
320
|
+
*/
|
|
321
|
+
private getViewportTimestamps;
|
|
322
|
+
/**
|
|
323
|
+
* Restores the viewport from a timestamp pair, converting each edge back
|
|
324
|
+
* into a fractional bar index relative to the current dataStore. Callers
|
|
325
|
+
* must ensure bars are loaded before invoking.
|
|
326
|
+
*/
|
|
327
|
+
private applyViewportFromTimestamps;
|
|
291
328
|
/**
|
|
292
329
|
* Restores chart configuration from a previously captured `ChartState`.
|
|
293
330
|
* Call this after construction to hydrate a chart from persisted state.
|
|
294
331
|
*/
|
|
295
332
|
setState(state: ChartState): this;
|
|
296
333
|
/**
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
334
|
+
* Converts a fractional barIndex into an absolute unix-ms timestamp by
|
|
335
|
+
* interpolating across the containing bar. Extrapolates linearly for indexes
|
|
336
|
+
* outside [0, bars.length-1] using the adjacent bar's width.
|
|
337
|
+
*
|
|
338
|
+
* This is the inverse of `timestampToBarIndex` and the authoritative way to
|
|
339
|
+
* capture "where in time" a drawing point sits at placement, drag, or resize.
|
|
340
|
+
* Returns undefined only when no bars are loaded.
|
|
341
|
+
*/
|
|
342
|
+
private barIndexToTimestamp;
|
|
343
|
+
/**
|
|
344
|
+
* Converts a unix-ms timestamp into a fractional barIndex using floor-bar
|
|
345
|
+
* containment: the result is `floorBar + (ts - floorBar.time) / (nextBar.time - floorBar.time)`.
|
|
346
|
+
* Extrapolates linearly for timestamps outside the loaded range using the edge
|
|
347
|
+
* bar width, so drawings outside the visible data still render at the correct
|
|
348
|
+
* relative offset rather than snapping to an edge.
|
|
349
|
+
*
|
|
350
|
+
* Matches TradingView's floor-bar semantics and preserves sub-bar time
|
|
351
|
+
* precision across timeframe changes.
|
|
352
|
+
*/
|
|
353
|
+
private timestampToBarIndex;
|
|
354
|
+
/**
|
|
355
|
+
* Re-anchors all loaded drawings to the current dataset. For points with a
|
|
356
|
+
* stored timestamp, barIndex is recomputed via `timestampToBarIndex`; for
|
|
357
|
+
* points missing a timestamp (legacy saves or freshly placed points whose
|
|
358
|
+
* timestamp capture was skipped), the timestamp is backfilled from the
|
|
359
|
+
* current barIndex so subsequent data reloads remain accurate.
|
|
360
|
+
*
|
|
361
|
+
* Called after loadData(), prependData(), and whenever the underlying bars
|
|
362
|
+
* change such that cached barIndex values would otherwise drift.
|
|
300
363
|
*/
|
|
301
364
|
private reanchorDrawingsByTimestamp;
|
|
365
|
+
/**
|
|
366
|
+
* Captures a timestamp on any drawing point that is missing one, using the
|
|
367
|
+
* current bars. Call this BEFORE mutating `dataStore.all` (insert/splice)
|
|
368
|
+
* so that points still pointing at a stale barIndex get frozen to the
|
|
369
|
+
* correct time before the mutation invalidates the index. Safe no-op for
|
|
370
|
+
* points that already have a timestamp.
|
|
371
|
+
*/
|
|
372
|
+
private backfillDrawingTimestamps;
|
|
302
373
|
/**
|
|
303
374
|
* Resets all chart settings that are captured by `getState()` back to their
|
|
304
375
|
* defaults (candlestick / dark / 1D / 1Y / volume on / no indicators / no drawings)
|
|
@@ -543,10 +614,29 @@ declare class ChartEngine {
|
|
|
543
614
|
private onMouseLeave;
|
|
544
615
|
private onMouseUp;
|
|
545
616
|
private touchToDrawingPoint;
|
|
617
|
+
/**
|
|
618
|
+
* Builds a fully-populated DrawingPoint from raw float coordinates. Captures
|
|
619
|
+
* the absolute timestamp at this fractional barIndex so the anchor survives
|
|
620
|
+
* timeframe changes, data reloads, and serialization round-trips.
|
|
621
|
+
*/
|
|
622
|
+
private makeDrawingPoint;
|
|
546
623
|
/** Shared close-button handler used by both mouse click and touch tap. */
|
|
547
624
|
private _handleTradeLevelClose;
|
|
548
625
|
/** Activates the mobile crosshair at canvas coords (x, y). */
|
|
549
626
|
private _activateMobileCrosshair;
|
|
627
|
+
/**
|
|
628
|
+
* Closes the edit form, clears selection, and emits `tradeLevelEditCancelled` when
|
|
629
|
+
* the edit form was actually open for this label. Shared between click-outside,
|
|
630
|
+
* repeat-click toggle, and the ✗ button so all exit paths produce the same payload.
|
|
631
|
+
*/
|
|
632
|
+
private _cancelEditAndDeselect;
|
|
633
|
+
/**
|
|
634
|
+
* Opens the external edit form for a trade level by emitting `tradeLevelEditOpen`.
|
|
635
|
+
* Shared between pencil click, bare box click, and drag start so every entry
|
|
636
|
+
* point fires the same payload. No-op when the form is already open for this
|
|
637
|
+
* label, so repeat opens (e.g. pencil click followed by drag) don't spam the event.
|
|
638
|
+
*/
|
|
639
|
+
private _openTradeLevelEditForm;
|
|
550
640
|
/** Shared helper: initiate a trade level main-line drag from a hit area. */
|
|
551
641
|
private _startTradeDragFromHit;
|
|
552
642
|
/** Shared helper: initiate a +SL/+TP add-bracket drag from a hit area. */
|
|
@@ -665,6 +755,14 @@ declare class DrawingManager {
|
|
|
665
755
|
onDrawingsChange: (() => void) | null;
|
|
666
756
|
/** Called when a text-type drawing is first completed — ChartEngine shows the text input. */
|
|
667
757
|
onStartTextEdit: ((drawing: IDrawing) => void) | null;
|
|
758
|
+
/**
|
|
759
|
+
* Called after drag/resize mutates a drawing's points so ChartEngine can
|
|
760
|
+
* refresh each point's `timestamp` from the current dataStore. Required
|
|
761
|
+
* because DrawingManager has no access to the data layer, and drag
|
|
762
|
+
* reconstructs points from raw (barIndex, price) deltas that strip the
|
|
763
|
+
* original point's timestamp.
|
|
764
|
+
*/
|
|
765
|
+
onPointsMutated: ((drawing: IDrawing) => void) | null;
|
|
668
766
|
/** Set to true by ChartEngine while the text input is focused — prevents Delete/Backspace from deleting the drawing. */
|
|
669
767
|
private editingText;
|
|
670
768
|
private dragDrawing;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ChartConfig, O as OHLCVBar, I as IIndicator, a as ChartEventMap, T as Timeframe, S as SeriesType, b as ChartState, D as DrawingToolType, c as IDrawing, d as IWebSocketAdapter, e as TradeLevelType, A as AnyLevel, f as DrawingPoint, g as ScaleManager, V as Viewport, P as PriceRange$1, h as DrawingHandle, i as SerializedDrawing, j as Tick, k as StreamStatus } from './MACD-
|
|
2
|
-
export { l as ActiveIndicatorState, B as BollingerBands, m as BottomBarColors, n as BottomBarLabels, o as BottomBarUiConfig, p as CanvasColorSettings, q as ChartLabels, r as ChartMiscLabels, s as ChartTheme, t as ChartThemeUi, u as CrosshairPosition, v as CrosshairUiConfig, w as DARK_THEME, x as DEFAULT_BOTTOM_BAR_CONFIG, y as DEFAULT_CROSSHAIR_CONFIG, z as DEFAULT_DRAWING_TOOLBAR_CONFIG, E as DEFAULT_INDICATOR_OVERLAY_CONFIG, F as DEFAULT_LABELS, G as DEFAULT_PRICE_AXIS_CONFIG, H as DEFAULT_TIME_AXIS_CONFIG, J as DEFAULT_TOP_BAR_CONFIG, K as DEFAULT_TRADE_BUTTON_CONFIG, L as DEFAULT_UI_CONFIG, M as DataLoaderParams, N as DeepPartial, Q as DeepPartialChartTheme, R as DialogLabels, U as DrawingToolbarColors, W as DrawingToolbarLabels, X as DrawingToolbarUiConfig, Y as Duration, Z as EMA, _ as IndicatorOverlayColors, $ as IndicatorOverlayUiConfig, a0 as IndicatorParams, a1 as IndicatorResult, a2 as IndicatorStateEntry, a3 as LIGHT_THEME, a4 as MACD, a5 as OhlcLabels, a6 as OrderSubmit, a7 as Padding, a8 as PendingOrderLevel, a9 as PositionLevel, aa as PositionRenderStyle, ab as PriceAxisUiConfig, ac as RSI, ad as SMA, ae as Theme, af as ThemeOverrides, ag as TimeAxisUiConfig, ah as TopBarColors, ai as TopBarLabels, aj as TopBarUiConfig, ak as TradeButtonUiConfig, al as TradeDisplayFilter, am as TradeLabels, an as TradeLevel, ao as TradeLevelColors, ap as TradePanelColors, aq as UiConfig, ar as deepMergeTheme, as as resolveCssVarsInTheme, at as resolveLabels, au as resolveUiConfig } from './MACD-
|
|
1
|
+
import { C as ChartConfig, O as OHLCVBar, I as IIndicator, a as ChartEventMap, T as Timeframe, S as SeriesType, b as ChartState, D as DrawingToolType, c as IDrawing, d as IWebSocketAdapter, e as TradeLevelType, A as AnyLevel, f as DrawingPoint, g as ScaleManager, V as Viewport, P as PriceRange$1, h as DrawingHandle, i as SerializedDrawing, j as Tick, k as StreamStatus } from './MACD-DGFPNwy9.js';
|
|
2
|
+
export { l as ActiveIndicatorState, B as BollingerBands, m as BottomBarColors, n as BottomBarLabels, o as BottomBarUiConfig, p as CanvasColorSettings, q as ChartLabels, r as ChartMiscLabels, s as ChartTheme, t as ChartThemeUi, u as CrosshairPosition, v as CrosshairUiConfig, w as DARK_THEME, x as DEFAULT_BOTTOM_BAR_CONFIG, y as DEFAULT_CROSSHAIR_CONFIG, z as DEFAULT_DRAWING_TOOLBAR_CONFIG, E as DEFAULT_INDICATOR_OVERLAY_CONFIG, F as DEFAULT_LABELS, G as DEFAULT_PRICE_AXIS_CONFIG, H as DEFAULT_TIME_AXIS_CONFIG, J as DEFAULT_TOP_BAR_CONFIG, K as DEFAULT_TRADE_BUTTON_CONFIG, L as DEFAULT_UI_CONFIG, M as DataLoaderParams, N as DeepPartial, Q as DeepPartialChartTheme, R as DialogLabels, U as DrawingToolbarColors, W as DrawingToolbarLabels, X as DrawingToolbarUiConfig, Y as Duration, Z as EMA, _ as IndicatorOverlayColors, $ as IndicatorOverlayUiConfig, a0 as IndicatorParams, a1 as IndicatorResult, a2 as IndicatorStateEntry, a3 as LIGHT_THEME, a4 as MACD, a5 as OhlcLabels, a6 as OrderSubmit, a7 as Padding, a8 as PendingOrderLevel, a9 as PositionLevel, aa as PositionRenderStyle, ab as PriceAxisUiConfig, ac as RSI, ad as SMA, ae as Theme, af as ThemeOverrides, ag as TimeAxisUiConfig, ah as TopBarColors, ai as TopBarLabels, aj as TopBarUiConfig, ak as TradeButtonUiConfig, al as TradeDisplayFilter, am as TradeLabels, an as TradeLevel, ao as TradeLevelColors, ap as TradePanelColors, aq as UiConfig, ar as deepMergeTheme, as as resolveCssVarsInTheme, at as resolveLabels, au as resolveUiConfig } from './MACD-DGFPNwy9.js';
|
|
3
3
|
|
|
4
4
|
declare class ChartEngine {
|
|
5
5
|
private wrapper;
|
|
@@ -82,6 +82,13 @@ declare class ChartEngine {
|
|
|
82
82
|
/** Pending resize — committed only after mouse moves past DRAW_GESTURE_THRESHOLD. */
|
|
83
83
|
private _pendingDrawResize;
|
|
84
84
|
private static readonly DRAW_GESTURE_THRESHOLD;
|
|
85
|
+
/**
|
|
86
|
+
* Pending trade-level drag — committed only after mouse moves past TRADE_DRAG_PIXEL_THRESHOLD.
|
|
87
|
+
* A mouseup before the threshold means it was a click: route to _openTradeLevelEditForm instead
|
|
88
|
+
* of finishing a zero-delta drag (which would otherwise stage a spurious pending change).
|
|
89
|
+
*/
|
|
90
|
+
private _pendingTradeDrag;
|
|
91
|
+
private static readonly TRADE_DRAG_PIXEL_THRESHOLD;
|
|
85
92
|
private paneHeightOverrides;
|
|
86
93
|
private separatorDrag;
|
|
87
94
|
private readonly priceAxisWidth;
|
|
@@ -90,6 +97,24 @@ declare class ChartEngine {
|
|
|
90
97
|
private pricePanOffset;
|
|
91
98
|
private _displayedPriceRange;
|
|
92
99
|
private _lockedAutoFitBase;
|
|
100
|
+
/**
|
|
101
|
+
* When setState() restores a persisted viewport but data isn't loaded yet,
|
|
102
|
+
* we stash the desired time window here and apply it from loadData() once
|
|
103
|
+
* bars are available. Cleared after one application.
|
|
104
|
+
*/
|
|
105
|
+
private _pendingViewportRestore;
|
|
106
|
+
/**
|
|
107
|
+
* Debounces viewport/priceScale stateChange emissions during continuous
|
|
108
|
+
* gestures (pan, wheel-zoom, price-scale drag). Pan/zoom don't emit
|
|
109
|
+
* stateChange directly because doing so per-frame would be wasteful; this
|
|
110
|
+
* timer coalesces bursts so the persisted viewport catches up a few ms
|
|
111
|
+
* after the user stops interacting. Paired with the consumer's own
|
|
112
|
+
* debounce (e.g. CRM's 800ms save) for minimal traffic.
|
|
113
|
+
*/
|
|
114
|
+
private _viewportPersistTimer;
|
|
115
|
+
/** Schedules a stateChange emission so viewport/priceScale changes made by
|
|
116
|
+
* pan/zoom/price-scale drag reach persistence. Coalesces rapid calls. */
|
|
117
|
+
private scheduleViewportPersist;
|
|
93
118
|
private axisDrag;
|
|
94
119
|
private subPaneScaleFactors;
|
|
95
120
|
private _mobileCrosshairActive;
|
|
@@ -288,17 +313,63 @@ declare class ChartEngine {
|
|
|
288
313
|
* Includes timeframe, chart type, active indicators (with params), and drawings.
|
|
289
314
|
*/
|
|
290
315
|
getState(): ChartState;
|
|
316
|
+
/**
|
|
317
|
+
* Captures the current viewport as a {startTime, endTime} timestamp pair,
|
|
318
|
+
* preserving sub-bar fractional position. Returns undefined only when no
|
|
319
|
+
* bars are loaded (viewport has no meaningful time anchor).
|
|
320
|
+
*/
|
|
321
|
+
private getViewportTimestamps;
|
|
322
|
+
/**
|
|
323
|
+
* Restores the viewport from a timestamp pair, converting each edge back
|
|
324
|
+
* into a fractional bar index relative to the current dataStore. Callers
|
|
325
|
+
* must ensure bars are loaded before invoking.
|
|
326
|
+
*/
|
|
327
|
+
private applyViewportFromTimestamps;
|
|
291
328
|
/**
|
|
292
329
|
* Restores chart configuration from a previously captured `ChartState`.
|
|
293
330
|
* Call this after construction to hydrate a chart from persisted state.
|
|
294
331
|
*/
|
|
295
332
|
setState(state: ChartState): this;
|
|
296
333
|
/**
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
334
|
+
* Converts a fractional barIndex into an absolute unix-ms timestamp by
|
|
335
|
+
* interpolating across the containing bar. Extrapolates linearly for indexes
|
|
336
|
+
* outside [0, bars.length-1] using the adjacent bar's width.
|
|
337
|
+
*
|
|
338
|
+
* This is the inverse of `timestampToBarIndex` and the authoritative way to
|
|
339
|
+
* capture "where in time" a drawing point sits at placement, drag, or resize.
|
|
340
|
+
* Returns undefined only when no bars are loaded.
|
|
341
|
+
*/
|
|
342
|
+
private barIndexToTimestamp;
|
|
343
|
+
/**
|
|
344
|
+
* Converts a unix-ms timestamp into a fractional barIndex using floor-bar
|
|
345
|
+
* containment: the result is `floorBar + (ts - floorBar.time) / (nextBar.time - floorBar.time)`.
|
|
346
|
+
* Extrapolates linearly for timestamps outside the loaded range using the edge
|
|
347
|
+
* bar width, so drawings outside the visible data still render at the correct
|
|
348
|
+
* relative offset rather than snapping to an edge.
|
|
349
|
+
*
|
|
350
|
+
* Matches TradingView's floor-bar semantics and preserves sub-bar time
|
|
351
|
+
* precision across timeframe changes.
|
|
352
|
+
*/
|
|
353
|
+
private timestampToBarIndex;
|
|
354
|
+
/**
|
|
355
|
+
* Re-anchors all loaded drawings to the current dataset. For points with a
|
|
356
|
+
* stored timestamp, barIndex is recomputed via `timestampToBarIndex`; for
|
|
357
|
+
* points missing a timestamp (legacy saves or freshly placed points whose
|
|
358
|
+
* timestamp capture was skipped), the timestamp is backfilled from the
|
|
359
|
+
* current barIndex so subsequent data reloads remain accurate.
|
|
360
|
+
*
|
|
361
|
+
* Called after loadData(), prependData(), and whenever the underlying bars
|
|
362
|
+
* change such that cached barIndex values would otherwise drift.
|
|
300
363
|
*/
|
|
301
364
|
private reanchorDrawingsByTimestamp;
|
|
365
|
+
/**
|
|
366
|
+
* Captures a timestamp on any drawing point that is missing one, using the
|
|
367
|
+
* current bars. Call this BEFORE mutating `dataStore.all` (insert/splice)
|
|
368
|
+
* so that points still pointing at a stale barIndex get frozen to the
|
|
369
|
+
* correct time before the mutation invalidates the index. Safe no-op for
|
|
370
|
+
* points that already have a timestamp.
|
|
371
|
+
*/
|
|
372
|
+
private backfillDrawingTimestamps;
|
|
302
373
|
/**
|
|
303
374
|
* Resets all chart settings that are captured by `getState()` back to their
|
|
304
375
|
* defaults (candlestick / dark / 1D / 1Y / volume on / no indicators / no drawings)
|
|
@@ -543,10 +614,29 @@ declare class ChartEngine {
|
|
|
543
614
|
private onMouseLeave;
|
|
544
615
|
private onMouseUp;
|
|
545
616
|
private touchToDrawingPoint;
|
|
617
|
+
/**
|
|
618
|
+
* Builds a fully-populated DrawingPoint from raw float coordinates. Captures
|
|
619
|
+
* the absolute timestamp at this fractional barIndex so the anchor survives
|
|
620
|
+
* timeframe changes, data reloads, and serialization round-trips.
|
|
621
|
+
*/
|
|
622
|
+
private makeDrawingPoint;
|
|
546
623
|
/** Shared close-button handler used by both mouse click and touch tap. */
|
|
547
624
|
private _handleTradeLevelClose;
|
|
548
625
|
/** Activates the mobile crosshair at canvas coords (x, y). */
|
|
549
626
|
private _activateMobileCrosshair;
|
|
627
|
+
/**
|
|
628
|
+
* Closes the edit form, clears selection, and emits `tradeLevelEditCancelled` when
|
|
629
|
+
* the edit form was actually open for this label. Shared between click-outside,
|
|
630
|
+
* repeat-click toggle, and the ✗ button so all exit paths produce the same payload.
|
|
631
|
+
*/
|
|
632
|
+
private _cancelEditAndDeselect;
|
|
633
|
+
/**
|
|
634
|
+
* Opens the external edit form for a trade level by emitting `tradeLevelEditOpen`.
|
|
635
|
+
* Shared between pencil click, bare box click, and drag start so every entry
|
|
636
|
+
* point fires the same payload. No-op when the form is already open for this
|
|
637
|
+
* label, so repeat opens (e.g. pencil click followed by drag) don't spam the event.
|
|
638
|
+
*/
|
|
639
|
+
private _openTradeLevelEditForm;
|
|
550
640
|
/** Shared helper: initiate a trade level main-line drag from a hit area. */
|
|
551
641
|
private _startTradeDragFromHit;
|
|
552
642
|
/** Shared helper: initiate a +SL/+TP add-bracket drag from a hit area. */
|
|
@@ -665,6 +755,14 @@ declare class DrawingManager {
|
|
|
665
755
|
onDrawingsChange: (() => void) | null;
|
|
666
756
|
/** Called when a text-type drawing is first completed — ChartEngine shows the text input. */
|
|
667
757
|
onStartTextEdit: ((drawing: IDrawing) => void) | null;
|
|
758
|
+
/**
|
|
759
|
+
* Called after drag/resize mutates a drawing's points so ChartEngine can
|
|
760
|
+
* refresh each point's `timestamp` from the current dataStore. Required
|
|
761
|
+
* because DrawingManager has no access to the data layer, and drag
|
|
762
|
+
* reconstructs points from raw (barIndex, price) deltas that strip the
|
|
763
|
+
* original point's timestamp.
|
|
764
|
+
*/
|
|
765
|
+
onPointsMutated: ((drawing: IDrawing) => void) | null;
|
|
668
766
|
/** Set to true by ChartEngine while the text input is focused — prevents Delete/Backspace from deleting the drawing. */
|
|
669
767
|
private editingText;
|
|
670
768
|
private dragDrawing;
|