@tradecanvas/chart 1.2.0 → 1.3.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 +38 -34
- package/dist/Chart.d.ts +18 -1
- package/dist/Chart.d.ts.map +1 -1
- package/dist/DragDropImporter-BazeSQPD.cjs +2 -0
- package/dist/DragDropImporter-BazeSQPD.cjs.map +1 -0
- package/dist/{DragDropImporter-BcTzFeRP.js → DragDropImporter-cURSpfUb.js} +211 -163
- package/dist/DragDropImporter-cURSpfUb.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -34
- package/dist/index.js.map +1 -1
- package/dist/interaction/verticalPanGate.d.ts +22 -0
- package/dist/interaction/verticalPanGate.d.ts.map +1 -0
- package/dist/widget/WidgetHotkeySheet.d.ts +1 -1
- package/dist/widget/WidgetHotkeySheet.d.ts.map +1 -1
- package/dist/widget/WidgetLoadingOverlay.d.ts +3 -1
- package/dist/widget/WidgetLoadingOverlay.d.ts.map +1 -1
- package/dist/widget/WidgetObjectTree.d.ts +1 -1
- package/dist/widget/index.cjs +165 -69
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +99 -30
- package/dist/widget/index.js.map +1 -1
- package/dist/widget/widgetConfig.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/DragDropImporter-BcTzFeRP.js.map +0 -1
- package/dist/DragDropImporter-DZBrretS.cjs +0 -2
- package/dist/DragDropImporter-DZBrretS.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
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, autoPricePrecision as s, computePriceLimits as c, formatPrice as l, mergeBar as u, setLocale as d, timeframeToMs as f } from "@tradecanvas/commons";
|
|
2
|
-
import { AlertDragHandler as p, AlertManager as m, Animator as ee, AreaRenderer as te, AxisDragHandler as ne, BarCountdown as re, BarRenderer as ie, BaselineRenderer as ae, CandlestickRenderer as h, ChartLegend as oe, ChartStateManager as g, CompareRenderer as se, CrosshairHandler as ce, CrosshairTooltip as le, CurrentPriceLine as ue, DataExporter as _, DepthHeatmapRenderer as de, DrawingManager as fe, DrawingRenderer as pe, EquivolumeRenderer as me, EventBus as he, GridRenderer as ge, HLCAreaRenderer as _e, HollowCandleRenderer as ve, IndicatorEngine as v, InteractionManager as ye, KagiRenderer as be, KeyboardHandler as xe, LineRenderer as Se, LineWithMarkersRenderer as Ce, MarketProfileRenderer as we, MeasureOverlay as Te, PanHandler as Ee, PaneResizeHandler as De, PeriodLevelsRenderer as Oe, PinnedTooltip as ke, PivotMarkersRenderer as Ae, PointAndFigureRenderer as je, PriceAxis as Me, RenderEngine as
|
|
2
|
+
import { AlertDragHandler as p, AlertManager as m, Animator as ee, AreaRenderer as te, AxisDragHandler as ne, BarCountdown as re, BarRenderer as ie, BaselineRenderer as ae, CandlestickRenderer as h, ChartLegend as oe, ChartStateManager as g, CompareRenderer as se, CrosshairHandler as ce, CrosshairTooltip as le, CurrentPriceLine as ue, DataExporter as _, DepthHeatmapRenderer as de, DrawingManager as fe, DrawingRenderer as pe, EquivolumeRenderer as me, EventBus as he, GridRenderer as ge, HLCAreaRenderer as _e, HollowCandleRenderer as ve, IndicatorEngine as v, InteractionManager as ye, KagiRenderer as be, KeyboardHandler as xe, LineRenderer as Se, LineWithMarkersRenderer as Ce, MarketProfileRenderer as we, MeasureOverlay as Te, PanHandler as Ee, PaneResizeHandler as De, PeriodLevelsRenderer as Oe, PinnedTooltip as ke, PivotMarkersRenderer as Ae, PointAndFigureRenderer as je, PriceAxis as Me, RenderEngine as Ne, RenkoRenderer as y, ReplayManager as b, Screenshot as x, SelectionBoxOverlay as Pe, SessionBreaks as Fe, SessionShading as Ie, SignalMarkerManager as Le, StepLineRenderer as Re, StreamManager as ze, TimeAxis as Be, TradeZoneManager as Ve, TradingManager as He, TradingRenderer as Ue, UndoRedoManager as We, Viewport as Ge, VolumeCandleRenderer as Ke, VolumeProfileRenderer as qe, VolumeRenderer as Je, Watermark as Ye, ZoomHandler as Xe, barTimeStep as Ze, findDominantSwing as Qe, registerBuiltInDrawingTools as $e, registerBuiltInIndicators as S, timestampToBarIndex as C, toHeikinAshi as et, toKagi as tt, toLineBreak as nt, toPointAndFigure as rt, toRangeBars as it, toRenko as at, xToBarIndex as ot } from "@tradecanvas/core";
|
|
3
3
|
//#region src/charts/ChartTypeStrategy.ts
|
|
4
|
-
function
|
|
4
|
+
function st(e) {
|
|
5
5
|
switch (e) {
|
|
6
6
|
case "candlestick":
|
|
7
7
|
case "heikinAshi":
|
|
@@ -12,55 +12,55 @@ function w(e) {
|
|
|
12
12
|
case "bar": return new ie();
|
|
13
13
|
case "hollowCandle": return new ve();
|
|
14
14
|
case "baseline": return new ae();
|
|
15
|
-
case "renko": return new
|
|
15
|
+
case "renko": return new y();
|
|
16
16
|
case "kagi": return new be();
|
|
17
17
|
case "pointAndFigure": return new je();
|
|
18
|
-
case "volumeCandles": return new
|
|
18
|
+
case "volumeCandles": return new Ke();
|
|
19
19
|
case "equivolume": return new me();
|
|
20
20
|
case "hlcArea": return new _e();
|
|
21
|
-
case "stepLine": return new
|
|
21
|
+
case "stepLine": return new Re();
|
|
22
22
|
case "lineWithMarkers": return new Ce();
|
|
23
23
|
default: return new h();
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function ct(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 et(t);
|
|
30
|
+
case "renko": return at(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 nt(t, 3);
|
|
36
|
+
case "kagi": return tt(t, 4);
|
|
37
|
+
case "pointAndFigure": return rt(t, w(t) * .01, 3);
|
|
38
|
+
case "rangeBars": return it(t, { rangeSize: w(t) * .005 });
|
|
39
39
|
default: return t;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function w(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
|
-
function
|
|
47
|
+
function lt(e, t) {
|
|
48
48
|
let n = t?.(e);
|
|
49
|
-
return n ? n.createRenderer() :
|
|
49
|
+
return n ? n.createRenderer() : st(e);
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function ut(e, t, n) {
|
|
52
52
|
if (t.length === 0) return t;
|
|
53
53
|
let r = n?.(e);
|
|
54
|
-
return r?.transform ? r.transform(t) :
|
|
54
|
+
return r?.transform ? r.transform(t) : ct(e, t);
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/charts/IndicatorPriceRange.ts
|
|
58
|
-
var
|
|
58
|
+
var T = {
|
|
59
59
|
min: 0,
|
|
60
60
|
max: 100
|
|
61
|
-
},
|
|
62
|
-
function
|
|
63
|
-
if (!e) return { ...
|
|
61
|
+
}, E = .1;
|
|
62
|
+
function dt(e, t, n) {
|
|
63
|
+
if (!e) return { ...T };
|
|
64
64
|
let r = Infinity, i = -Infinity;
|
|
65
65
|
if (e.series) {
|
|
66
66
|
let a = Math.min(n, e.series.length - 1);
|
|
@@ -81,16 +81,16 @@ function st(e, t, n) {
|
|
|
81
81
|
a++;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
if (r === Infinity) return { ...
|
|
84
|
+
if (r === Infinity) return { ...T };
|
|
85
85
|
let a = i - r || 1;
|
|
86
86
|
return {
|
|
87
|
-
min: r - a *
|
|
88
|
-
max: i + a *
|
|
87
|
+
min: r - a * E,
|
|
88
|
+
max: i + a * E
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
//#endregion
|
|
92
92
|
//#region src/state/AutoSaveScheduler.ts
|
|
93
|
-
var
|
|
93
|
+
var ft = class {
|
|
94
94
|
timer = null;
|
|
95
95
|
delayMs = 0;
|
|
96
96
|
key = null;
|
|
@@ -120,15 +120,15 @@ var ct = class {
|
|
|
120
120
|
};
|
|
121
121
|
//#endregion
|
|
122
122
|
//#region src/DataManager.ts
|
|
123
|
-
function
|
|
123
|
+
function D(e) {
|
|
124
124
|
if (!e || typeof e.time != "number") return !1;
|
|
125
125
|
let { open: t, high: n, low: r, close: i } = e;
|
|
126
126
|
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));
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function pt(e) {
|
|
129
129
|
return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function O(e) {
|
|
132
132
|
return {
|
|
133
133
|
...e,
|
|
134
134
|
high: Math.max(e.open, e.high, e.low, e.close),
|
|
@@ -136,7 +136,7 @@ function k(e) {
|
|
|
136
136
|
volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
-
var
|
|
139
|
+
var k = class {
|
|
140
140
|
data = [];
|
|
141
141
|
getData() {
|
|
142
142
|
return this.data;
|
|
@@ -145,16 +145,16 @@ var A = class {
|
|
|
145
145
|
let t = [];
|
|
146
146
|
for (let n = 0; n < e.length; n++) {
|
|
147
147
|
let r = e[n];
|
|
148
|
-
|
|
148
|
+
D(r) && t.push(pt(r) ? r : O(r));
|
|
149
149
|
}
|
|
150
150
|
this.data = t;
|
|
151
151
|
}
|
|
152
152
|
appendBar(e) {
|
|
153
|
-
|
|
153
|
+
D(e) && this.data.push(O(e));
|
|
154
154
|
}
|
|
155
155
|
updateLastBar(e) {
|
|
156
|
-
if (!
|
|
157
|
-
let t =
|
|
156
|
+
if (!D(e)) return;
|
|
157
|
+
let t = O(e);
|
|
158
158
|
if (this.data.length === 0) {
|
|
159
159
|
this.data.push(t);
|
|
160
160
|
return;
|
|
@@ -170,7 +170,7 @@ var A = class {
|
|
|
170
170
|
clear() {
|
|
171
171
|
this.data = [];
|
|
172
172
|
}
|
|
173
|
-
},
|
|
173
|
+
}, A = class {
|
|
174
174
|
theme;
|
|
175
175
|
constructor(t) {
|
|
176
176
|
!t || t === "dark" ? this.theme = { ...e } : t === "light" ? this.theme = { ...n } : this.theme = { ...t };
|
|
@@ -181,7 +181,7 @@ var A = class {
|
|
|
181
181
|
setTheme(t) {
|
|
182
182
|
t === "dark" ? this.theme = { ...e } : t === "light" ? this.theme = { ...n } : this.theme = { ...t };
|
|
183
183
|
}
|
|
184
|
-
},
|
|
184
|
+
}, j = 200, M = 80, N = class {
|
|
185
185
|
panels = [];
|
|
186
186
|
containerWidth = 0;
|
|
187
187
|
containerHeight = 0;
|
|
@@ -194,8 +194,8 @@ var A = class {
|
|
|
194
194
|
this.panels.push({
|
|
195
195
|
id: e,
|
|
196
196
|
position: n,
|
|
197
|
-
size: r ?? (a ?
|
|
198
|
-
minSize: a ?
|
|
197
|
+
size: r ?? (a ? j : t),
|
|
198
|
+
minSize: a ? M : i,
|
|
199
199
|
content: {
|
|
200
200
|
type: "indicator",
|
|
201
201
|
indicatorInstanceId: e
|
|
@@ -209,7 +209,7 @@ var A = class {
|
|
|
209
209
|
let r = this.panels.find((t) => t.id === e);
|
|
210
210
|
if (r) {
|
|
211
211
|
let e = r.position === "left" || r.position === "right", a = n === "left" || n === "right";
|
|
212
|
-
r.position = n, e !== a && (r.size = a ?
|
|
212
|
+
r.position = n, e !== a && (r.size = a ? j : t, r.minSize = a ? M : i);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
setPanelSize(e, t) {
|
|
@@ -313,8 +313,8 @@ var A = class {
|
|
|
313
313
|
getMainChartRect() {
|
|
314
314
|
return this.resolve().mainChartRect;
|
|
315
315
|
}
|
|
316
|
-
},
|
|
317
|
-
function
|
|
316
|
+
}, mt = 14, ht = 14, gt = 22, P = 4;
|
|
317
|
+
function _t(e) {
|
|
318
318
|
let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: u } = e, d = s(t, n), f = e.tagPrecision ?? d, p = r === null ? [t, n] : [
|
|
319
319
|
t,
|
|
320
320
|
n,
|
|
@@ -323,20 +323,34 @@ function pt(e) {
|
|
|
323
323
|
for (let e of p) {
|
|
324
324
|
if (!Number.isFinite(e)) continue;
|
|
325
325
|
let t = l(e, d, i), n = l(e, f, i);
|
|
326
|
-
m = Math.max(m, u(t, `500 ${c}px ${o}`) +
|
|
326
|
+
m = Math.max(m, u(t, `500 ${c}px ${o}`) + mt, u(n, `bold 11px ${o}`) + ht, u(n, `600 ${c}px ${o}`) + gt);
|
|
327
327
|
}
|
|
328
|
-
return m <= a ? a : Math.ceil(m /
|
|
328
|
+
return m <= a ? a : Math.ceil(m / P) * P;
|
|
329
329
|
}
|
|
330
|
-
function
|
|
330
|
+
function vt(e, t) {
|
|
331
331
|
return t > e || t <= e - 12 ? t : e;
|
|
332
332
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
333
|
+
var yt = class {
|
|
334
|
+
netY = 0;
|
|
335
|
+
travelX = 0;
|
|
336
|
+
engaged = !1;
|
|
337
|
+
reset() {
|
|
338
|
+
this.netY = 0, this.travelX = 0, this.engaged = !1;
|
|
339
|
+
}
|
|
340
|
+
step(e, t, n) {
|
|
341
|
+
if (this.engaged) return !0;
|
|
342
|
+
if (this.netY += t, this.travelX += Math.abs(e), !n) this.engaged = !0;
|
|
343
|
+
else {
|
|
344
|
+
let e = Math.abs(this.netY);
|
|
345
|
+
this.engaged = e > 24 && e >= this.travelX * .5;
|
|
346
|
+
}
|
|
347
|
+
return this.engaged;
|
|
348
|
+
}
|
|
349
|
+
}, bt = 1;
|
|
350
|
+
function F(e, t) {
|
|
337
351
|
return e.filter((e) => (e.descriptor.layer ?? "overlay") === t);
|
|
338
352
|
}
|
|
339
|
-
function
|
|
353
|
+
function I(e) {
|
|
340
354
|
switch (e.kind) {
|
|
341
355
|
case "indicator": return `indicator:${e.plugin.descriptor.id}`;
|
|
342
356
|
case "drawing": return `drawing:${e.plugin.descriptor.type}`;
|
|
@@ -346,25 +360,25 @@ function L(e) {
|
|
|
346
360
|
}
|
|
347
361
|
//#endregion
|
|
348
362
|
//#region src/plugins/registry.ts
|
|
349
|
-
var
|
|
350
|
-
function
|
|
351
|
-
|
|
363
|
+
var L = /* @__PURE__ */ new Map();
|
|
364
|
+
function xt(e) {
|
|
365
|
+
L.set(I(e), e);
|
|
352
366
|
}
|
|
353
|
-
function
|
|
354
|
-
return
|
|
367
|
+
function St(e) {
|
|
368
|
+
return L.delete(e);
|
|
355
369
|
}
|
|
356
|
-
function
|
|
357
|
-
return [...
|
|
370
|
+
function R() {
|
|
371
|
+
return [...L.values()];
|
|
358
372
|
}
|
|
359
|
-
function
|
|
360
|
-
|
|
373
|
+
function Ct() {
|
|
374
|
+
L.clear();
|
|
361
375
|
}
|
|
362
376
|
//#endregion
|
|
363
377
|
//#region src/plugins/PluginManager.ts
|
|
364
|
-
var
|
|
378
|
+
var z = class {
|
|
365
379
|
plugins = /* @__PURE__ */ new Map();
|
|
366
380
|
constructor(e, t = {}) {
|
|
367
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
381
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of R()) this.add(e);
|
|
368
382
|
for (let e of t.plugins ?? []) this.add(e);
|
|
369
383
|
}
|
|
370
384
|
register(e) {
|
|
@@ -392,20 +406,20 @@ var B = class {
|
|
|
392
406
|
return e;
|
|
393
407
|
}
|
|
394
408
|
add(e) {
|
|
395
|
-
this.plugins.set(
|
|
409
|
+
this.plugins.set(I(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
396
410
|
}
|
|
397
|
-
},
|
|
411
|
+
}, B = {
|
|
398
412
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
399
413
|
orderModify: (e, t) => e.modifyOrder(t),
|
|
400
414
|
orderCancel: (e, t) => e.cancelOrder(t),
|
|
401
415
|
positionModify: (e, t) => e.modifyPosition(t),
|
|
402
416
|
positionClose: (e, t) => e.closePosition(t)
|
|
403
417
|
};
|
|
404
|
-
function
|
|
418
|
+
function wt(e, t) {
|
|
405
419
|
let n = [], r = (e) => t.setOrders(e.data ?? []), i = (e) => t.setPositions(e.data ?? []), a = (e) => t.onError(e.data ?? { message: "Execution error" });
|
|
406
420
|
e.on("orders", r), e.on("positions", i), e.on("error", a), n.push(() => e.off("orders", r), () => e.off("positions", i), () => e.off("error", a));
|
|
407
|
-
for (let r of Object.keys(
|
|
408
|
-
let i =
|
|
421
|
+
for (let r of Object.keys(B)) {
|
|
422
|
+
let i = B[r], a = t.onIntent(r, (n) => {
|
|
409
423
|
Promise.resolve(i(e, n)).catch((e) => t.onError({
|
|
410
424
|
message: `Execution command failed: ${r}`,
|
|
411
425
|
cause: e
|
|
@@ -419,8 +433,8 @@ function yt(e, t) {
|
|
|
419
433
|
}
|
|
420
434
|
//#endregion
|
|
421
435
|
//#region src/Chart.ts
|
|
422
|
-
var
|
|
423
|
-
static version = "1.
|
|
436
|
+
var Tt = class {
|
|
437
|
+
static version = "1.3.0";
|
|
424
438
|
engine;
|
|
425
439
|
viewport;
|
|
426
440
|
dataManager;
|
|
@@ -465,10 +479,12 @@ var bt = 6, xt = class {
|
|
|
465
479
|
signalMarkerManager;
|
|
466
480
|
tradeZoneManager;
|
|
467
481
|
measureOverlay;
|
|
482
|
+
selectionBoxOverlay = new Pe();
|
|
468
483
|
replayManager;
|
|
469
484
|
replayBarUnsub = null;
|
|
485
|
+
replaySeeking = !1;
|
|
470
486
|
undoRedoManager;
|
|
471
|
-
autoSaveScheduler = new
|
|
487
|
+
autoSaveScheduler = new ft((e) => this.saveState(e));
|
|
472
488
|
animator;
|
|
473
489
|
crosshairTooltip;
|
|
474
490
|
pinnedTooltip;
|
|
@@ -497,7 +513,7 @@ var bt = 6, xt = class {
|
|
|
497
513
|
drawingMagnet: n.drawingMagnet ?? !0,
|
|
498
514
|
drawingUndoRedo: n.drawingUndoRedo ?? !0,
|
|
499
515
|
trading: n.trading ?? !0,
|
|
500
|
-
tradingContextMenu: n.tradingContextMenu ?? !
|
|
516
|
+
tradingContextMenu: n.tradingContextMenu ?? !1,
|
|
501
517
|
indicators: n.indicators ?? !0,
|
|
502
518
|
indicatorIds: n.indicatorIds ?? [],
|
|
503
519
|
panning: n.panning ?? !0,
|
|
@@ -522,36 +538,48 @@ var bt = 6, xt = class {
|
|
|
522
538
|
logScale: n.logScale ?? !0,
|
|
523
539
|
timeframes: n.timeframes ?? [],
|
|
524
540
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
525
|
-
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", this.dataManager = new
|
|
541
|
+
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", this.dataManager = new k(), this.themeManager = new A(t.theme), this.layoutManager = new N(), this.indicatorEngine = new v(), this.pluginManager = new z(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new he(), S(this.indicatorEngine), this.drawingManager = new fe(), $e(this.drawingManager), this.drawingRenderer = new pe(this.drawingManager), this.drawingManager.setRequestRender(() => {
|
|
526
542
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
527
543
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
528
544
|
this.eventBus.emit(e, t);
|
|
529
|
-
}), this.undoRedoManager = new
|
|
545
|
+
}), this.undoRedoManager = new We(), 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 He({
|
|
530
546
|
enabled: this.features.trading,
|
|
531
547
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
532
|
-
}), this.tradingRenderer = new
|
|
548
|
+
}), this.tradingRenderer = new Ue(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
533
549
|
this.eventBus.emit(e, t);
|
|
534
|
-
}), this.engine = new
|
|
550
|
+
}), this.engine = new Ne(e);
|
|
535
551
|
let i = this.engine.dprManager.getContainerSize();
|
|
536
|
-
if (this.viewport = new
|
|
552
|
+
if (this.viewport = new Ge(i.width, i.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
|
|
553
|
+
freePan: t.freePan ?? !0,
|
|
554
|
+
minVisibleBars: t.panLimits?.minVisibleBars ?? 3
|
|
555
|
+
}), this.layoutManager.resize(i.width, i.height), this.engine.onContainerResize = (e) => {
|
|
537
556
|
if (e.width <= 0 || e.height <= 0) return;
|
|
538
557
|
let t = this.viewport.isAtEnd();
|
|
539
558
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
|
|
540
|
-
}, this.chartRenderer = this.createChartRenderer(t.chartType), this.gridRenderer = new ge(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new Me(), this.priceAxis.setLocale(this.numberLocale), this.timeAxis = new
|
|
559
|
+
}, this.chartRenderer = this.createChartRenderer(t.chartType), this.gridRenderer = new ge(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new Me(), this.priceAxis.setLocale(this.numberLocale), this.timeAxis = new Be(), this.crosshairHandler = new ce(), this.crosshairHandler.setLocale(this.numberLocale), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
|
|
541
560
|
if (e !== null && t) {
|
|
542
561
|
let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
|
|
543
|
-
this.chartLegend.setHoverBar(r ?? null), r && this.features.crosshairTooltip
|
|
562
|
+
if (this.chartLegend.setHoverBar(r ?? null), r && this.features.crosshairTooltip) {
|
|
563
|
+
let i = this.viewport.getState();
|
|
564
|
+
this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize(), {
|
|
565
|
+
prevClose: e > 0 ? n[e - 1]?.close : void 0,
|
|
566
|
+
priceRange: i.priceRange,
|
|
567
|
+
plot: i.chartRect,
|
|
568
|
+
barStepMs: Ze(n)
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
|
|
544
572
|
point: t,
|
|
545
573
|
bar: r,
|
|
546
574
|
barIndex: e
|
|
547
575
|
});
|
|
548
576
|
} else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null);
|
|
549
|
-
}), this.chartLegend = new oe(), this.chartLegend.setChartType(t.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new
|
|
577
|
+
}), this.chartLegend = new oe(), this.chartLegend.setChartType(t.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new Ye(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Je(), this.volumeProfile = new qe(), this.marketProfile = new we(), this.depthHeatmap = new de(), this.periodLevels = new Oe(), this.pivotMarkers = new Ae(), this.barCountdown = new re(), this.sessionBreaks = new Fe(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new Ie(), this.compareRenderer = new se(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
550
578
|
visible: t.sessionBreaks.visible ?? !0,
|
|
551
579
|
color: t.sessionBreaks.color,
|
|
552
580
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
553
581
|
lineWidth: t.sessionBreaks.lineWidth
|
|
554
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.viewport.setLogScale(!0), this.animator = new ee(), this.crosshairTooltip = new le(), this.crosshairTooltip.create(e), this.pinnedTooltip = new ke(), this.pinnedTooltip.create(e), this.keyboardHandler = new xe({
|
|
582
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.viewport.setLogScale(!0), this.animator = new ee(), this.crosshairTooltip = new le(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new ke(), this.pinnedTooltip.create(e), this.keyboardHandler = new xe({
|
|
555
583
|
scrollBars: (e) => {
|
|
556
584
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
557
585
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -571,7 +599,7 @@ var bt = 6, xt = class {
|
|
|
571
599
|
if (!this.keyboardHandler) return;
|
|
572
600
|
let t = document.activeElement;
|
|
573
601
|
t && t !== this.container && !this.container.contains(t) || t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable) || this.keyboardHandler.handleKey(e) && e.preventDefault();
|
|
574
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new ue(), this.currentPriceLine.setLocale(this.numberLocale), this.alertManager = new m(), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
|
|
602
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new ue(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new m(), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
|
|
575
603
|
let t = {
|
|
576
604
|
id: e.id,
|
|
577
605
|
price: e.price,
|
|
@@ -603,7 +631,7 @@ var bt = 6, xt = class {
|
|
|
603
631
|
message: e.message,
|
|
604
632
|
triggered: e.triggered
|
|
605
633
|
});
|
|
606
|
-
}), this.signalMarkerManager = new
|
|
634
|
+
}), this.signalMarkerManager = new Le(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
|
|
607
635
|
this.eventBus.emit("signalMarkerAdd", {
|
|
608
636
|
id: e.id,
|
|
609
637
|
source: e.source,
|
|
@@ -611,23 +639,21 @@ var bt = 6, xt = class {
|
|
|
611
639
|
});
|
|
612
640
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
613
641
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
614
|
-
}), this.tradeZoneManager = new
|
|
642
|
+
}), this.tradeZoneManager = new Ve(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
|
|
615
643
|
this.eventBus.emit("tradeZoneAdd", {
|
|
616
644
|
id: e.id,
|
|
617
645
|
direction: e.direction
|
|
618
646
|
});
|
|
619
647
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
620
648
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
621
|
-
}), this.replayManager = new
|
|
622
|
-
let e =
|
|
649
|
+
}), this.replayManager = new b(), this.measureOverlay = new Te(), this.interactionManager = new ye(e), this.features.panning) {
|
|
650
|
+
let e = new yt();
|
|
623
651
|
this.interactionManager.setPanHandler(new Ee((t, n) => {
|
|
624
|
-
t && this.viewport.scrollBy(t),
|
|
625
|
-
}, () =>
|
|
626
|
-
e = 0;
|
|
627
|
-
}));
|
|
652
|
+
t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.options.autoScale = !1, this.viewport.panPriceRange(n)), this.updateViewportAndRender();
|
|
653
|
+
}, () => e.reset()));
|
|
628
654
|
}
|
|
629
655
|
if (this.features.zooming) {
|
|
630
|
-
this.interactionManager.setZoomHandler(new
|
|
656
|
+
this.interactionManager.setZoomHandler(new Xe((e, t) => {
|
|
631
657
|
this.viewport.zoom(e, t), this.updateViewportAndRender();
|
|
632
658
|
}));
|
|
633
659
|
let e = new ne((e) => {
|
|
@@ -662,7 +688,7 @@ var bt = 6, xt = class {
|
|
|
662
688
|
x: e.x,
|
|
663
689
|
y: e.y
|
|
664
690
|
}), t.length === 0) return;
|
|
665
|
-
let n =
|
|
691
|
+
let n = ot(e.x, this.viewport.getState());
|
|
666
692
|
n < 0 || n >= t.length || this.eventBus.emit("barClick", {
|
|
667
693
|
bar: t[n],
|
|
668
694
|
barIndex: n,
|
|
@@ -684,8 +710,32 @@ var bt = 6, xt = class {
|
|
|
684
710
|
end: () => {
|
|
685
711
|
this.measureOverlay.end();
|
|
686
712
|
}
|
|
687
|
-
})
|
|
688
|
-
|
|
713
|
+
});
|
|
714
|
+
let o = (e) => {
|
|
715
|
+
let t = this.viewport.getState().chartRect;
|
|
716
|
+
return {
|
|
717
|
+
x: Math.max(t.x, Math.min(t.x + t.width, e.x)),
|
|
718
|
+
y: Math.max(t.y, Math.min(t.y + t.height, e.y))
|
|
719
|
+
};
|
|
720
|
+
};
|
|
721
|
+
this.interactionManager.setBoxSelectHandlers({
|
|
722
|
+
begin: (e) => this.selectionBoxOverlay.begin(o(e)),
|
|
723
|
+
move: (e) => this.selectionBoxOverlay.update(o(e)),
|
|
724
|
+
end: () => {
|
|
725
|
+
let e = this.selectionBoxOverlay.end();
|
|
726
|
+
if (!e || !this.features.drawings) return;
|
|
727
|
+
let t = {
|
|
728
|
+
...this.viewport.getState(),
|
|
729
|
+
data: this.getDisplayData()
|
|
730
|
+
};
|
|
731
|
+
e.isClick ? this.drawingManager.toggleSelectionAt({
|
|
732
|
+
x: e.x1,
|
|
733
|
+
y: e.y1
|
|
734
|
+
}, t) : this.drawingManager.selectInRect(e, t), this.engine.requestRender(r.Overlay);
|
|
735
|
+
},
|
|
736
|
+
cancel: () => this.selectionBoxOverlay.cancel()
|
|
737
|
+
}), this.interactionManager.setOverlayDirtyCallback((e) => {
|
|
738
|
+
this.engine.requestRender(e ? r.Hover : r.Overlay);
|
|
689
739
|
}), this.interactionManager.attach(), this.syncRenderContext(), this.engine.start();
|
|
690
740
|
}
|
|
691
741
|
setData(e) {
|
|
@@ -742,7 +792,7 @@ var bt = 6, xt = class {
|
|
|
742
792
|
}
|
|
743
793
|
static indicators() {
|
|
744
794
|
let e = new v();
|
|
745
|
-
return
|
|
795
|
+
return S(e), e.getAvailableIndicators();
|
|
746
796
|
}
|
|
747
797
|
setPanelPosition(e, t) {
|
|
748
798
|
this.layoutManager.setPanelPosition(e, t), this.engine.requestRender();
|
|
@@ -781,7 +831,7 @@ var bt = 6, xt = class {
|
|
|
781
831
|
}
|
|
782
832
|
autoFib() {
|
|
783
833
|
if (!this.features.drawings) return null;
|
|
784
|
-
let e = this.getDisplayData(), t = this.viewport.getState(), n =
|
|
834
|
+
let e = this.getDisplayData(), t = this.viewport.getState(), n = Qe(e, t.visibleRange.from, t.visibleRange.to);
|
|
785
835
|
return n ? this.addDrawing({
|
|
786
836
|
type: "fibRetracement",
|
|
787
837
|
anchors: [n[0], n[1]]
|
|
@@ -948,7 +998,7 @@ var bt = 6, xt = class {
|
|
|
948
998
|
this.features.trading && this.tradingManager.setConfig(e);
|
|
949
999
|
}
|
|
950
1000
|
async connect(e) {
|
|
951
|
-
this.disconnectStream(), this.streamManager = new
|
|
1001
|
+
this.disconnectStream(), this.streamManager = new ze(), this.streamManager.on("snapshot", (e) => {
|
|
952
1002
|
this.setData(e);
|
|
953
1003
|
}), this.streamManager.on("barClose", (e) => {
|
|
954
1004
|
let t = this.autoScrollOnNewBar && this.viewport.isAtEnd();
|
|
@@ -960,7 +1010,7 @@ var bt = 6, xt = class {
|
|
|
960
1010
|
let t = this.dataManager.getData();
|
|
961
1011
|
this.indicatorEngine.recalculateFrom(t, t.length - 1), this.scheduleRender();
|
|
962
1012
|
}), this.streamManager.on("priceChange", ({ price: e, previousClose: t }) => {
|
|
963
|
-
this.tradingManager.setCurrentPrice(e), this.currentPriceLine.setPrice(e, t ?? void 0), this.engine.requestRender(r.Overlay)
|
|
1013
|
+
this.tradingManager.setCurrentPrice(e), this.currentPriceLine.setPrice(e, t ?? void 0), this.engine.requestRender(r.Overlay);
|
|
964
1014
|
}), this.streamManager.on("connectionChange", (e) => {
|
|
965
1015
|
this.eventBus.emit("dataUpdate", { connection: e });
|
|
966
1016
|
}), this.streamManager.on("error", (e) => {
|
|
@@ -970,7 +1020,7 @@ var bt = 6, xt = class {
|
|
|
970
1020
|
if (await t.connect(e), this.streamManager !== t) return;
|
|
971
1021
|
let n = f(e.timeframe);
|
|
972
1022
|
this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
|
|
973
|
-
this.barCountdown.isVisible() && this.engine.requestRender(r.
|
|
1023
|
+
this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
|
|
974
1024
|
}, 1e3);
|
|
975
1025
|
}
|
|
976
1026
|
async switchStream(e, t) {
|
|
@@ -985,7 +1035,7 @@ var bt = 6, xt = class {
|
|
|
985
1035
|
}
|
|
986
1036
|
connectExecution(e, t = {}) {
|
|
987
1037
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
988
|
-
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown =
|
|
1038
|
+
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = wt(e, {
|
|
989
1039
|
onIntent: (e, t) => {
|
|
990
1040
|
let n = (e) => t(e.payload);
|
|
991
1041
|
return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
|
|
@@ -1005,7 +1055,7 @@ var bt = 6, xt = class {
|
|
|
1005
1055
|
return this.executionAdapter;
|
|
1006
1056
|
}
|
|
1007
1057
|
setBarCountdownVisible(e) {
|
|
1008
|
-
this.barCountdown.setVisible(e), this.engine.requestRender(r.
|
|
1058
|
+
this.barCountdown.setVisible(e), this.engine.requestRender(r.Hover);
|
|
1009
1059
|
}
|
|
1010
1060
|
setSessionBreaksVisible(e) {
|
|
1011
1061
|
this.sessionBreaks.setVisible(e), this.engine.requestRender(r.Background);
|
|
@@ -1067,21 +1117,13 @@ var bt = 6, xt = class {
|
|
|
1067
1117
|
this.viewport.scrollToEnd(), this.updateViewportAndRender();
|
|
1068
1118
|
}
|
|
1069
1119
|
setVisibleRange(e, t) {
|
|
1070
|
-
let n = this.dataManager.getData()
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
break;
|
|
1078
|
-
}
|
|
1079
|
-
let a = i - r + 1;
|
|
1080
|
-
if (a > 0) {
|
|
1081
|
-
let e = this.viewport.getState().chartRect.width, t = e / a, n = Math.max(2, t - this.viewport.getState().barSpacing);
|
|
1082
|
-
this.viewport.zoom((n - this.viewport.getState().barWidth) / this.viewport.getState().barWidth, e / 2);
|
|
1083
|
-
}
|
|
1084
|
-
this.updateViewportAndRender();
|
|
1120
|
+
let n = this.dataManager.getData();
|
|
1121
|
+
if (n.length === 0) return;
|
|
1122
|
+
let r = C(Math.min(e, t), n), i = C(Math.max(e, t), n);
|
|
1123
|
+
this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
|
|
1124
|
+
}
|
|
1125
|
+
setPanLimits(e) {
|
|
1126
|
+
this.viewport.setPanLimits(e), this.updateViewportAndRender();
|
|
1085
1127
|
}
|
|
1086
1128
|
zoomIn() {
|
|
1087
1129
|
let e = this.viewport.getState().chartRect.width;
|
|
@@ -1092,8 +1134,8 @@ var bt = 6, xt = class {
|
|
|
1092
1134
|
this.viewport.zoom(-.2, e / 2), this.updateViewportAndRender();
|
|
1093
1135
|
}
|
|
1094
1136
|
fitContent() {
|
|
1095
|
-
let e = this.dataManager.
|
|
1096
|
-
e
|
|
1137
|
+
let e = this.dataManager.getLength();
|
|
1138
|
+
e !== 0 && (this.viewport.zoomToBarRange(0, e - 1 + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender());
|
|
1097
1139
|
}
|
|
1098
1140
|
on(e, t) {
|
|
1099
1141
|
this.eventBus.on(e, t);
|
|
@@ -1129,13 +1171,13 @@ var bt = 6, xt = class {
|
|
|
1129
1171
|
return this.options.autoScale !== !1;
|
|
1130
1172
|
}
|
|
1131
1173
|
setCrosshairMode(e) {
|
|
1132
|
-
this.crosshairHandler.setMode(e), this.engine.requestRender(r.
|
|
1174
|
+
this.crosshairHandler.setMode(e), this.engine.requestRender(r.Hover);
|
|
1133
1175
|
}
|
|
1134
1176
|
getCrosshairMode() {
|
|
1135
1177
|
return this.crosshairHandler.getMode();
|
|
1136
1178
|
}
|
|
1137
1179
|
setCrosshairPosition(e) {
|
|
1138
|
-
e && this.crosshairHandler.onPointerMove(e), this.engine.requestRender(r.
|
|
1180
|
+
e && this.crosshairHandler.onPointerMove(e), this.engine.requestRender(r.Hover);
|
|
1139
1181
|
}
|
|
1140
1182
|
getData() {
|
|
1141
1183
|
return this.dataManager.getData();
|
|
@@ -1196,7 +1238,7 @@ var bt = 6, xt = class {
|
|
|
1196
1238
|
this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
|
|
1197
1239
|
}
|
|
1198
1240
|
setTimezoneOffset(e) {
|
|
1199
|
-
this.timeAxis.setTimezoneOffset(e), this.crosshairHandler.setTimezoneOffset(e), this.
|
|
1241
|
+
this.timeAxis.setTimezoneOffset(e), this.crosshairHandler.setTimezoneOffset(e), this.crosshairTooltip.setTimezoneOffset(e), this.engine.requestRender(r.UI);
|
|
1200
1242
|
}
|
|
1201
1243
|
setPivotMarkersVisible(e) {
|
|
1202
1244
|
this.pivotMarkers.setVisible(e), this.engine.requestRender(r.Overlay);
|
|
@@ -1220,31 +1262,31 @@ var bt = 6, xt = class {
|
|
|
1220
1262
|
e || this.crosshairTooltip.hide();
|
|
1221
1263
|
}
|
|
1222
1264
|
setLegend(e) {
|
|
1223
|
-
this.chartLegend.setConfig(e), this.engine.requestRender(r.
|
|
1265
|
+
this.chartLegend.setConfig(e), this.engine.requestRender(r.Hover);
|
|
1224
1266
|
}
|
|
1225
1267
|
setSymbolName(e) {
|
|
1226
|
-
this.chartLegend.setSymbol(e), this.engine.requestRender(r.
|
|
1268
|
+
this.chartLegend.setSymbol(e), this.engine.requestRender(r.Hover);
|
|
1227
1269
|
}
|
|
1228
1270
|
setStatusText(e) {
|
|
1229
|
-
this.chartLegend.setStatusText(e), this.engine.requestRender(r.
|
|
1271
|
+
this.chartLegend.setStatusText(e), this.engine.requestRender(r.Hover);
|
|
1230
1272
|
}
|
|
1231
1273
|
screenshot(e) {
|
|
1232
|
-
this.features.screenshot &&
|
|
1274
|
+
this.features.screenshot && x.download(this.container, e, this.themeManager.getTheme().background);
|
|
1233
1275
|
}
|
|
1234
1276
|
async copyScreenshot() {
|
|
1235
1277
|
if (!this.features.screenshot) return !1;
|
|
1236
1278
|
try {
|
|
1237
|
-
let e = await
|
|
1279
|
+
let e = await x.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
|
|
1238
1280
|
return !e || !navigator.clipboard?.write || !t ? !1 : (await navigator.clipboard.write([new t({ "image/png": e })]), !0);
|
|
1239
1281
|
} catch {
|
|
1240
1282
|
return !1;
|
|
1241
1283
|
}
|
|
1242
1284
|
}
|
|
1243
1285
|
screenshotDataURL() {
|
|
1244
|
-
return this.features.screenshot ?
|
|
1286
|
+
return this.features.screenshot ? x.toDataURL(this.container, this.themeManager.getTheme().background) : null;
|
|
1245
1287
|
}
|
|
1246
1288
|
async screenshotBlob() {
|
|
1247
|
-
return this.features.screenshot ?
|
|
1289
|
+
return this.features.screenshot ? x.toBlob(this.container, this.themeManager.getTheme().background) : null;
|
|
1248
1290
|
}
|
|
1249
1291
|
addAlert(e, t = "crossing", n, r = "price", i) {
|
|
1250
1292
|
if (!this.features.alerts) return null;
|
|
@@ -1311,12 +1353,12 @@ var bt = 6, xt = class {
|
|
|
1311
1353
|
this.replayManager.load(t);
|
|
1312
1354
|
let n = -1;
|
|
1313
1355
|
this.replayBarUnsub?.(), this.replayBarUnsub = this.replayManager.on("bar", ({ bar: e, index: r }) => {
|
|
1314
|
-
let i = r + 1;
|
|
1315
|
-
if (
|
|
1356
|
+
let i = r + 1, a = n > 0 && i > n && this.dataManager.getLength() === n, o = !(a && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
|
|
1357
|
+
if (a) {
|
|
1316
1358
|
for (let e = n; e < i; e++) this.dataManager.appendBar(t[e]);
|
|
1317
1359
|
this.indicatorEngine.recalculateFrom(this.dataManager.getData(), n);
|
|
1318
1360
|
} else this.dataManager.setData(t.slice(0, i)), this.indicatorEngine.recalculateAll(this.dataManager.getData());
|
|
1319
|
-
n = i, this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.updateViewportAndRender();
|
|
1361
|
+
n = i, this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.updateViewportAndRender(o);
|
|
1320
1362
|
}), this.replayManager.play(e);
|
|
1321
1363
|
}
|
|
1322
1364
|
replayPause() {
|
|
@@ -1329,7 +1371,12 @@ var bt = 6, xt = class {
|
|
|
1329
1371
|
this.replayManager.stop();
|
|
1330
1372
|
}
|
|
1331
1373
|
replaySeek(e) {
|
|
1332
|
-
this.
|
|
1374
|
+
this.replaySeeking = !0;
|
|
1375
|
+
try {
|
|
1376
|
+
this.replayManager.seekTo(e);
|
|
1377
|
+
} finally {
|
|
1378
|
+
this.replaySeeking = !1;
|
|
1379
|
+
}
|
|
1333
1380
|
}
|
|
1334
1381
|
setReplaySpeed(e) {
|
|
1335
1382
|
this.replayManager.setSpeed(e);
|
|
@@ -1380,7 +1427,7 @@ var bt = 6, xt = class {
|
|
|
1380
1427
|
d(e), this.engine.requestRender();
|
|
1381
1428
|
}
|
|
1382
1429
|
setNumberLocale(e) {
|
|
1383
|
-
this.numberLocale = e, this.priceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.chartLegend.setLocale(e), this.sessionBreaks.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
|
|
1430
|
+
this.numberLocale = e, this.priceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.chartLegend.setLocale(e), this.crosshairTooltip.setLocale(e), this.sessionBreaks.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
|
|
1384
1431
|
}
|
|
1385
1432
|
getNumberLocale() {
|
|
1386
1433
|
return this.numberLocale;
|
|
@@ -1398,7 +1445,7 @@ var bt = 6, xt = class {
|
|
|
1398
1445
|
};
|
|
1399
1446
|
this.themeManager.setTheme(t);
|
|
1400
1447
|
}
|
|
1401
|
-
e.pricePrecision !== void 0 && (this.tradingManager.setConfig({ pricePrecision: e.pricePrecision }), this.alertManager.setPricePrecision(e.pricePrecision), this.streamManager?.priceLine.setPricePrecision(e.pricePrecision), this.currentPriceLine.setPricePrecision(e.pricePrecision), this.crosshairHandler.setPricePrecision(e.pricePrecision), this.chartLegend.setPricePrecision(e.pricePrecision)), this.updateViewportAndRender();
|
|
1448
|
+
e.pricePrecision !== void 0 && (this.tradingManager.setConfig({ pricePrecision: e.pricePrecision }), this.alertManager.setPricePrecision(e.pricePrecision), this.streamManager?.priceLine.setPricePrecision(e.pricePrecision), this.currentPriceLine.setPricePrecision(e.pricePrecision), this.crosshairHandler.setPricePrecision(e.pricePrecision), this.chartLegend.setPricePrecision(e.pricePrecision), this.crosshairTooltip.setPricePrecision(e.pricePrecision)), this.updateViewportAndRender();
|
|
1402
1449
|
}
|
|
1403
1450
|
getMarket() {
|
|
1404
1451
|
return this.marketConfig;
|
|
@@ -1428,13 +1475,13 @@ var bt = 6, xt = class {
|
|
|
1428
1475
|
this.countdownInterval && clearInterval(this.countdownInterval), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), 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 = "";
|
|
1429
1476
|
}
|
|
1430
1477
|
createChartRenderer(e) {
|
|
1431
|
-
return
|
|
1478
|
+
return lt(e, (e) => this.pluginManager.getChartType(e));
|
|
1432
1479
|
}
|
|
1433
1480
|
getDisplayData() {
|
|
1434
1481
|
if (this.displayDataCache) return this.displayDataCache;
|
|
1435
1482
|
let e = this.dataManager.getData();
|
|
1436
1483
|
if (e.length === 0) return e;
|
|
1437
|
-
let t =
|
|
1484
|
+
let t = ut(this.options.chartType, e, (e) => this.pluginManager.getChartType(e));
|
|
1438
1485
|
return this.displayDataCache = t, t;
|
|
1439
1486
|
}
|
|
1440
1487
|
scheduleRender() {
|
|
@@ -1469,7 +1516,7 @@ var bt = 6, xt = class {
|
|
|
1469
1516
|
}
|
|
1470
1517
|
fitPriceAxisWidth() {
|
|
1471
1518
|
if (!this.features.priceAxis) return !1;
|
|
1472
|
-
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n =
|
|
1519
|
+
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = _t({
|
|
1473
1520
|
min: e.min,
|
|
1474
1521
|
max: e.max,
|
|
1475
1522
|
lastPrice: this.currentPriceLine.getPrice(),
|
|
@@ -1478,7 +1525,7 @@ var bt = 6, xt = class {
|
|
|
1478
1525
|
fontFamily: t.font.family,
|
|
1479
1526
|
fontSizeSmall: t.font.sizeSmall,
|
|
1480
1527
|
measure: (e, t) => this.measureText(e, t)
|
|
1481
|
-
}), r =
|
|
1528
|
+
}), r = vt(this.priceAxisWidth, n);
|
|
1482
1529
|
return r === this.priceAxisWidth ? !1 : (this.priceAxisWidth = r, this.layoutManager.setPriceAxisWidth(r), this.viewport.setPriceAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
|
|
1483
1530
|
}
|
|
1484
1531
|
measureText(e, t) {
|
|
@@ -1514,7 +1561,7 @@ var bt = 6, xt = class {
|
|
|
1514
1561
|
buildPanelRenderInfos() {
|
|
1515
1562
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
1516
1563
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
1517
|
-
let i =
|
|
1564
|
+
let i = dt(this.indicatorEngine.getOutput(e.config.id), n, r), a = {
|
|
1518
1565
|
x: e.rect.x,
|
|
1519
1566
|
y: e.rect.y + 20,
|
|
1520
1567
|
width: e.rect.width,
|
|
@@ -1559,6 +1606,7 @@ var bt = 6, xt = class {
|
|
|
1559
1606
|
compareRenderer: this.compareRenderer,
|
|
1560
1607
|
alertManager: this.features.alerts ? this.alertManager : null,
|
|
1561
1608
|
measureOverlay: this.measureOverlay,
|
|
1609
|
+
selectionBoxOverlay: this.selectionBoxOverlay,
|
|
1562
1610
|
signalMarkerManager: this.signalMarkerManager,
|
|
1563
1611
|
tradeZoneManager: this.tradeZoneManager,
|
|
1564
1612
|
panels: t,
|
|
@@ -1575,7 +1623,7 @@ var bt = 6, xt = class {
|
|
|
1575
1623
|
});
|
|
1576
1624
|
}
|
|
1577
1625
|
drawOverlayPlugins(e, t) {
|
|
1578
|
-
let n =
|
|
1626
|
+
let n = F(this.pluginManager.getOverlays(), t);
|
|
1579
1627
|
if (n.length === 0) return;
|
|
1580
1628
|
let r = {
|
|
1581
1629
|
viewport: this.viewport.getState(),
|
|
@@ -1596,26 +1644,26 @@ var bt = 6, xt = class {
|
|
|
1596
1644
|
} : void 0
|
|
1597
1645
|
} : null;
|
|
1598
1646
|
}
|
|
1599
|
-
},
|
|
1647
|
+
}, V = [
|
|
1600
1648
|
"time",
|
|
1601
1649
|
"timestamp",
|
|
1602
1650
|
"date",
|
|
1603
1651
|
"datetime",
|
|
1604
1652
|
"t"
|
|
1605
|
-
],
|
|
1653
|
+
], H = ["open", "o"], U = ["high", "h"], W = ["low", "l"], G = ["close", "c"], K = [
|
|
1606
1654
|
"volume",
|
|
1607
1655
|
"vol",
|
|
1608
1656
|
"v"
|
|
1609
1657
|
];
|
|
1610
|
-
function
|
|
1658
|
+
function q(e) {
|
|
1611
1659
|
let t = e.trim();
|
|
1612
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
1660
|
+
return t ? t[0] === "[" || t[0] === "{" ? Et(t) : Dt(t) : {
|
|
1613
1661
|
data: [],
|
|
1614
1662
|
rowCount: 0,
|
|
1615
1663
|
skipped: 0
|
|
1616
1664
|
};
|
|
1617
1665
|
}
|
|
1618
|
-
function
|
|
1666
|
+
function Et(e) {
|
|
1619
1667
|
let t;
|
|
1620
1668
|
try {
|
|
1621
1669
|
t = JSON.parse(e);
|
|
@@ -1625,19 +1673,19 @@ function St(e) {
|
|
|
1625
1673
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
1626
1674
|
let n = [], r = 0;
|
|
1627
1675
|
for (let e of t) {
|
|
1628
|
-
let t = Array.isArray(e) ?
|
|
1676
|
+
let t = Array.isArray(e) ? At(e) : Y(e);
|
|
1629
1677
|
t ? n.push(t) : r++;
|
|
1630
1678
|
}
|
|
1631
1679
|
return Q(n, t.length, r);
|
|
1632
1680
|
}
|
|
1633
|
-
function
|
|
1681
|
+
function Dt(e) {
|
|
1634
1682
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
1635
1683
|
if (t.length === 0) return {
|
|
1636
1684
|
data: [],
|
|
1637
1685
|
rowCount: 0,
|
|
1638
1686
|
skipped: 0
|
|
1639
1687
|
};
|
|
1640
|
-
let n =
|
|
1688
|
+
let n = Ot(t[0]), r = J(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? kt(r) : {
|
|
1641
1689
|
time: 0,
|
|
1642
1690
|
open: 1,
|
|
1643
1691
|
high: 2,
|
|
@@ -1648,7 +1696,7 @@ function Ct(e) {
|
|
|
1648
1696
|
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");
|
|
1649
1697
|
let o = [], s = 0;
|
|
1650
1698
|
for (let e = +!!i; e < t.length; e++) {
|
|
1651
|
-
let r =
|
|
1699
|
+
let r = J(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;
|
|
1652
1700
|
if (i === null || ![
|
|
1653
1701
|
c,
|
|
1654
1702
|
l,
|
|
@@ -1669,7 +1717,7 @@ function Ct(e) {
|
|
|
1669
1717
|
}
|
|
1670
1718
|
return Q(o, t.length - +!!i, s);
|
|
1671
1719
|
}
|
|
1672
|
-
function
|
|
1720
|
+
function Ot(e) {
|
|
1673
1721
|
let t = {
|
|
1674
1722
|
",": 0,
|
|
1675
1723
|
";": 0,
|
|
@@ -1681,7 +1729,7 @@ function wt(e) {
|
|
|
1681
1729
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
1682
1730
|
return n;
|
|
1683
1731
|
}
|
|
1684
|
-
function
|
|
1732
|
+
function J(e, t) {
|
|
1685
1733
|
let n = [], r = "", i = !1;
|
|
1686
1734
|
for (let a = 0; a < e.length; a++) {
|
|
1687
1735
|
let o = e[a];
|
|
@@ -1689,25 +1737,25 @@ function Y(e, t) {
|
|
|
1689
1737
|
}
|
|
1690
1738
|
return n.push(r), n;
|
|
1691
1739
|
}
|
|
1692
|
-
function
|
|
1740
|
+
function kt(e) {
|
|
1693
1741
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
1694
1742
|
return {
|
|
1695
|
-
time: t(
|
|
1696
|
-
open: t(
|
|
1697
|
-
high: t(
|
|
1698
|
-
low: t(
|
|
1699
|
-
close: t(
|
|
1700
|
-
volume: t(
|
|
1743
|
+
time: t(V),
|
|
1744
|
+
open: t(H),
|
|
1745
|
+
high: t(U),
|
|
1746
|
+
low: t(W),
|
|
1747
|
+
close: t(G),
|
|
1748
|
+
volume: t(K)
|
|
1701
1749
|
};
|
|
1702
1750
|
}
|
|
1703
|
-
function
|
|
1751
|
+
function Y(e) {
|
|
1704
1752
|
let t = (t) => {
|
|
1705
1753
|
for (let n of t) {
|
|
1706
1754
|
if (e[n] !== void 0) return e[n];
|
|
1707
1755
|
let t = n.toUpperCase();
|
|
1708
1756
|
if (e[t] !== void 0) return e[t];
|
|
1709
1757
|
}
|
|
1710
|
-
}, n = Z(String(t(
|
|
1758
|
+
}, n = Z(String(t(V) ?? "")), r = Number(t(H)), i = Number(t(U)), a = Number(t(W)), o = Number(t(G)), s = Number(t(K) ?? 0);
|
|
1711
1759
|
return n === null || ![
|
|
1712
1760
|
r,
|
|
1713
1761
|
i,
|
|
@@ -1722,7 +1770,7 @@ function Et(e) {
|
|
|
1722
1770
|
volume: Number.isFinite(s) ? s : 0
|
|
1723
1771
|
};
|
|
1724
1772
|
}
|
|
1725
|
-
function
|
|
1773
|
+
function At(e) {
|
|
1726
1774
|
if (e.length < 5) return null;
|
|
1727
1775
|
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;
|
|
1728
1776
|
return t === null || ![
|
|
@@ -1762,7 +1810,7 @@ function Q(e, t, n) {
|
|
|
1762
1810
|
}
|
|
1763
1811
|
//#endregion
|
|
1764
1812
|
//#region src/io/DragDropImporter.ts
|
|
1765
|
-
var
|
|
1813
|
+
var jt = class {
|
|
1766
1814
|
host;
|
|
1767
1815
|
overlay = null;
|
|
1768
1816
|
callbacks;
|
|
@@ -1795,7 +1843,7 @@ var Ot = class {
|
|
|
1795
1843
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
1796
1844
|
let t = e.dataTransfer?.files?.[0];
|
|
1797
1845
|
if (t) try {
|
|
1798
|
-
let e =
|
|
1846
|
+
let e = q(await t.text());
|
|
1799
1847
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
1800
1848
|
this.callbacks.onData(e.data, e, t);
|
|
1801
1849
|
} catch (e) {
|
|
@@ -1809,12 +1857,12 @@ var Ot = class {
|
|
|
1809
1857
|
zIndex: "90",
|
|
1810
1858
|
pointerEvents: "none",
|
|
1811
1859
|
borderRadius: "10px",
|
|
1812
|
-
border: "2px dashed var(--tcw-accent, #
|
|
1860
|
+
border: "2px dashed var(--tcw-accent, #f2a93b)",
|
|
1813
1861
|
background: "rgba(79, 136, 255, 0.06)",
|
|
1814
1862
|
display: "flex",
|
|
1815
1863
|
alignItems: "center",
|
|
1816
1864
|
justifyContent: "center",
|
|
1817
|
-
color: "var(--tcw-accent, #
|
|
1865
|
+
color: "var(--tcw-accent, #f2a93b)",
|
|
1818
1866
|
fontSize: "14px",
|
|
1819
1867
|
fontWeight: "600",
|
|
1820
1868
|
letterSpacing: "-0.005em",
|
|
@@ -1830,6 +1878,6 @@ function $(e) {
|
|
|
1830
1878
|
return e.dataTransfer?.types?.includes("Files") ?? !1;
|
|
1831
1879
|
}
|
|
1832
1880
|
//#endregion
|
|
1833
|
-
export {
|
|
1881
|
+
export { Ct as a, St as c, I as d, N as f, z as i, bt as l, k as m, q as n, R as o, A as p, Tt as r, xt as s, jt as t, F as u };
|
|
1834
1882
|
|
|
1835
|
-
//# sourceMappingURL=DragDropImporter-
|
|
1883
|
+
//# sourceMappingURL=DragDropImporter-cURSpfUb.js.map
|