@tradecanvas/chart 0.8.2 → 0.14.0
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/README.md +86 -4
- package/dist/Chart.d.ts +121 -1
- package/dist/Chart.d.ts.map +1 -1
- package/dist/{Chart-Cn_TSMO7.js → DragDropImporter-Br2ez5Gz.js} +560 -91
- package/dist/DragDropImporter-Br2ez5Gz.js.map +1 -0
- package/dist/DragDropImporter-ycI_Tcs6.cjs +2 -0
- package/dist/DragDropImporter-ycI_Tcs6.cjs.map +1 -0
- package/dist/finance/PerformanceDashboard.d.ts +43 -0
- package/dist/finance/PerformanceDashboard.d.ts.map +1 -0
- package/dist/finance/index.d.ts +4 -0
- package/dist/finance/index.d.ts.map +1 -1
- package/dist/finance/performanceData.d.ts +39 -0
- package/dist/finance/performanceData.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +287 -30
- package/dist/index.js.map +1 -1
- package/dist/io/DragDropImporter.d.ts +34 -0
- package/dist/io/DragDropImporter.d.ts.map +1 -0
- package/dist/io/index.d.ts +7 -0
- package/dist/io/index.d.ts.map +1 -0
- package/dist/io/parseOHLCV.d.ts +21 -0
- package/dist/io/parseOHLCV.d.ts.map +1 -0
- package/dist/io/resampleOHLCV.d.ts +29 -0
- package/dist/io/resampleOHLCV.d.ts.map +1 -0
- package/dist/widget/AlertNotifier.d.ts +32 -0
- package/dist/widget/AlertNotifier.d.ts.map +1 -0
- package/dist/widget/ChartWidget.d.ts +100 -2
- package/dist/widget/ChartWidget.d.ts.map +1 -1
- package/dist/widget/DrawingFavoritesStore.d.ts +22 -0
- package/dist/widget/DrawingFavoritesStore.d.ts.map +1 -0
- package/dist/widget/DrawingTemplateStore.d.ts +29 -0
- package/dist/widget/DrawingTemplateStore.d.ts.map +1 -0
- package/dist/widget/WidgetAlertsPanel.d.ts +58 -0
- package/dist/widget/WidgetAlertsPanel.d.ts.map +1 -0
- package/dist/widget/WidgetBracketBar.d.ts +21 -0
- package/dist/widget/WidgetBracketBar.d.ts.map +1 -0
- package/dist/widget/WidgetDataWindow.d.ts +41 -0
- package/dist/widget/WidgetDataWindow.d.ts.map +1 -0
- package/dist/widget/WidgetDepthLadder.d.ts +29 -0
- package/dist/widget/WidgetDepthLadder.d.ts.map +1 -0
- package/dist/widget/WidgetDrawingSidebar.d.ts +6 -0
- package/dist/widget/WidgetDrawingSidebar.d.ts.map +1 -1
- package/dist/widget/WidgetDrawingStyle.d.ts +36 -0
- package/dist/widget/WidgetDrawingStyle.d.ts.map +1 -0
- package/dist/widget/WidgetHotkeySheet.d.ts +20 -0
- package/dist/widget/WidgetHotkeySheet.d.ts.map +1 -0
- package/dist/widget/WidgetIndicatorSettings.d.ts +42 -0
- package/dist/widget/WidgetIndicatorSettings.d.ts.map +1 -0
- package/dist/widget/WidgetObjectTree.d.ts +59 -0
- package/dist/widget/WidgetObjectTree.d.ts.map +1 -0
- package/dist/widget/WidgetReplayBar.d.ts +41 -0
- package/dist/widget/WidgetReplayBar.d.ts.map +1 -0
- package/dist/widget/WidgetSettings.d.ts +1 -0
- package/dist/widget/WidgetSettings.d.ts.map +1 -1
- package/dist/widget/WidgetSymbolSearch.d.ts +34 -0
- package/dist/widget/WidgetSymbolSearch.d.ts.map +1 -0
- package/dist/widget/WidgetToolbar.d.ts.map +1 -1
- package/dist/widget/WidgetWatchlist.d.ts +39 -0
- package/dist/widget/WidgetWatchlist.d.ts.map +1 -0
- package/dist/widget/icons.d.ts.map +1 -1
- package/dist/widget/index.cjs +2372 -877
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +2455 -185
- package/dist/widget/index.js.map +1 -1
- package/dist/widget/ladderRows.d.ts +21 -0
- package/dist/widget/ladderRows.d.ts.map +1 -0
- package/dist/widget/types.d.ts +91 -1
- package/dist/widget/types.d.ts.map +1 -1
- package/dist/widget/widgetConfig.d.ts.map +1 -1
- package/dist/widget/widgetShareState.d.ts +26 -0
- package/dist/widget/widgetShareState.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/Chart-Br_N-BCL.cjs +0 -2
- package/dist/Chart-Br_N-BCL.cjs.map +0 -1
- package/dist/Chart-Cn_TSMO7.js.map +0 -1
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, computePriceLimits as s, mergeBar as c, setLocale as l, timeframeToMs as u } from "@tradecanvas/commons";
|
|
2
|
-
import {
|
|
2
|
+
import { AlertDragHandler as d, AlertManager as f, Animator as p, AreaRenderer as m, AxisDragHandler as ee, BarCountdown as te, BarRenderer as h, BaselineRenderer as ne, CandlestickRenderer as g, ChartLegend as re, ChartStateManager as _, CompareRenderer as ie, CrosshairHandler as ae, CrosshairTooltip as oe, CurrentPriceLine as se, DataExporter as v, DepthHeatmapRenderer as ce, DrawingManager as le, DrawingRenderer as ue, EquivolumeRenderer as de, EventBus as fe, GridRenderer as pe, HLCAreaRenderer as me, HollowCandleRenderer as he, IndicatorEngine as y, InteractionManager as ge, KagiRenderer as _e, KeyboardHandler as ve, LineRenderer as ye, LineWithMarkersRenderer as be, MarketProfileRenderer as xe, MeasureOverlay as Se, PanHandler as Ce, PeriodLevelsRenderer as we, PinnedTooltip as Te, PivotMarkersRenderer as b, PointAndFigureRenderer as x, PriceAxis as S, RenderEngine as C, RenkoRenderer as w, ReplayManager as T, Screenshot as E, SessionBreaks as D, SessionShading as O, SignalMarkerManager as Ee, StepLineRenderer as De, StreamManager as Oe, TimeAxis as ke, TradeZoneManager as Ae, TradingManager as je, TradingRenderer as Me, UndoRedoManager as Ne, Viewport as Pe, VolumeCandleRenderer as Fe, VolumeProfileRenderer as Ie, VolumeRenderer as Le, Watermark as Re, ZoomHandler as ze, findDominantSwing as Be, registerBuiltInDrawingTools as Ve, registerBuiltInIndicators as k, toHeikinAshi as A, toKagi as He, toLineBreak as Ue, toPointAndFigure as We, toRangeBars as Ge, toRenko as Ke, xToBarIndex as qe } from "@tradecanvas/core";
|
|
3
3
|
//#region src/charts/ChartTypeStrategy.ts
|
|
4
|
-
function
|
|
4
|
+
function Je(e) {
|
|
5
5
|
switch (e) {
|
|
6
6
|
case "candlestick":
|
|
7
7
|
case "heikinAshi":
|
|
8
8
|
case "lineBreak":
|
|
9
9
|
case "rangeBars": return new g();
|
|
10
|
-
case "line": return new
|
|
11
|
-
case "area": return new
|
|
12
|
-
case "bar": return new
|
|
13
|
-
case "hollowCandle": return new
|
|
14
|
-
case "baseline": return new
|
|
15
|
-
case "renko": return new
|
|
16
|
-
case "kagi": return new
|
|
17
|
-
case "pointAndFigure": return new
|
|
18
|
-
case "volumeCandles": return new
|
|
19
|
-
case "equivolume": return new
|
|
20
|
-
case "hlcArea": return new
|
|
21
|
-
case "stepLine": return new
|
|
22
|
-
case "lineWithMarkers": return new
|
|
10
|
+
case "line": return new ye();
|
|
11
|
+
case "area": return new m();
|
|
12
|
+
case "bar": return new h();
|
|
13
|
+
case "hollowCandle": return new he();
|
|
14
|
+
case "baseline": return new ne();
|
|
15
|
+
case "renko": return new w();
|
|
16
|
+
case "kagi": return new _e();
|
|
17
|
+
case "pointAndFigure": return new x();
|
|
18
|
+
case "volumeCandles": return new Fe();
|
|
19
|
+
case "equivolume": return new de();
|
|
20
|
+
case "hlcArea": return new me();
|
|
21
|
+
case "stepLine": return new De();
|
|
22
|
+
case "lineWithMarkers": return new be();
|
|
23
23
|
default: return new g();
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function Ye(e, t) {
|
|
27
27
|
if (t.length === 0) return t;
|
|
28
28
|
switch (e) {
|
|
29
|
-
case "heikinAshi": return
|
|
30
|
-
case "renko": return
|
|
29
|
+
case "heikinAshi": return A(t);
|
|
30
|
+
case "renko": return Ke(t, {
|
|
31
31
|
brickSize: 0,
|
|
32
32
|
useATR: !0,
|
|
33
33
|
atrPeriod: 14
|
|
34
34
|
});
|
|
35
|
-
case "lineBreak": return
|
|
36
|
-
case "kagi": return
|
|
37
|
-
case "pointAndFigure": return
|
|
38
|
-
case "rangeBars": return
|
|
35
|
+
case "lineBreak": return Ue(t, 3);
|
|
36
|
+
case "kagi": return He(t, 4);
|
|
37
|
+
case "pointAndFigure": return We(t, j(t) * .01, 3);
|
|
38
|
+
case "rangeBars": return Ge(t, { rangeSize: j(t) * .005 });
|
|
39
39
|
default: return t;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function j(e) {
|
|
43
43
|
let t = 0;
|
|
44
44
|
for (let n of e) t += n.close;
|
|
45
45
|
return t / e.length;
|
|
46
46
|
}
|
|
47
47
|
//#endregion
|
|
48
48
|
//#region src/charts/IndicatorPriceRange.ts
|
|
49
|
-
var
|
|
49
|
+
var M = {
|
|
50
50
|
min: 0,
|
|
51
51
|
max: 100
|
|
52
|
-
},
|
|
53
|
-
function
|
|
54
|
-
if (!e) return { ...
|
|
52
|
+
}, N = .1;
|
|
53
|
+
function Xe(e, t, n) {
|
|
54
|
+
if (!e) return { ...M };
|
|
55
55
|
let r = Infinity, i = -Infinity, a = 0;
|
|
56
56
|
for (let [, o] of e.values) {
|
|
57
57
|
if (a >= t && a <= n) for (let e in o) {
|
|
@@ -60,16 +60,16 @@ function Ee(e, t, n) {
|
|
|
60
60
|
}
|
|
61
61
|
a++;
|
|
62
62
|
}
|
|
63
|
-
if (r === Infinity) return { ...
|
|
63
|
+
if (r === Infinity) return { ...M };
|
|
64
64
|
let o = i - r || 1;
|
|
65
65
|
return {
|
|
66
|
-
min: r - o *
|
|
67
|
-
max: i + o *
|
|
66
|
+
min: r - o * N,
|
|
67
|
+
max: i + o * N
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
//#endregion
|
|
71
71
|
//#region src/state/AutoSaveScheduler.ts
|
|
72
|
-
var
|
|
72
|
+
var Ze = class {
|
|
73
73
|
timer = null;
|
|
74
74
|
delayMs = 0;
|
|
75
75
|
key = null;
|
|
@@ -99,12 +99,12 @@ var De = class {
|
|
|
99
99
|
};
|
|
100
100
|
//#endregion
|
|
101
101
|
//#region src/DataManager.ts
|
|
102
|
-
function
|
|
102
|
+
function P(e) {
|
|
103
103
|
if (!e || typeof e.time != "number") return !1;
|
|
104
104
|
let { open: t, high: n, low: r, close: i } = e;
|
|
105
105
|
return !(!isFinite(t) || !isFinite(n) || !isFinite(r) || !isFinite(i) || t < 0 || n < 0 || r < 0 || i < 0 || n < r || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0));
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function F(e) {
|
|
108
108
|
return {
|
|
109
109
|
...e,
|
|
110
110
|
high: Math.max(e.open, e.high, e.low, e.close),
|
|
@@ -112,20 +112,20 @@ function q(e) {
|
|
|
112
112
|
volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
var
|
|
115
|
+
var I = class {
|
|
116
116
|
data = [];
|
|
117
117
|
getData() {
|
|
118
118
|
return this.data;
|
|
119
119
|
}
|
|
120
120
|
setData(e) {
|
|
121
|
-
this.data = e.filter(
|
|
121
|
+
this.data = e.filter(P).map(F);
|
|
122
122
|
}
|
|
123
123
|
appendBar(e) {
|
|
124
|
-
|
|
124
|
+
P(e) && this.data.push(F(e));
|
|
125
125
|
}
|
|
126
126
|
updateLastBar(e) {
|
|
127
|
-
if (!
|
|
128
|
-
let t =
|
|
127
|
+
if (!P(e)) return;
|
|
128
|
+
let t = F(e);
|
|
129
129
|
if (this.data.length === 0) {
|
|
130
130
|
this.data.push(t);
|
|
131
131
|
return;
|
|
@@ -141,7 +141,7 @@ var J = class {
|
|
|
141
141
|
clear() {
|
|
142
142
|
this.data = [];
|
|
143
143
|
}
|
|
144
|
-
},
|
|
144
|
+
}, L = class {
|
|
145
145
|
theme;
|
|
146
146
|
constructor(t) {
|
|
147
147
|
!t || t === "dark" ? this.theme = { ...e } : t === "light" ? this.theme = { ...n } : this.theme = { ...t };
|
|
@@ -152,7 +152,7 @@ var J = class {
|
|
|
152
152
|
setTheme(t) {
|
|
153
153
|
t === "dark" ? this.theme = { ...e } : t === "light" ? this.theme = { ...n } : this.theme = { ...t };
|
|
154
154
|
}
|
|
155
|
-
},
|
|
155
|
+
}, R = 200, z = 80, B = class {
|
|
156
156
|
panels = [];
|
|
157
157
|
containerWidth = 0;
|
|
158
158
|
containerHeight = 0;
|
|
@@ -164,8 +164,8 @@ var J = class {
|
|
|
164
164
|
this.panels.push({
|
|
165
165
|
id: e,
|
|
166
166
|
position: n,
|
|
167
|
-
size: r ?? (a ?
|
|
168
|
-
minSize: a ?
|
|
167
|
+
size: r ?? (a ? R : t),
|
|
168
|
+
minSize: a ? z : i,
|
|
169
169
|
content: {
|
|
170
170
|
type: "indicator",
|
|
171
171
|
indicatorInstanceId: e
|
|
@@ -179,7 +179,7 @@ var J = class {
|
|
|
179
179
|
let r = this.panels.find((t) => t.id === e);
|
|
180
180
|
if (r) {
|
|
181
181
|
let e = r.position === "left" || r.position === "right", a = n === "left" || n === "right";
|
|
182
|
-
r.position = n, e !== a && (r.size = a ?
|
|
182
|
+
r.position = n, e !== a && (r.size = a ? R : t, r.minSize = a ? z : i);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
setPanelSize(e, t) {
|
|
@@ -280,14 +280,14 @@ var J = class {
|
|
|
280
280
|
getMainChartRect() {
|
|
281
281
|
return this.resolve().mainChartRect;
|
|
282
282
|
}
|
|
283
|
-
},
|
|
283
|
+
}, V = class {
|
|
284
284
|
constructor(e) {
|
|
285
285
|
this.indicatorEngine = e;
|
|
286
286
|
}
|
|
287
287
|
registerIndicator(e) {
|
|
288
288
|
this.indicatorEngine.register(e);
|
|
289
289
|
}
|
|
290
|
-
},
|
|
290
|
+
}, Qe = class {
|
|
291
291
|
static version = "0.7.0";
|
|
292
292
|
engine;
|
|
293
293
|
viewport;
|
|
@@ -313,17 +313,25 @@ var J = class {
|
|
|
313
313
|
watermark;
|
|
314
314
|
barCountdown;
|
|
315
315
|
sessionBreaks;
|
|
316
|
+
sessionShading;
|
|
316
317
|
compareRenderer;
|
|
317
318
|
countdownInterval = null;
|
|
318
319
|
volumeRenderer;
|
|
320
|
+
volumeProfile;
|
|
321
|
+
marketProfile;
|
|
322
|
+
depthHeatmap;
|
|
323
|
+
periodLevels;
|
|
324
|
+
pivotMarkers;
|
|
319
325
|
alertManager;
|
|
320
326
|
signalMarkerManager;
|
|
321
327
|
tradeZoneManager;
|
|
328
|
+
measureOverlay;
|
|
322
329
|
replayManager;
|
|
323
330
|
undoRedoManager;
|
|
324
|
-
autoSaveScheduler = new
|
|
331
|
+
autoSaveScheduler = new Ze((e) => this.saveState(e));
|
|
325
332
|
animator;
|
|
326
333
|
crosshairTooltip;
|
|
334
|
+
pinnedTooltip;
|
|
327
335
|
interactionManager;
|
|
328
336
|
crosshairHandler;
|
|
329
337
|
chartRenderer;
|
|
@@ -372,36 +380,36 @@ var J = class {
|
|
|
372
380
|
logScale: n.logScale ?? !0,
|
|
373
381
|
timeframes: n.timeframes ?? [],
|
|
374
382
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
375
|
-
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", this.dataManager = new
|
|
383
|
+
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", this.dataManager = new I(), this.themeManager = new L(t.theme), this.layoutManager = new B(), this.indicatorEngine = new y(), this.pluginManager = new V(this.indicatorEngine), this.eventBus = new fe(), k(this.indicatorEngine), this.drawingManager = new le(), Ve(this.drawingManager), this.drawingRenderer = new ue(this.drawingManager), this.drawingManager.setRequestRender(() => {
|
|
376
384
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
377
385
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
378
386
|
this.eventBus.emit(e, t);
|
|
379
|
-
}), this.undoRedoManager = new
|
|
387
|
+
}), this.undoRedoManager = new Ne(), this.drawingManager.setUndoRedoManager(this.undoRedoManager), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new je({
|
|
380
388
|
enabled: this.features.trading,
|
|
381
389
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
382
|
-
}), this.tradingRenderer = new
|
|
390
|
+
}), this.tradingRenderer = new Me(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
383
391
|
this.eventBus.emit(e, t);
|
|
384
|
-
}), this.engine = new
|
|
392
|
+
}), this.engine = new C(e);
|
|
385
393
|
let i = this.engine.dprManager.getContainerSize();
|
|
386
|
-
this.viewport = new
|
|
394
|
+
if (this.viewport = new Pe(i.width, i.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.layoutManager.resize(i.width, i.height), this.engine.onContainerResize = (e) => {
|
|
387
395
|
if (e.width <= 0 || e.height <= 0) return;
|
|
388
396
|
let t = this.viewport.isAtEnd();
|
|
389
397
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
|
|
390
|
-
}, this.chartRenderer = this.createChartRenderer(t.chartType), this.gridRenderer = new
|
|
398
|
+
}, this.chartRenderer = this.createChartRenderer(t.chartType), this.gridRenderer = new pe(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new S(), this.priceAxis.setLocale(this.numberLocale), this.timeAxis = new ke(), this.crosshairHandler = new ae(), this.crosshairHandler.setLocale(this.numberLocale), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
|
|
391
399
|
if (e !== null && t) {
|
|
392
400
|
let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
|
|
393
|
-
this.chartLegend.setHoverBar(r ?? null), r && this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize()), this.eventBus.emit("crosshairMove", {
|
|
401
|
+
this.chartLegend.setHoverBar(r ?? null), r && this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize()), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
|
|
394
402
|
point: t,
|
|
395
403
|
bar: r,
|
|
396
404
|
barIndex: e
|
|
397
405
|
});
|
|
398
406
|
} else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null);
|
|
399
|
-
}), this.chartLegend = new
|
|
407
|
+
}), this.chartLegend = new re(), this.chartLegend.setChartType(t.chartType), this.watermark = new Re(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Le(), this.volumeProfile = new Ie(), this.marketProfile = new xe(), this.depthHeatmap = new ce(), this.periodLevels = new we(), this.pivotMarkers = new b(), this.barCountdown = new te(), this.sessionBreaks = new D(), this.sessionShading = new O(), this.compareRenderer = new ie(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
400
408
|
visible: t.sessionBreaks.visible ?? !0,
|
|
401
409
|
color: t.sessionBreaks.color,
|
|
402
410
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
403
411
|
lineWidth: t.sessionBreaks.lineWidth
|
|
404
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.viewport.setLogScale(!0), this.animator = new
|
|
412
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.viewport.setLogScale(!0), this.animator = new p(), this.crosshairTooltip = new oe(), this.crosshairTooltip.create(e), this.pinnedTooltip = new Te(), this.pinnedTooltip.create(e), this.keyboardHandler = new ve({
|
|
405
413
|
scrollBars: (e) => {
|
|
406
414
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
407
415
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -421,14 +429,39 @@ var J = class {
|
|
|
421
429
|
if (!this.keyboardHandler) return;
|
|
422
430
|
let t = document.activeElement;
|
|
423
431
|
t && t !== this.container && !this.container.contains(t) || t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable) || this.keyboardHandler.handleKey(e) && e.preventDefault();
|
|
424
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new
|
|
425
|
-
|
|
432
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new se(), this.alertManager = new f(), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
|
|
433
|
+
let t = {
|
|
434
|
+
id: e.id,
|
|
435
|
+
price: e.price,
|
|
436
|
+
condition: e.condition,
|
|
437
|
+
message: e.message,
|
|
438
|
+
triggered: e.triggered
|
|
439
|
+
};
|
|
440
|
+
this.eventBus.emit("alertTriggered", t), this.eventBus.emit("dataUpdate", {
|
|
426
441
|
alert: "triggered",
|
|
427
442
|
alertId: e.id,
|
|
428
443
|
price: e.price,
|
|
429
444
|
message: e.message
|
|
430
445
|
});
|
|
431
|
-
}), this.
|
|
446
|
+
}), this.alertManager.on("added", (e) => {
|
|
447
|
+
this.eventBus.emit("alertAdd", {
|
|
448
|
+
id: e.id,
|
|
449
|
+
price: e.price,
|
|
450
|
+
condition: e.condition,
|
|
451
|
+
message: e.message,
|
|
452
|
+
triggered: e.triggered
|
|
453
|
+
});
|
|
454
|
+
}), this.alertManager.on("removed", (e) => {
|
|
455
|
+
this.eventBus.emit("alertRemove", { id: e });
|
|
456
|
+
}), this.alertManager.on("updated", (e) => {
|
|
457
|
+
this.eventBus.emit("alertUpdate", {
|
|
458
|
+
id: e.id,
|
|
459
|
+
price: e.price,
|
|
460
|
+
condition: e.condition,
|
|
461
|
+
message: e.message,
|
|
462
|
+
triggered: e.triggered
|
|
463
|
+
});
|
|
464
|
+
}), this.signalMarkerManager = new Ee(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
|
|
432
465
|
this.eventBus.emit("signalMarkerAdd", {
|
|
433
466
|
id: e.id,
|
|
434
467
|
source: e.source,
|
|
@@ -436,29 +469,78 @@ var J = class {
|
|
|
436
469
|
});
|
|
437
470
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
438
471
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
439
|
-
}), this.tradeZoneManager = new
|
|
472
|
+
}), this.tradeZoneManager = new Ae(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
|
|
440
473
|
this.eventBus.emit("tradeZoneAdd", {
|
|
441
474
|
id: e.id,
|
|
442
475
|
direction: e.direction
|
|
443
476
|
});
|
|
444
477
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
445
478
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
446
|
-
}), this.replayManager = new
|
|
479
|
+
}), this.replayManager = new T(), this.measureOverlay = new Se(), this.interactionManager = new ge(e), this.features.panning && this.interactionManager.setPanHandler(new Ce((e) => {
|
|
447
480
|
this.viewport.scrollBy(e), this.updateViewportAndRender();
|
|
448
|
-
})), this.features.zooming
|
|
449
|
-
this.
|
|
450
|
-
|
|
481
|
+
})), this.features.zooming) {
|
|
482
|
+
this.interactionManager.setZoomHandler(new ze((e, t) => {
|
|
483
|
+
this.viewport.zoom(e, t), this.updateViewportAndRender();
|
|
484
|
+
}));
|
|
485
|
+
let e = new ee((e) => {
|
|
486
|
+
this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender();
|
|
487
|
+
}, (e) => {
|
|
488
|
+
let t = this.viewport.getState().chartRect.width;
|
|
489
|
+
this.viewport.zoom(1 / e - 1, t / 2), this.updateViewportAndRender();
|
|
490
|
+
});
|
|
491
|
+
this.interactionManager.setAxisDragHandler(e, () => this.viewport.getState(), (e) => {
|
|
492
|
+
e === "price" ? (this.options.autoScale = !0, this.updateViewportAndRender()) : this.fitContent();
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
if (this.features.crosshair && this.interactionManager.setCrosshairHandler(this.crosshairHandler), this.features.drawings && this.interactionManager.setDrawingManager(this.drawingManager, () => ({
|
|
451
496
|
...this.viewport.getState(),
|
|
452
497
|
data: this.getDisplayData()
|
|
453
498
|
})), this.features.trading && this.interactionManager.setTradingManager(this.tradingManager, () => ({
|
|
454
499
|
...this.viewport.getState(),
|
|
455
500
|
data: this.getDisplayData()
|
|
456
|
-
})), this.
|
|
457
|
-
this.
|
|
501
|
+
})), this.features.alerts) {
|
|
502
|
+
let e = new d(this.alertManager, () => this.viewport.getState());
|
|
503
|
+
this.interactionManager.setAlertDragHandler(e);
|
|
504
|
+
}
|
|
505
|
+
this.interactionManager.setAltClickHandler((e) => {
|
|
506
|
+
let t = this.getDisplayData();
|
|
507
|
+
if (t.length === 0) return;
|
|
508
|
+
let n = this.viewport.getState(), i = n.barWidth + n.barSpacing, a = Math.round((n.offset + e.x) / i);
|
|
509
|
+
a < 0 || a >= t.length || (this.pinnedTooltip.isPinned() && this.pinnedTooltip.getPinnedIndex() === a ? this.pinnedTooltip.unpin() : this.pinnedTooltip.pin(t[a], a, this.themeManager.getTheme()), this.pinnedTooltip.reposition(this.viewport.getState(), this.dataManager.getData()[a] ?? null, a, this.themeManager.getTheme()), this.engine.requestRender(r.Overlay));
|
|
510
|
+
}), this.interactionManager.setClickHandler((e) => {
|
|
511
|
+
let t = this.getDisplayData();
|
|
512
|
+
if (this.eventBus.emit("click", {
|
|
513
|
+
x: e.x,
|
|
514
|
+
y: e.y
|
|
515
|
+
}), t.length === 0) return;
|
|
516
|
+
let n = qe(e.x, this.viewport.getState());
|
|
517
|
+
n < 0 || n >= t.length || this.eventBus.emit("barClick", {
|
|
518
|
+
bar: t[n],
|
|
519
|
+
barIndex: n,
|
|
520
|
+
point: e
|
|
521
|
+
});
|
|
522
|
+
}), this.interactionManager.setEscapeHandler(() => {
|
|
523
|
+
if (this.features.trading && this.tradingManager.isBracketActive()) {
|
|
524
|
+
this.tradingManager.cancelBracket(), this.eventBus.emit("dataUpdate", { bracket: "cancelled" });
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
this.pinnedTooltip.isPinned() && (this.pinnedTooltip.unpin(), this.engine.requestRender(r.Overlay));
|
|
528
|
+
}), this.interactionManager.setConfirmHandler(() => this.features.trading && this.tradingManager.isBracketActive() ? (this.tradingManager.confirmBracket(), !0) : !1), this.interactionManager.setMeasureHandlers({
|
|
529
|
+
begin: (e) => {
|
|
530
|
+
this.measureOverlay.begin(e, this.viewport.getState(), this.getDisplayData());
|
|
531
|
+
},
|
|
532
|
+
move: (e) => {
|
|
533
|
+
this.measureOverlay.update(e, this.viewport.getState(), this.getDisplayData());
|
|
534
|
+
},
|
|
535
|
+
end: () => {
|
|
536
|
+
this.measureOverlay.end();
|
|
537
|
+
}
|
|
538
|
+
}), this.interactionManager.setOverlayDirtyCallback(() => {
|
|
539
|
+
this.engine.requestRender(r.Overlay), this.engine.requestRender(r.UI);
|
|
458
540
|
}), this.interactionManager.attach(), this.syncRenderContext(), this.engine.start();
|
|
459
541
|
}
|
|
460
542
|
setData(e) {
|
|
461
|
-
this.dataManager.setData(e), this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.indicatorEngine.recalculateAll(this.dataManager.getData()), e.length > 0 && this.currentPriceLine.setPrice(e[e.length - 1].close), this.updateViewportAndRender(!0), this.eventBus.emit("dataUpdate", { length: e.length });
|
|
543
|
+
this.dataManager.setData(e), this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.alertManager.clearLastValues(), this.indicatorEngine.recalculateAll(this.dataManager.getData()), e.length > 0 && this.currentPriceLine.setPrice(e[e.length - 1].close), this.updateViewportAndRender(!0), this.eventBus.emit("dataUpdate", { length: e.length });
|
|
462
544
|
}
|
|
463
545
|
appendBar(e) {
|
|
464
546
|
this.dataManager.appendBar(e), this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.autoScrollOnNewBar && this.viewport.scrollToEnd(), this.indicatorEngine.recalculateAll(this.dataManager.getData()), this.updateViewportAndRender();
|
|
@@ -500,8 +582,8 @@ var J = class {
|
|
|
500
582
|
this.pluginManager.registerIndicator(e);
|
|
501
583
|
}
|
|
502
584
|
static indicators() {
|
|
503
|
-
let e = new
|
|
504
|
-
return
|
|
585
|
+
let e = new y();
|
|
586
|
+
return k(e), e.getAvailableIndicators();
|
|
505
587
|
}
|
|
506
588
|
setPanelPosition(e, t) {
|
|
507
589
|
this.layoutManager.setPanelPosition(e, t), this.engine.requestRender();
|
|
@@ -518,15 +600,43 @@ var J = class {
|
|
|
518
600
|
setDrawingStyle(e) {
|
|
519
601
|
this.drawingManager.setStyle(e);
|
|
520
602
|
}
|
|
603
|
+
getDrawingStyle() {
|
|
604
|
+
return this.drawingManager.getActiveStyle();
|
|
605
|
+
}
|
|
606
|
+
getSelectedDrawingId() {
|
|
607
|
+
return this.drawingManager.getSelectedDrawingId();
|
|
608
|
+
}
|
|
609
|
+
setSelectedDrawingStyle(e, t) {
|
|
610
|
+
return this.drawingManager.setSelectedDrawingStyle(e, t);
|
|
611
|
+
}
|
|
521
612
|
getDrawings() {
|
|
522
613
|
return this.drawingManager.getDrawings();
|
|
523
614
|
}
|
|
524
615
|
setDrawings(e) {
|
|
525
616
|
this.drawingManager.setDrawings(e);
|
|
526
617
|
}
|
|
618
|
+
addDrawing(e) {
|
|
619
|
+
if (!this.features.drawings) return null;
|
|
620
|
+
let t = this.drawingManager.addDrawing(e);
|
|
621
|
+
return this.scheduleAutoSave(), t;
|
|
622
|
+
}
|
|
623
|
+
autoFib() {
|
|
624
|
+
if (!this.features.drawings) return null;
|
|
625
|
+
let e = this.getDisplayData(), t = this.viewport.getState(), n = Be(e, t.visibleRange.from, t.visibleRange.to);
|
|
626
|
+
return n ? this.addDrawing({
|
|
627
|
+
type: "fibRetracement",
|
|
628
|
+
anchors: [n[0], n[1]]
|
|
629
|
+
}) : null;
|
|
630
|
+
}
|
|
527
631
|
removeDrawing(e) {
|
|
528
632
|
this.drawingManager.removeDrawing(e);
|
|
529
633
|
}
|
|
634
|
+
setDrawingVisible(e, t) {
|
|
635
|
+
this.drawingManager.setDrawingVisible(e, t);
|
|
636
|
+
}
|
|
637
|
+
setDrawingLocked(e, t) {
|
|
638
|
+
this.drawingManager.setDrawingLocked(e, t);
|
|
639
|
+
}
|
|
530
640
|
clearDrawings() {
|
|
531
641
|
this.drawingManager.clearDrawings();
|
|
532
642
|
}
|
|
@@ -567,21 +677,21 @@ var J = class {
|
|
|
567
677
|
exportVisibleData(e = "csv", t) {
|
|
568
678
|
let n = this.viewport.getState(), r = this.dataManager.getData(), i = Math.max(0, n.visibleRange.from), a = Math.min(r.length - 1, n.visibleRange.to), o = r.slice(i, a + 1);
|
|
569
679
|
if (e === "json") {
|
|
570
|
-
let e =
|
|
571
|
-
|
|
680
|
+
let e = v.toJSON(o);
|
|
681
|
+
v.download(e, t ?? "chart-data.json", "application/json");
|
|
572
682
|
} else {
|
|
573
|
-
let e =
|
|
574
|
-
|
|
683
|
+
let e = v.toCSV(o);
|
|
684
|
+
v.download(e, t ?? "chart-data.csv", "text/csv");
|
|
575
685
|
}
|
|
576
686
|
}
|
|
577
687
|
exportAllData(e = "csv", t) {
|
|
578
688
|
let n = this.dataManager.getData();
|
|
579
689
|
if (e === "json") {
|
|
580
|
-
let e =
|
|
581
|
-
|
|
690
|
+
let e = v.toJSON(n);
|
|
691
|
+
v.download(e, t ?? "chart-data.json", "application/json");
|
|
582
692
|
} else {
|
|
583
|
-
let e =
|
|
584
|
-
|
|
693
|
+
let e = v.toCSV(n);
|
|
694
|
+
v.download(e, t ?? "chart-data.csv", "text/csv");
|
|
585
695
|
}
|
|
586
696
|
}
|
|
587
697
|
setAutoSave(e, t = 5e3) {
|
|
@@ -606,6 +716,9 @@ var J = class {
|
|
|
606
716
|
getActiveIndicators() {
|
|
607
717
|
return this.indicatorEngine.getActiveIndicators();
|
|
608
718
|
}
|
|
719
|
+
setIndicatorVisible(e, t) {
|
|
720
|
+
this.indicatorEngine.setVisible(e, t) !== null && this.updateViewportAndRender();
|
|
721
|
+
}
|
|
609
722
|
getIndicatorConfig(e) {
|
|
610
723
|
let t = this.indicatorEngine.getIndicatorConfig(e);
|
|
611
724
|
return t ? {
|
|
@@ -619,6 +732,23 @@ var J = class {
|
|
|
619
732
|
setOrders(e) {
|
|
620
733
|
this.features.trading && this.tradingManager.setOrders(e);
|
|
621
734
|
}
|
|
735
|
+
startBracket(e, t) {
|
|
736
|
+
if (!this.features.trading) return !1;
|
|
737
|
+
let n = this.dataManager.getData(), r = t ?? (n.length > 0 ? n[n.length - 1].close : null);
|
|
738
|
+
return r === null ? !1 : (this.tradingManager.startBracket(e, r), !0);
|
|
739
|
+
}
|
|
740
|
+
cancelBracket() {
|
|
741
|
+
this.features.trading && this.tradingManager.cancelBracket();
|
|
742
|
+
}
|
|
743
|
+
confirmBracket() {
|
|
744
|
+
return this.features.trading ? this.tradingManager.confirmBracket() : !1;
|
|
745
|
+
}
|
|
746
|
+
isBracketActive() {
|
|
747
|
+
return this.features.trading && this.tradingManager.isBracketActive();
|
|
748
|
+
}
|
|
749
|
+
placeOrderIntent(e) {
|
|
750
|
+
this.features.trading && this.eventBus.emit("orderPlace", e);
|
|
751
|
+
}
|
|
622
752
|
setPositions(e) {
|
|
623
753
|
this.features.trading && this.tradingManager.setPositions(e);
|
|
624
754
|
}
|
|
@@ -626,13 +756,26 @@ var J = class {
|
|
|
626
756
|
this.features.trading && this.tradingManager.setDepthData(e);
|
|
627
757
|
}
|
|
628
758
|
setCurrentPrice(e, t) {
|
|
629
|
-
this.tradingManager.setCurrentPrice(e), this.currentPriceLine.setPrice(e), this.scheduleRender(), this.features.alerts && this.alertManager.checkPrice(e);
|
|
759
|
+
this.tradingManager.setCurrentPrice(e), this.currentPriceLine.setPrice(e), this.scheduleRender(), this.features.alerts && (this.alertManager.checkPrice(e), this.feedIndicatorAlerts());
|
|
760
|
+
}
|
|
761
|
+
feedIndicatorAlerts() {
|
|
762
|
+
let e = this.alertManager.getAlerts(), t = this.dataManager.getData();
|
|
763
|
+
if (t.length === 0) return;
|
|
764
|
+
let n = t.length - 1, r = /* @__PURE__ */ new Set();
|
|
765
|
+
for (let t of e) {
|
|
766
|
+
if (t.channel === "price" || r.has(t.channel)) continue;
|
|
767
|
+
r.add(t.channel);
|
|
768
|
+
let e = t.channel.indexOf(":");
|
|
769
|
+
if (e < 0) continue;
|
|
770
|
+
let i = t.channel.slice(0, e), a = t.channel.slice(e + 1), o = this.indicatorEngine.getOutput(i)?.series?.[n]?.[a];
|
|
771
|
+
typeof o == "number" && Number.isFinite(o) && this.alertManager.checkChannel(t.channel, o);
|
|
772
|
+
}
|
|
630
773
|
}
|
|
631
774
|
setTradingConfig(e) {
|
|
632
775
|
this.features.trading && this.tradingManager.setConfig(e);
|
|
633
776
|
}
|
|
634
777
|
async connect(e) {
|
|
635
|
-
this.disconnectStream(), this.streamManager = new
|
|
778
|
+
this.disconnectStream(), this.streamManager = new Oe(), this.streamManager.on("snapshot", (e) => {
|
|
636
779
|
this.setData(e);
|
|
637
780
|
}), this.streamManager.on("barClose", (e) => {
|
|
638
781
|
this.dataManager.appendBar(e), this.crosshairHandler.setData(this.dataManager.getData()), this.autoScrollOnNewBar && this.viewport.scrollToEnd(), this.indicatorEngine.recalculateAll(this.dataManager.getData()), this.updateViewportAndRender();
|
|
@@ -693,6 +836,12 @@ var J = class {
|
|
|
693
836
|
isLogScale() {
|
|
694
837
|
return this.viewport.isLogScale();
|
|
695
838
|
}
|
|
839
|
+
setScaleMode(e) {
|
|
840
|
+
this.viewport.setScaleMode(e), this.updateViewportAndRender();
|
|
841
|
+
}
|
|
842
|
+
getScaleMode() {
|
|
843
|
+
return this.viewport.getScaleMode();
|
|
844
|
+
}
|
|
696
845
|
setSessionBreaksConfig(e) {
|
|
697
846
|
this.sessionBreaks.setConfig(e), this.engine.requestRender(r.Background);
|
|
698
847
|
}
|
|
@@ -799,6 +948,73 @@ var J = class {
|
|
|
799
948
|
setVolumeVisible(e) {
|
|
800
949
|
this.volumeRenderer.setVisible(e), this.engine.requestRender(r.Main);
|
|
801
950
|
}
|
|
951
|
+
setVolumeProfileVisible(e) {
|
|
952
|
+
this.volumeProfile.setVisible(e), this.engine.requestRender(r.Main);
|
|
953
|
+
}
|
|
954
|
+
isVolumeProfileVisible() {
|
|
955
|
+
return this.volumeProfile.isVisible();
|
|
956
|
+
}
|
|
957
|
+
setVolumeProfileConfig(e) {
|
|
958
|
+
e.buckets !== void 0 && this.volumeProfile.setBuckets(e.buckets), e.widthRatio !== void 0 && this.volumeProfile.setWidthRatio(e.widthRatio), e.opacity !== void 0 && this.volumeProfile.setOpacity(e.opacity), e.highlightPoC !== void 0 && this.volumeProfile.setHighlightPoC(e.highlightPoC), this.engine.requestRender(r.Main);
|
|
959
|
+
}
|
|
960
|
+
setMarketProfileVisible(e) {
|
|
961
|
+
this.marketProfile.setVisible(e), this.engine.requestRender(r.Main);
|
|
962
|
+
}
|
|
963
|
+
isMarketProfileVisible() {
|
|
964
|
+
return this.marketProfile.isVisible();
|
|
965
|
+
}
|
|
966
|
+
setMarketProfileConfig(e) {
|
|
967
|
+
e.buckets !== void 0 && this.marketProfile.setBuckets(e.buckets), e.widthRatio !== void 0 && this.marketProfile.setWidthRatio(e.widthRatio), e.opacity !== void 0 && this.marketProfile.setOpacity(e.opacity), e.valueAreaPct !== void 0 && this.marketProfile.setValueAreaPct(e.valueAreaPct), e.highlightPoC !== void 0 && this.marketProfile.setHighlightPoC(e.highlightPoC), e.showStats !== void 0 && this.marketProfile.setShowStats(e.showStats), e.splitBySession !== void 0 && this.marketProfile.setSplitBySession(e.splitBySession), e.letters !== void 0 && this.marketProfile.setLetters(e.letters), this.engine.requestRender(r.Main);
|
|
968
|
+
}
|
|
969
|
+
getMarketProfileStats() {
|
|
970
|
+
return this.marketProfile.getStats();
|
|
971
|
+
}
|
|
972
|
+
setDepthHeatmapVisible(e) {
|
|
973
|
+
this.depthHeatmap.setVisible(e), this.engine.requestRender(r.Main);
|
|
974
|
+
}
|
|
975
|
+
isDepthHeatmapVisible() {
|
|
976
|
+
return this.depthHeatmap.isVisible();
|
|
977
|
+
}
|
|
978
|
+
setDepthHeatmapConfig(e) {
|
|
979
|
+
e.opacity !== void 0 && this.depthHeatmap.setOpacity(e.opacity), e.capacity !== void 0 && this.depthHeatmap.setCapacity(e.capacity), this.engine.requestRender(r.Main);
|
|
980
|
+
}
|
|
981
|
+
pushDepthSnapshot(e) {
|
|
982
|
+
let t = this.dataManager.getData();
|
|
983
|
+
t.length !== 0 && (this.depthHeatmap.push(t[t.length - 1].time, e), this.depthHeatmap.isVisible() && this.engine.requestRender(r.Main));
|
|
984
|
+
}
|
|
985
|
+
clearDepthHeatmap() {
|
|
986
|
+
this.depthHeatmap.clear(), this.engine.requestRender(r.Main);
|
|
987
|
+
}
|
|
988
|
+
setPeriodLevelsVisible(e) {
|
|
989
|
+
this.periodLevels.setVisible(e), this.engine.requestRender(r.Main);
|
|
990
|
+
}
|
|
991
|
+
isPeriodLevelsVisible() {
|
|
992
|
+
return this.periodLevels.isVisible();
|
|
993
|
+
}
|
|
994
|
+
setPeriodLevelsPeriod(e) {
|
|
995
|
+
this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
|
|
996
|
+
}
|
|
997
|
+
setTimezoneOffset(e) {
|
|
998
|
+
this.timeAxis.setTimezoneOffset(e), this.crosshairHandler.setTimezoneOffset(e), this.engine.requestRender(r.UI), this.engine.requestRender(r.Overlay);
|
|
999
|
+
}
|
|
1000
|
+
setPivotMarkersVisible(e) {
|
|
1001
|
+
this.pivotMarkers.setVisible(e), this.engine.requestRender(r.Overlay);
|
|
1002
|
+
}
|
|
1003
|
+
isPivotMarkersVisible() {
|
|
1004
|
+
return this.pivotMarkers.isVisible();
|
|
1005
|
+
}
|
|
1006
|
+
setPivotMarkersConfig(e) {
|
|
1007
|
+
(e.left !== void 0 || e.right !== void 0) && this.pivotMarkers.setStrength(e.left ?? 5, e.right ?? e.left ?? 5), e.showLabels !== void 0 && this.pivotMarkers.setShowLabels(e.showLabels), e.structureLabels !== void 0 && this.pivotMarkers.setStructureLabels(e.structureLabels), this.engine.requestRender(r.Overlay);
|
|
1008
|
+
}
|
|
1009
|
+
setSessionShadingVisible(e) {
|
|
1010
|
+
this.sessionShading.setVisible(e), this.engine.requestRender(r.Background);
|
|
1011
|
+
}
|
|
1012
|
+
isSessionShadingVisible() {
|
|
1013
|
+
return this.sessionShading.isVisible();
|
|
1014
|
+
}
|
|
1015
|
+
setSessionShadingConfig(e) {
|
|
1016
|
+
this.sessionShading.setConfig(e), this.engine.requestRender(r.Background);
|
|
1017
|
+
}
|
|
802
1018
|
setTooltipVisible(e) {
|
|
803
1019
|
e || this.crosshairTooltip.hide();
|
|
804
1020
|
}
|
|
@@ -812,18 +1028,27 @@ var J = class {
|
|
|
812
1028
|
this.chartLegend.setStatusText(e), this.engine.requestRender(r.UI);
|
|
813
1029
|
}
|
|
814
1030
|
screenshot(e) {
|
|
815
|
-
this.features.screenshot &&
|
|
1031
|
+
this.features.screenshot && E.download(this.container, e, this.themeManager.getTheme().background);
|
|
1032
|
+
}
|
|
1033
|
+
async copyScreenshot() {
|
|
1034
|
+
if (!this.features.screenshot) return !1;
|
|
1035
|
+
try {
|
|
1036
|
+
let e = await E.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
|
|
1037
|
+
return !e || !navigator.clipboard?.write || !t ? !1 : (await navigator.clipboard.write([new t({ "image/png": e })]), !0);
|
|
1038
|
+
} catch {
|
|
1039
|
+
return !1;
|
|
1040
|
+
}
|
|
816
1041
|
}
|
|
817
1042
|
screenshotDataURL() {
|
|
818
|
-
return this.features.screenshot ?
|
|
1043
|
+
return this.features.screenshot ? E.toDataURL(this.container, this.themeManager.getTheme().background) : null;
|
|
819
1044
|
}
|
|
820
1045
|
async screenshotBlob() {
|
|
821
|
-
return this.features.screenshot ?
|
|
1046
|
+
return this.features.screenshot ? E.toBlob(this.container, this.themeManager.getTheme().background) : null;
|
|
822
1047
|
}
|
|
823
|
-
addAlert(e, t = "crossing", n) {
|
|
1048
|
+
addAlert(e, t = "crossing", n, r = "price", i) {
|
|
824
1049
|
if (!this.features.alerts) return null;
|
|
825
|
-
let
|
|
826
|
-
return this.scheduleAutoSave(),
|
|
1050
|
+
let a = this.alertManager.addAlert(e, t, n, !1, r, i);
|
|
1051
|
+
return this.scheduleAutoSave(), a;
|
|
827
1052
|
}
|
|
828
1053
|
removeAlert(e) {
|
|
829
1054
|
this.alertManager.removeAlert(e), this.scheduleAutoSave();
|
|
@@ -993,16 +1218,16 @@ var J = class {
|
|
|
993
1218
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(n), this.eventBus.emit("resize", e);
|
|
994
1219
|
}
|
|
995
1220
|
destroy() {
|
|
996
|
-
this.countdownInterval && clearInterval(this.countdownInterval), this.disableAutoSave(), this.disconnectStream(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.replayManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
|
|
1221
|
+
this.countdownInterval && clearInterval(this.countdownInterval), this.disableAutoSave(), this.disconnectStream(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
|
|
997
1222
|
}
|
|
998
1223
|
createChartRenderer(e) {
|
|
999
|
-
return
|
|
1224
|
+
return Je(e);
|
|
1000
1225
|
}
|
|
1001
1226
|
getDisplayData() {
|
|
1002
1227
|
if (this.displayDataCache) return this.displayDataCache;
|
|
1003
1228
|
let e = this.dataManager.getData();
|
|
1004
1229
|
if (e.length === 0) return e;
|
|
1005
|
-
let t =
|
|
1230
|
+
let t = Ye(this.options.chartType, e);
|
|
1006
1231
|
return this.displayDataCache = t, t;
|
|
1007
1232
|
}
|
|
1008
1233
|
scheduleRender() {
|
|
@@ -1017,7 +1242,11 @@ var J = class {
|
|
|
1017
1242
|
let t = this.getResolvedLayout();
|
|
1018
1243
|
this.viewport.setChartRect(t.mainChartRect);
|
|
1019
1244
|
let n = this.getDisplayData();
|
|
1020
|
-
if (this.viewport.updateData(n, this.options.autoScale !== !1),
|
|
1245
|
+
if (this.viewport.updateData(n, this.options.autoScale !== !1), n.length > 0) {
|
|
1246
|
+
let e = this.viewport.getState(), t = Math.max(0, Math.min(e.visibleRange.from, n.length - 1));
|
|
1247
|
+
this.viewport.setScaleBaseline(n[t]?.close);
|
|
1248
|
+
}
|
|
1249
|
+
if (this.options.autoScale !== !1) {
|
|
1021
1250
|
let e = this.viewport.getState(), t = this.indicatorEngine.getOverlayPriceRange(e.visibleRange.from, Math.min(e.visibleRange.to, n.length - 1));
|
|
1022
1251
|
if (t) {
|
|
1023
1252
|
let n = e.priceRange, r = Math.min(n.min, t.min), i = Math.max(n.max, t.max);
|
|
@@ -1039,7 +1268,7 @@ var J = class {
|
|
|
1039
1268
|
buildPanelRenderInfos() {
|
|
1040
1269
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
1041
1270
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
1042
|
-
let i =
|
|
1271
|
+
let i = Xe(this.indicatorEngine.getOutput(e.config.id), n, r), a = {
|
|
1043
1272
|
x: e.rect.x,
|
|
1044
1273
|
y: e.rect.y + 20,
|
|
1045
1274
|
width: e.rect.width,
|
|
@@ -1058,6 +1287,7 @@ var J = class {
|
|
|
1058
1287
|
return this.panelInfoCache = i, i;
|
|
1059
1288
|
}
|
|
1060
1289
|
syncRenderContext() {
|
|
1290
|
+
this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), null, null, this.themeManager.getTheme());
|
|
1061
1291
|
let e = this.getResolvedLayout(), t = this.features.indicators ? this.buildPanelRenderInfos() : [], n = e.panels.filter((e) => e.config.position === "bottom").reduce((e, t) => e + t.rect.height, 0), r = e.mainChartRect.y + e.mainChartRect.height + n, i = this.getDisplayData();
|
|
1062
1292
|
this.engine.setRenderContext({
|
|
1063
1293
|
chartRenderer: this.chartRenderer,
|
|
@@ -1071,11 +1301,18 @@ var J = class {
|
|
|
1071
1301
|
currentPriceLine: this.streamManager?.priceLine ?? this.currentPriceLine,
|
|
1072
1302
|
chartLegend: this.features.legend ? this.chartLegend : null,
|
|
1073
1303
|
volumeRenderer: this.features.volume ? this.volumeRenderer : null,
|
|
1304
|
+
volumeProfile: this.volumeProfile,
|
|
1305
|
+
marketProfile: this.marketProfile,
|
|
1306
|
+
depthHeatmap: this.depthHeatmap,
|
|
1307
|
+
periodLevels: this.periodLevels,
|
|
1308
|
+
pivotMarkers: this.pivotMarkers,
|
|
1074
1309
|
watermark: this.features.watermark ? this.watermark : null,
|
|
1075
1310
|
barCountdown: this.barCountdown,
|
|
1076
1311
|
sessionBreaks: this.sessionBreaks,
|
|
1312
|
+
sessionShading: this.sessionShading,
|
|
1077
1313
|
compareRenderer: this.compareRenderer,
|
|
1078
1314
|
alertManager: this.features.alerts ? this.alertManager : null,
|
|
1315
|
+
measureOverlay: this.measureOverlay,
|
|
1079
1316
|
signalMarkerManager: this.signalMarkerManager,
|
|
1080
1317
|
tradeZoneManager: this.tradeZoneManager,
|
|
1081
1318
|
panels: t,
|
|
@@ -1102,8 +1339,240 @@ var J = class {
|
|
|
1102
1339
|
} : void 0
|
|
1103
1340
|
} : null;
|
|
1104
1341
|
}
|
|
1342
|
+
}, H = [
|
|
1343
|
+
"time",
|
|
1344
|
+
"timestamp",
|
|
1345
|
+
"date",
|
|
1346
|
+
"datetime",
|
|
1347
|
+
"t"
|
|
1348
|
+
], U = ["open", "o"], W = ["high", "h"], G = ["low", "l"], K = ["close", "c"], q = [
|
|
1349
|
+
"volume",
|
|
1350
|
+
"vol",
|
|
1351
|
+
"v"
|
|
1352
|
+
];
|
|
1353
|
+
function J(e) {
|
|
1354
|
+
let t = e.trim();
|
|
1355
|
+
return t ? t[0] === "[" || t[0] === "{" ? $e(t) : et(t) : {
|
|
1356
|
+
data: [],
|
|
1357
|
+
rowCount: 0,
|
|
1358
|
+
skipped: 0
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
function $e(e) {
|
|
1362
|
+
let t;
|
|
1363
|
+
try {
|
|
1364
|
+
t = JSON.parse(e);
|
|
1365
|
+
} catch (e) {
|
|
1366
|
+
throw Error(`Invalid JSON: ${e.message}`);
|
|
1367
|
+
}
|
|
1368
|
+
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
1369
|
+
let n = [], r = 0;
|
|
1370
|
+
for (let e of t) {
|
|
1371
|
+
let t = Array.isArray(e) ? it(e) : rt(e);
|
|
1372
|
+
t ? n.push(t) : r++;
|
|
1373
|
+
}
|
|
1374
|
+
return Q(n, t.length, r);
|
|
1375
|
+
}
|
|
1376
|
+
function et(e) {
|
|
1377
|
+
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
1378
|
+
if (t.length === 0) return {
|
|
1379
|
+
data: [],
|
|
1380
|
+
rowCount: 0,
|
|
1381
|
+
skipped: 0
|
|
1382
|
+
};
|
|
1383
|
+
let n = tt(t[0]), r = Y(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? nt(r) : {
|
|
1384
|
+
time: 0,
|
|
1385
|
+
open: 1,
|
|
1386
|
+
high: 2,
|
|
1387
|
+
low: 3,
|
|
1388
|
+
close: 4,
|
|
1389
|
+
volume: 5
|
|
1390
|
+
};
|
|
1391
|
+
if (a.time < 0 || a.open < 0 || a.high < 0 || a.low < 0 || a.close < 0) throw Error("CSV is missing required column(s): time, open, high, low, close");
|
|
1392
|
+
let o = [], s = 0;
|
|
1393
|
+
for (let e = +!!i; e < t.length; e++) {
|
|
1394
|
+
let r = Y(t[e], n), i = Z(r[a.time]), c = X(r[a.open]), l = X(r[a.high]), u = X(r[a.low]), d = X(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
|
|
1395
|
+
if (i === null || ![
|
|
1396
|
+
c,
|
|
1397
|
+
l,
|
|
1398
|
+
u,
|
|
1399
|
+
d
|
|
1400
|
+
].every(Number.isFinite)) {
|
|
1401
|
+
s++;
|
|
1402
|
+
continue;
|
|
1403
|
+
}
|
|
1404
|
+
o.push({
|
|
1405
|
+
time: i,
|
|
1406
|
+
open: c,
|
|
1407
|
+
high: l,
|
|
1408
|
+
low: u,
|
|
1409
|
+
close: d,
|
|
1410
|
+
volume: Number.isFinite(f) ? f : 0
|
|
1411
|
+
});
|
|
1412
|
+
}
|
|
1413
|
+
return Q(o, t.length - +!!i, s);
|
|
1414
|
+
}
|
|
1415
|
+
function tt(e) {
|
|
1416
|
+
let t = {
|
|
1417
|
+
",": 0,
|
|
1418
|
+
";": 0,
|
|
1419
|
+
" ": 0,
|
|
1420
|
+
"|": 0
|
|
1421
|
+
};
|
|
1422
|
+
for (let n of e) n in t && t[n]++;
|
|
1423
|
+
let n = ",", r = 0;
|
|
1424
|
+
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
1425
|
+
return n;
|
|
1426
|
+
}
|
|
1427
|
+
function Y(e, t) {
|
|
1428
|
+
let n = [], r = "", i = !1;
|
|
1429
|
+
for (let a = 0; a < e.length; a++) {
|
|
1430
|
+
let o = e[a];
|
|
1431
|
+
o === "\"" ? i && e[a + 1] === "\"" ? (r += "\"", a++) : i = !i : o === t && !i ? (n.push(r), r = "") : r += o;
|
|
1432
|
+
}
|
|
1433
|
+
return n.push(r), n;
|
|
1434
|
+
}
|
|
1435
|
+
function nt(e) {
|
|
1436
|
+
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
1437
|
+
return {
|
|
1438
|
+
time: t(H),
|
|
1439
|
+
open: t(U),
|
|
1440
|
+
high: t(W),
|
|
1441
|
+
low: t(G),
|
|
1442
|
+
close: t(K),
|
|
1443
|
+
volume: t(q)
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
function rt(e) {
|
|
1447
|
+
let t = (t) => {
|
|
1448
|
+
for (let n of t) {
|
|
1449
|
+
if (e[n] !== void 0) return e[n];
|
|
1450
|
+
let t = n.toUpperCase();
|
|
1451
|
+
if (e[t] !== void 0) return e[t];
|
|
1452
|
+
}
|
|
1453
|
+
}, n = Z(String(t(H) ?? "")), r = Number(t(U)), i = Number(t(W)), a = Number(t(G)), o = Number(t(K)), s = Number(t(q) ?? 0);
|
|
1454
|
+
return n === null || ![
|
|
1455
|
+
r,
|
|
1456
|
+
i,
|
|
1457
|
+
a,
|
|
1458
|
+
o
|
|
1459
|
+
].every(Number.isFinite) ? null : {
|
|
1460
|
+
time: n,
|
|
1461
|
+
open: r,
|
|
1462
|
+
high: i,
|
|
1463
|
+
low: a,
|
|
1464
|
+
close: o,
|
|
1465
|
+
volume: Number.isFinite(s) ? s : 0
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
function it(e) {
|
|
1469
|
+
if (e.length < 5) return null;
|
|
1470
|
+
let t = Z(String(e[0])), n = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = Number(e[4]), o = e.length >= 6 ? Number(e[5]) : 0;
|
|
1471
|
+
return t === null || ![
|
|
1472
|
+
n,
|
|
1473
|
+
r,
|
|
1474
|
+
i,
|
|
1475
|
+
a
|
|
1476
|
+
].every(Number.isFinite) ? null : {
|
|
1477
|
+
time: t,
|
|
1478
|
+
open: n,
|
|
1479
|
+
high: r,
|
|
1480
|
+
low: i,
|
|
1481
|
+
close: a,
|
|
1482
|
+
volume: Number.isFinite(o) ? o : 0
|
|
1483
|
+
};
|
|
1484
|
+
}
|
|
1485
|
+
function X(e) {
|
|
1486
|
+
return e === void 0 || e.trim() === "" ? NaN : Number(e);
|
|
1487
|
+
}
|
|
1488
|
+
function Z(e) {
|
|
1489
|
+
let t = e.trim();
|
|
1490
|
+
if (!t) return null;
|
|
1491
|
+
let n = Number(t);
|
|
1492
|
+
if (Number.isFinite(n) && n > 0) return n < 0xe8d4a51000 ? n * 1e3 : n;
|
|
1493
|
+
let r = Date.parse(t);
|
|
1494
|
+
return Number.isFinite(r) ? r : null;
|
|
1495
|
+
}
|
|
1496
|
+
function Q(e, t, n) {
|
|
1497
|
+
e.sort((e, t) => e.time - t.time);
|
|
1498
|
+
let r = [];
|
|
1499
|
+
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
1500
|
+
return {
|
|
1501
|
+
data: r,
|
|
1502
|
+
rowCount: t,
|
|
1503
|
+
skipped: n
|
|
1504
|
+
};
|
|
1505
|
+
}
|
|
1506
|
+
//#endregion
|
|
1507
|
+
//#region src/io/DragDropImporter.ts
|
|
1508
|
+
var at = class {
|
|
1509
|
+
host;
|
|
1510
|
+
overlay = null;
|
|
1511
|
+
callbacks;
|
|
1512
|
+
bound;
|
|
1513
|
+
depth = 0;
|
|
1514
|
+
constructor(e, t) {
|
|
1515
|
+
this.host = e, this.callbacks = t, this.bound = {
|
|
1516
|
+
dragenter: (e) => this.onDragEnter(e),
|
|
1517
|
+
dragover: (e) => this.onDragOver(e),
|
|
1518
|
+
dragleave: (e) => this.onDragLeave(e),
|
|
1519
|
+
drop: (e) => this.onDrop(e)
|
|
1520
|
+
};
|
|
1521
|
+
}
|
|
1522
|
+
attach() {
|
|
1523
|
+
this.host.addEventListener("dragenter", this.bound.dragenter), this.host.addEventListener("dragover", this.bound.dragover), this.host.addEventListener("dragleave", this.bound.dragleave), this.host.addEventListener("drop", this.bound.drop);
|
|
1524
|
+
}
|
|
1525
|
+
detach() {
|
|
1526
|
+
this.host.removeEventListener("dragenter", this.bound.dragenter), this.host.removeEventListener("dragover", this.bound.dragover), this.host.removeEventListener("dragleave", this.bound.dragleave), this.host.removeEventListener("drop", this.bound.drop), this.hideOverlay();
|
|
1527
|
+
}
|
|
1528
|
+
onDragEnter(e) {
|
|
1529
|
+
$(e) && (e.preventDefault(), this.depth++, this.showOverlay());
|
|
1530
|
+
}
|
|
1531
|
+
onDragOver(e) {
|
|
1532
|
+
$(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
|
|
1533
|
+
}
|
|
1534
|
+
onDragLeave(e) {
|
|
1535
|
+
$(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
|
|
1536
|
+
}
|
|
1537
|
+
async onDrop(e) {
|
|
1538
|
+
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
1539
|
+
let t = e.dataTransfer?.files?.[0];
|
|
1540
|
+
if (t) try {
|
|
1541
|
+
let e = J(await t.text());
|
|
1542
|
+
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
1543
|
+
this.callbacks.onData(e.data, e, t);
|
|
1544
|
+
} catch (e) {
|
|
1545
|
+
this.callbacks.onError?.(e, t);
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
showOverlay() {
|
|
1549
|
+
this.overlay || (this.overlay = document.createElement("div"), Object.assign(this.overlay.style, {
|
|
1550
|
+
position: "absolute",
|
|
1551
|
+
inset: "8px",
|
|
1552
|
+
zIndex: "90",
|
|
1553
|
+
pointerEvents: "none",
|
|
1554
|
+
borderRadius: "10px",
|
|
1555
|
+
border: "2px dashed var(--tcw-accent, #4f88ff)",
|
|
1556
|
+
background: "rgba(79, 136, 255, 0.06)",
|
|
1557
|
+
display: "flex",
|
|
1558
|
+
alignItems: "center",
|
|
1559
|
+
justifyContent: "center",
|
|
1560
|
+
color: "var(--tcw-accent, #4f88ff)",
|
|
1561
|
+
fontSize: "14px",
|
|
1562
|
+
fontWeight: "600",
|
|
1563
|
+
letterSpacing: "-0.005em",
|
|
1564
|
+
fontFamily: "inherit",
|
|
1565
|
+
backdropFilter: "blur(2px)"
|
|
1566
|
+
}), this.overlay.textContent = "Drop CSV or JSON to load chart data", getComputedStyle(this.host).position === "static" && (this.host.style.position = "relative"), this.host.appendChild(this.overlay));
|
|
1567
|
+
}
|
|
1568
|
+
hideOverlay() {
|
|
1569
|
+
this.overlay?.remove(), this.overlay = null;
|
|
1570
|
+
}
|
|
1105
1571
|
};
|
|
1572
|
+
function $(e) {
|
|
1573
|
+
return e.dataTransfer?.types?.includes("Files") ?? !1;
|
|
1574
|
+
}
|
|
1106
1575
|
//#endregion
|
|
1107
|
-
export {
|
|
1576
|
+
export { B as a, V as i, J as n, L as o, Qe as r, I as s, at as t };
|
|
1108
1577
|
|
|
1109
|
-
//# sourceMappingURL=
|
|
1578
|
+
//# sourceMappingURL=DragDropImporter-Br2ez5Gz.js.map
|