@tradecanvas/chart 1.24.0 → 1.25.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/dist/Chart.d.ts +6 -0
- package/dist/Chart.d.ts.map +1 -1
- package/dist/DataManager.d.ts +9 -0
- package/dist/DataManager.d.ts.map +1 -1
- package/dist/{LayoutSession-CrMUvvtP.js → LayoutSession-BD1CfXIS.js} +185 -168
- package/dist/LayoutSession-BD1CfXIS.js.map +1 -0
- package/dist/LayoutSession-DH9V8bYi.cjs +2 -0
- package/dist/LayoutSession-DH9V8bYi.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -56
- package/dist/io/parseOHLCV.d.ts.map +1 -1
- package/dist/regularHours.d.ts.map +1 -1
- package/dist/widget/ChartWidget.d.ts +1 -0
- package/dist/widget/ChartWidget.d.ts.map +1 -1
- package/dist/widget/index.cjs +2 -2
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +946 -946
- package/dist/widget/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/LayoutSession-CdiNNoci.cjs +0 -2
- package/dist/LayoutSession-CdiNNoci.cjs.map +0 -1
- package/dist/LayoutSession-CrMUvvtP.js.map +0 -1
|
@@ -1,47 +1,47 @@
|
|
|
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,
|
|
2
|
-
import { AlertDragHandler as ce, AlertManager as le, Animator as ue, AreaRenderer as de, AxisDragHandler as fe, BarCountdown as pe, BarRenderer as me, BaselineRenderer as he, CandlestickRenderer as ge, ChartLegend as _e, ChartStateManager as
|
|
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, barTimeUnit as c, chartStyleValue as l, computePriceLimits as u, formatPrice as d, fractionTick as f, indicatorSource as p, isValidTimeZone as m, mergeBar as h, normalizeBarTime as g, parseIndicatorSource as _, priceFormatterFor as v, priceStepAt as ee, readChartStyleOverrides as y, readChartTypeOptions as b, readIndicatorPlotStyles as x, readPaneStyle as S, resolveChartTheme as te, sessionMinute as C, setLocale as ne, stepDecimals as re, tickBarCount as ie, timeframeToMs as ae, volumeColor as oe, zonedDateFormatter as se } from "@tradecanvas/commons";
|
|
2
|
+
import { AlertDragHandler as ce, AlertManager as le, Animator as ue, AreaRenderer as de, AxisDragHandler as fe, BarCountdown as pe, BarRenderer as me, BaselineRenderer as he, CandlestickRenderer as ge, ChartLegend as _e, ChartStateManager as w, CompareRenderer as ve, CompareSymbolIndicator as ye, CorrelationCoefficientIndicator as be, CorrelationLogIndicator as xe, CrosshairHandler as Se, CrosshairTooltip as Ce, CurrentPriceLine as we, DEFAULT_SESSION_HOURS as Te, DataExporter as T, DepthHeatmapRenderer as Ee, DrawingManager as De, DrawingRenderer as Oe, EquivolumeRenderer as ke, EventBus as Ae, GridRenderer as je, HLCAreaRenderer as Me, HiLoRenderer as E, HollowCandleRenderer as Ne, IndicatorEngine as D, InteractionManager as Pe, KagiRenderer as Fe, KeyboardHandler as Ie, LineRenderer as Le, LineWithMarkersRenderer as Re, MarketProfileRenderer as ze, MeasureOverlay as Be, PanHandler as Ve, PaneResizeHandler as He, PeriodLevelsRenderer as Ue, PinnedTooltip as We, PivotMarkersRenderer as Ge, PointAndFigureRenderer as O, PriceAxis as k, PriceAxisAddButton as Ke, PriceLines as qe, RenderEngine as Je, RenkoRenderer as Ye, ReplayManager as Xe, Screenshot as A, SelectionBoxOverlay as Ze, SessionBreaks as Qe, SessionShading as $e, SignalMarkerManager as et, SpreadIndicator as tt, StepLineRenderer as nt, StreamManager as rt, SymbolSeriesStore as it, TimeAxis as at, TradeZoneManager as ot, TradingManager as st, TradingRenderer as ct, UndoRedoManager as lt, Viewport as ut, VolumeCandleRenderer as dt, VolumeProfileRenderer as ft, VolumeRenderer as pt, Watermark as mt, ZoomHandler as ht, barTimeStepMs as gt, findDominantSwing as _t, gpuContextsLeft as vt, isRegularSession as yt, loadWebGL as bt, mergeSessionHours as xt, priceToY as St, rangePresetStart as Ct, readAlertOptions as wt, registerBuiltInDrawingTools as Tt, registerBuiltInIndicators as j, servesTimeframe as M, sourceParam as N, timeToX as Et, timestampToBarIndex as P, toHeikinAshi as Dt, toKagi as Ot, toLineBreak as kt, toPointAndFigure as At, toRangeBars as jt, toRenko as Mt, whenGpuContextFree as Nt, withResampling as Pt, xToBarIndex as Ft, xToTime as F, yToPrice as It } from "@tradecanvas/core";
|
|
3
3
|
//#region src/regularHours.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
4
|
+
var Lt = 864e5, Rt = 10;
|
|
5
|
+
function zt(e, t) {
|
|
6
6
|
let n = e?.timezone;
|
|
7
|
-
if (!n || !
|
|
7
|
+
if (!n || !m(n) || t.length < 2) return null;
|
|
8
8
|
let r = (e?.sessions ?? []).flatMap((e) => {
|
|
9
|
-
let t =
|
|
9
|
+
let t = C(e.start), n = C(e.end);
|
|
10
10
|
return t === null || n === null ? [] : [{
|
|
11
11
|
startMinute: t,
|
|
12
12
|
endMinute: n
|
|
13
13
|
}];
|
|
14
14
|
});
|
|
15
15
|
if (r.length === 0) return null;
|
|
16
|
-
let i = Infinity;
|
|
17
|
-
for (let e = Math.max(1, t.length -
|
|
18
|
-
let n =
|
|
19
|
-
n > 0 && n <
|
|
16
|
+
let i = c(t), a = Infinity;
|
|
17
|
+
for (let e = Math.max(1, t.length - Rt); e < t.length; e++) {
|
|
18
|
+
let n = (t[e].time - t[e - 1].time) * i;
|
|
19
|
+
n > 0 && n < a && (a = n);
|
|
20
20
|
}
|
|
21
|
-
if (!(
|
|
22
|
-
let
|
|
21
|
+
if (!(a < Lt)) return null;
|
|
22
|
+
let o = {
|
|
23
23
|
timeZone: n,
|
|
24
24
|
windows: r,
|
|
25
25
|
startMinute: r[0].startMinute,
|
|
26
26
|
endMinute: r[r.length - 1].endMinute
|
|
27
27
|
};
|
|
28
|
-
return (e) => yt(
|
|
28
|
+
return (e) => yt(e * i, o);
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/chartA11y.ts
|
|
32
|
-
var
|
|
32
|
+
var Bt = {
|
|
33
33
|
role: "chart",
|
|
34
34
|
summary: "{what}. Last price {close}.",
|
|
35
35
|
empty: "Chart, no data.",
|
|
36
36
|
view: "Showing {count} bars, {from} to {to}. High {high}, low {low}.",
|
|
37
37
|
bar: "{time}: open {open}, high {high}, low {low}, close {close}, volume {volume}.",
|
|
38
38
|
keys: "Arrow keys scroll and zoom, Home and End go to the start and the end. Comma and period read the bars one at a time."
|
|
39
|
-
}, I = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e),
|
|
39
|
+
}, I = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), Vt = [
|
|
40
40
|
"role",
|
|
41
41
|
"aria-roledescription",
|
|
42
42
|
"aria-label",
|
|
43
43
|
"aria-describedby"
|
|
44
|
-
],
|
|
44
|
+
], Ht = 400, Ut = 1e3, Wt = class {
|
|
45
45
|
live;
|
|
46
46
|
help;
|
|
47
47
|
labels;
|
|
@@ -55,20 +55,20 @@ var zt = {
|
|
|
55
55
|
};
|
|
56
56
|
constructor(e, t, n = {}) {
|
|
57
57
|
this.container = e, this.source = t, this.labels = {
|
|
58
|
-
...
|
|
58
|
+
...Bt,
|
|
59
59
|
...n
|
|
60
60
|
};
|
|
61
|
-
for (let t of
|
|
62
|
-
e.setAttribute("role", "application"), this.help =
|
|
61
|
+
for (let t of Vt) this.before.set(t, e.getAttribute(t));
|
|
62
|
+
e.setAttribute("role", "application"), this.help = Gt("div", "tc-sr-only"), this.help.id = `tc-chart-keys-${Math.random().toString(36).slice(2, 10)}`, e.setAttribute("aria-describedby", this.help.id), this.live = Gt("div", "tc-sr-only tc-sr-live"), this.live.setAttribute("aria-live", "polite"), this.live.setAttribute("aria-atomic", "true"), e.append(this.help, this.live), e.addEventListener("blur", this.onBlur), this.applyLabels();
|
|
63
63
|
}
|
|
64
64
|
setLabels(e) {
|
|
65
65
|
this.labels = {
|
|
66
|
-
...
|
|
66
|
+
...Bt,
|
|
67
67
|
...e
|
|
68
68
|
}, this.applyLabels();
|
|
69
69
|
}
|
|
70
70
|
refresh(e = !1) {
|
|
71
|
-
let t =
|
|
71
|
+
let t = Ut - (Date.now() - this.summaryAt);
|
|
72
72
|
if (e || t <= 0 || this.container.getAttribute("aria-label") === this.labels.empty) {
|
|
73
73
|
this.summaryTimer && clearTimeout(this.summaryTimer), this.summaryTimer = null, this.summaryAt = Date.now(), this.container.setAttribute("aria-label", this.summary());
|
|
74
74
|
return;
|
|
@@ -80,7 +80,7 @@ var zt = {
|
|
|
80
80
|
viewMoved() {
|
|
81
81
|
this.cursor = null, this.viewTimer && clearTimeout(this.viewTimer), this.viewTimer = setTimeout(() => {
|
|
82
82
|
this.viewTimer = null, this.say(this.viewText());
|
|
83
|
-
},
|
|
83
|
+
}, Ht);
|
|
84
84
|
}
|
|
85
85
|
readBar(e) {
|
|
86
86
|
let t = this.source.bars();
|
|
@@ -99,7 +99,7 @@ var zt = {
|
|
|
99
99
|
high: a(i.high),
|
|
100
100
|
low: a(i.low),
|
|
101
101
|
close: a(i.close),
|
|
102
|
-
volume:
|
|
102
|
+
volume: Kt(i.volume ?? 0)
|
|
103
103
|
}));
|
|
104
104
|
}
|
|
105
105
|
destroy() {
|
|
@@ -140,7 +140,7 @@ var zt = {
|
|
|
140
140
|
this.live.textContent = e;
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function Gt(e, t) {
|
|
144
144
|
let n = document.createElement(e);
|
|
145
145
|
return n.className = t, Object.assign(n.style, {
|
|
146
146
|
position: "absolute",
|
|
@@ -154,12 +154,12 @@ function Wt(e, t) {
|
|
|
154
154
|
border: "0"
|
|
155
155
|
}), n;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function Kt(e) {
|
|
158
158
|
return Number.isInteger(e) ? String(e) : e.toFixed(2);
|
|
159
159
|
}
|
|
160
160
|
//#endregion
|
|
161
161
|
//#region src/indicatorLabel.ts
|
|
162
|
-
function
|
|
162
|
+
function qt(e, t, n, r) {
|
|
163
163
|
let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0, 3).map((e) => String(Number(e.toFixed(4)))), a = typeof t.symbol == "string" && t.symbol ? [t.symbol] : [];
|
|
164
164
|
return [
|
|
165
165
|
e === "spread" && t.mode === "ratio" ? "Ratio" : r ?? e.toUpperCase(),
|
|
@@ -169,7 +169,7 @@ function Kt(e, t, n, r) {
|
|
|
169
169
|
}
|
|
170
170
|
//#endregion
|
|
171
171
|
//#region src/charts/ChartTypeStrategy.ts
|
|
172
|
-
function
|
|
172
|
+
function Jt(e) {
|
|
173
173
|
switch (e) {
|
|
174
174
|
case "candlestick":
|
|
175
175
|
case "heikinAshi":
|
|
@@ -182,23 +182,23 @@ function qt(e) {
|
|
|
182
182
|
case "baseline": return new he();
|
|
183
183
|
case "renko": return new Ye();
|
|
184
184
|
case "kagi": return new Fe();
|
|
185
|
-
case "pointAndFigure": return new
|
|
185
|
+
case "pointAndFigure": return new O();
|
|
186
186
|
case "volumeCandles": return new dt();
|
|
187
187
|
case "equivolume": return new ke();
|
|
188
188
|
case "hlcArea": return new Me();
|
|
189
189
|
case "stepLine": return new nt();
|
|
190
190
|
case "lineWithMarkers": return new Re();
|
|
191
|
-
case "hiLo": return new
|
|
191
|
+
case "hiLo": return new E();
|
|
192
192
|
default: return new ge();
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function Yt(e, t, n = {}) {
|
|
196
196
|
if (t.length === 0) return t;
|
|
197
197
|
switch (e) {
|
|
198
198
|
case "heikinAshi": return Dt(t);
|
|
199
199
|
case "renko": {
|
|
200
200
|
let e = n.renko?.boxSize;
|
|
201
|
-
return typeof e == "number" ?
|
|
201
|
+
return typeof e == "number" ? Mt(t, { brickSize: e }) : Mt(t, {
|
|
202
202
|
brickSize: 0,
|
|
203
203
|
useATR: !0,
|
|
204
204
|
atrPeriod: n.renko?.atrPeriod ?? 14
|
|
@@ -206,15 +206,15 @@ function Jt(e, t, n = {}) {
|
|
|
206
206
|
}
|
|
207
207
|
case "lineBreak": return kt(t, n.lineBreak?.lines ?? 3);
|
|
208
208
|
case "kagi": return Ot(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
|
|
209
|
-
case "pointAndFigure": return At(t,
|
|
209
|
+
case "pointAndFigure": return At(t, Zt(t, n), n.pointAndFigure?.reversal ?? 3);
|
|
210
210
|
case "rangeBars": {
|
|
211
211
|
let e = n.rangeBars?.range;
|
|
212
|
-
return jt(t, { rangeSize: typeof e == "number" ? e :
|
|
212
|
+
return jt(t, { rangeSize: typeof e == "number" ? e : Qt(t) * .005 });
|
|
213
213
|
}
|
|
214
214
|
default: return t;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function Xt(e) {
|
|
218
218
|
switch (e) {
|
|
219
219
|
case "heikinAshi":
|
|
220
220
|
case "renko":
|
|
@@ -226,29 +226,29 @@ function Yt(e) {
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
function L(e) {
|
|
229
|
-
return e !== "heikinAshi" &&
|
|
229
|
+
return e !== "heikinAshi" && Xt(e);
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function Zt(e, t = {}) {
|
|
232
232
|
let n = t.pointAndFigure?.boxSize;
|
|
233
|
-
return typeof n == "number" ? n :
|
|
233
|
+
return typeof n == "number" ? n : Qt(e) * .01;
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function Qt(e) {
|
|
236
236
|
let t = 0;
|
|
237
237
|
for (let n of e) t += n.close;
|
|
238
238
|
return t / e.length;
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function $t(e, t) {
|
|
241
241
|
let n = t?.(e);
|
|
242
|
-
return n ? n.createRenderer() :
|
|
242
|
+
return n ? n.createRenderer() : Jt(e);
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function en(e, t, n, r) {
|
|
245
245
|
if (t.length === 0) return t;
|
|
246
246
|
let i = n?.(e);
|
|
247
|
-
return i?.transform ? i.transform(t) :
|
|
247
|
+
return i?.transform ? i.transform(t) : Yt(e, t, r);
|
|
248
248
|
}
|
|
249
249
|
//#endregion
|
|
250
250
|
//#region src/state/AutoSaveScheduler.ts
|
|
251
|
-
var
|
|
251
|
+
var tn = class {
|
|
252
252
|
timer = null;
|
|
253
253
|
delayMs = 0;
|
|
254
254
|
key = null;
|
|
@@ -283,7 +283,7 @@ function R(e) {
|
|
|
283
283
|
let { open: t, high: n, low: r, close: i } = e;
|
|
284
284
|
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));
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function nn(e) {
|
|
287
287
|
return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
|
|
288
288
|
}
|
|
289
289
|
function z(e) {
|
|
@@ -296,6 +296,18 @@ function z(e) {
|
|
|
296
296
|
}
|
|
297
297
|
var B = class {
|
|
298
298
|
data = [];
|
|
299
|
+
inSeriesUnit(e) {
|
|
300
|
+
if (this.data.length === 0) return e;
|
|
301
|
+
let t = g(e);
|
|
302
|
+
return c(this.data) === 1 ? t : t / 1e3;
|
|
303
|
+
}
|
|
304
|
+
withSeriesTime(e) {
|
|
305
|
+
let t = this.inSeriesUnit(e.time);
|
|
306
|
+
return t === e.time ? e : {
|
|
307
|
+
...e,
|
|
308
|
+
time: t
|
|
309
|
+
};
|
|
310
|
+
}
|
|
299
311
|
getData() {
|
|
300
312
|
return this.data;
|
|
301
313
|
}
|
|
@@ -303,15 +315,16 @@ var B = class {
|
|
|
303
315
|
let t = [];
|
|
304
316
|
for (let n = 0; n < e.length; n++) {
|
|
305
317
|
let r = e[n];
|
|
306
|
-
R(r) && t.push(
|
|
318
|
+
R(r) && t.push(nn(r) ? r : z(r));
|
|
307
319
|
}
|
|
308
320
|
this.data = t;
|
|
309
321
|
}
|
|
310
322
|
prependBars(e) {
|
|
311
323
|
let t = this.data.length > 0 ? this.data[0].time : Infinity, n = [];
|
|
312
324
|
for (let r = 0; r < e.length; r++) {
|
|
313
|
-
|
|
314
|
-
|
|
325
|
+
if (!R(e[r])) continue;
|
|
326
|
+
let i = this.withSeriesTime(e[r]);
|
|
327
|
+
i.time >= t || n.push(nn(i) ? i : z(i));
|
|
315
328
|
}
|
|
316
329
|
if (n.length === 0) return 0;
|
|
317
330
|
n.sort((e, t) => e.time - t.time);
|
|
@@ -320,11 +333,11 @@ var B = class {
|
|
|
320
333
|
return n.length = r, this.data = n.concat(this.data), r;
|
|
321
334
|
}
|
|
322
335
|
appendBar(e) {
|
|
323
|
-
R(e) && this.data.push(z(e));
|
|
336
|
+
R(e) && this.data.push(z(this.withSeriesTime(e)));
|
|
324
337
|
}
|
|
325
338
|
updateLastBar(e) {
|
|
326
339
|
if (!R(e)) return;
|
|
327
|
-
let t = z(e);
|
|
340
|
+
let t = z(this.withSeriesTime(e));
|
|
328
341
|
if (this.data.length === 0) {
|
|
329
342
|
this.data.push(t);
|
|
330
343
|
return;
|
|
@@ -332,7 +345,7 @@ var B = class {
|
|
|
332
345
|
this.data[this.data.length - 1] = t;
|
|
333
346
|
}
|
|
334
347
|
updateLastBarFromTick(e) {
|
|
335
|
-
this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] =
|
|
348
|
+
this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] = h(this.data[this.data.length - 1], this.withSeriesTime(e))));
|
|
336
349
|
}
|
|
337
350
|
getLength() {
|
|
338
351
|
return this.data.length;
|
|
@@ -340,7 +353,7 @@ var B = class {
|
|
|
340
353
|
clear() {
|
|
341
354
|
this.data = [];
|
|
342
355
|
}
|
|
343
|
-
},
|
|
356
|
+
}, rn = 5e3, an = 6e4, on = 500, sn = class {
|
|
344
357
|
loader = null;
|
|
345
358
|
pageSize = 500;
|
|
346
359
|
loading = !1;
|
|
@@ -381,7 +394,7 @@ var B = class {
|
|
|
381
394
|
try {
|
|
382
395
|
r = await e(t, this.pageSize);
|
|
383
396
|
} catch (e) {
|
|
384
|
-
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(
|
|
397
|
+
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(an, rn * 2 ** (this.failures - 1)), this.emit({
|
|
385
398
|
state: "error",
|
|
386
399
|
count: 0,
|
|
387
400
|
error: e instanceof Error ? e.message : String(e)
|
|
@@ -411,7 +424,7 @@ var B = class {
|
|
|
411
424
|
now() {
|
|
412
425
|
return this.host.now ? this.host.now() : Date.now();
|
|
413
426
|
}
|
|
414
|
-
},
|
|
427
|
+
}, cn = class t {
|
|
415
428
|
base;
|
|
416
429
|
shape = null;
|
|
417
430
|
chartType = "candlestick";
|
|
@@ -480,7 +493,7 @@ var B = class {
|
|
|
480
493
|
return JSON.stringify(e) === JSON.stringify(this.getUserOverrides()) ? !1 : (this.user = new Map(Object.entries(e).map(([e, t]) => [e, { ...t }])), this.effective = null, !0);
|
|
481
494
|
}
|
|
482
495
|
getStyleValue(e) {
|
|
483
|
-
return
|
|
496
|
+
return l(this.base, this.merged(), e, this.chartType);
|
|
484
497
|
}
|
|
485
498
|
layer(e) {
|
|
486
499
|
return e === "host" ? this.host : this.user.get(this.base.name) ?? {};
|
|
@@ -497,7 +510,7 @@ var B = class {
|
|
|
497
510
|
};
|
|
498
511
|
//#endregion
|
|
499
512
|
//#region src/style/styleOptions.ts
|
|
500
|
-
function
|
|
513
|
+
function ln(e, t) {
|
|
501
514
|
return t ? {
|
|
502
515
|
...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
|
|
503
516
|
...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
|
|
@@ -505,22 +518,22 @@ function cn(e, t) {
|
|
|
505
518
|
...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
|
|
506
519
|
} : {};
|
|
507
520
|
}
|
|
508
|
-
function
|
|
521
|
+
function un(e) {
|
|
509
522
|
let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
|
|
510
523
|
return {
|
|
511
524
|
...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
|
|
512
525
|
...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
|
|
513
526
|
...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
|
|
514
527
|
...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
|
|
515
|
-
...
|
|
516
|
-
...
|
|
528
|
+
...ln("horizontal", n?.hLine),
|
|
529
|
+
...ln("vertical", n?.vLine),
|
|
517
530
|
...r === void 0 ? {} : { "crosshair.labelBackground": r },
|
|
518
531
|
...e.overrides
|
|
519
532
|
};
|
|
520
533
|
}
|
|
521
534
|
//#endregion
|
|
522
535
|
//#region src/layout/LayoutManager.ts
|
|
523
|
-
var
|
|
536
|
+
var dn = 200, fn = 80, V = (e) => e.position === "top" || e.position === "bottom", pn = class {
|
|
524
537
|
panels = [];
|
|
525
538
|
containerWidth = 0;
|
|
526
539
|
containerHeight = 0;
|
|
@@ -536,8 +549,8 @@ var un = 200, dn = 80, V = (e) => e.position === "top" || e.position === "bottom
|
|
|
536
549
|
this.panels.push({
|
|
537
550
|
id: e,
|
|
538
551
|
position: n,
|
|
539
|
-
size: r ?? (a ?
|
|
540
|
-
minSize: a ?
|
|
552
|
+
size: r ?? (a ? dn : t),
|
|
553
|
+
minSize: a ? fn : i,
|
|
541
554
|
content: {
|
|
542
555
|
type: "indicator",
|
|
543
556
|
indicatorInstanceId: e
|
|
@@ -606,7 +619,7 @@ var un = 200, dn = 80, V = (e) => e.position === "top" || e.position === "bottom
|
|
|
606
619
|
let r = this.panels.find((t) => t.id === e);
|
|
607
620
|
if (r) {
|
|
608
621
|
let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
|
|
609
|
-
r.position = n, a !== o && (r.size = o ?
|
|
622
|
+
r.position = n, a !== o && (r.size = o ? dn : t, r.minSize = o ? fn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
|
|
610
623
|
}
|
|
611
624
|
}
|
|
612
625
|
setPanelSize(e, t) {
|
|
@@ -722,24 +735,24 @@ var un = 200, dn = 80, V = (e) => e.position === "top" || e.position === "bottom
|
|
|
722
735
|
getMainChartRect() {
|
|
723
736
|
return this.resolve().mainChartRect;
|
|
724
737
|
}
|
|
725
|
-
},
|
|
726
|
-
function
|
|
727
|
-
let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: l } = e,
|
|
738
|
+
}, mn = 14, hn = 14, gn = 22, _n = 4;
|
|
739
|
+
function vn(e) {
|
|
740
|
+
let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: l } = e, u = e.tagPrecision ?? s(t, n), f = u, p = r === null ? [t, n] : [
|
|
728
741
|
t,
|
|
729
742
|
n,
|
|
730
743
|
r
|
|
731
744
|
], m = a;
|
|
732
745
|
for (let t of p) {
|
|
733
746
|
if (!Number.isFinite(t)) continue;
|
|
734
|
-
let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) :
|
|
735
|
-
m = Math.max(m, l(n, `500 ${c}px ${o}`) +
|
|
747
|
+
let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : d(t, u, i), r = e.format ? n : d(t, f, i);
|
|
748
|
+
m = Math.max(m, l(n, `500 ${c}px ${o}`) + mn, l(r, `bold 11px ${o}`) + hn, l(r, `600 ${c}px ${o}`) + gn);
|
|
736
749
|
}
|
|
737
|
-
return m <= a ? a : Math.ceil(m /
|
|
750
|
+
return m <= a ? a : Math.ceil(m / _n) * _n;
|
|
738
751
|
}
|
|
739
|
-
function
|
|
752
|
+
function yn(e, t) {
|
|
740
753
|
return t > e || t <= e - 12 ? t : e;
|
|
741
754
|
}
|
|
742
|
-
var
|
|
755
|
+
var bn = class {
|
|
743
756
|
netY = 0;
|
|
744
757
|
travelX = 0;
|
|
745
758
|
engaged = !1;
|
|
@@ -755,8 +768,8 @@ var yn = class {
|
|
|
755
768
|
}
|
|
756
769
|
return this.engaged;
|
|
757
770
|
}
|
|
758
|
-
},
|
|
759
|
-
function
|
|
771
|
+
}, xn = 1;
|
|
772
|
+
function Sn(e, t) {
|
|
760
773
|
return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
|
|
761
774
|
}
|
|
762
775
|
function H(e) {
|
|
@@ -770,24 +783,24 @@ function H(e) {
|
|
|
770
783
|
//#endregion
|
|
771
784
|
//#region src/plugins/registry.ts
|
|
772
785
|
var U = /* @__PURE__ */ new Map();
|
|
773
|
-
function
|
|
786
|
+
function Cn(e) {
|
|
774
787
|
U.set(H(e), e);
|
|
775
788
|
}
|
|
776
|
-
function
|
|
789
|
+
function wn(e) {
|
|
777
790
|
return U.delete(e);
|
|
778
791
|
}
|
|
779
|
-
function
|
|
792
|
+
function Tn() {
|
|
780
793
|
return [...U.values()];
|
|
781
794
|
}
|
|
782
|
-
function
|
|
795
|
+
function En() {
|
|
783
796
|
U.clear();
|
|
784
797
|
}
|
|
785
798
|
//#endregion
|
|
786
799
|
//#region src/plugins/PluginManager.ts
|
|
787
|
-
var
|
|
800
|
+
var Dn = class {
|
|
788
801
|
plugins = /* @__PURE__ */ new Map();
|
|
789
802
|
constructor(e, t = {}) {
|
|
790
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
803
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of Tn()) this.add(e);
|
|
791
804
|
for (let e of t.plugins ?? []) this.add(e);
|
|
792
805
|
}
|
|
793
806
|
register(e) {
|
|
@@ -817,15 +830,15 @@ var En = class {
|
|
|
817
830
|
add(e) {
|
|
818
831
|
this.plugins.set(H(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
819
832
|
}
|
|
820
|
-
},
|
|
833
|
+
}, On = {
|
|
821
834
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
822
835
|
orderModify: (e, t) => e.modifyOrder(t),
|
|
823
836
|
orderCancel: (e, t) => e.cancelOrder(t),
|
|
824
837
|
positionModify: (e, t) => e.modifyPosition(t),
|
|
825
838
|
positionClose: (e, t) => e.closePosition(t),
|
|
826
|
-
positionReverse: (e, t, n) =>
|
|
839
|
+
positionReverse: (e, t, n) => kn(e, t, n)
|
|
827
840
|
};
|
|
828
|
-
async function
|
|
841
|
+
async function kn(e, t, n) {
|
|
829
842
|
let { reversing: r } = n;
|
|
830
843
|
if (!r.has(t.positionId)) {
|
|
831
844
|
r.add(t.positionId);
|
|
@@ -854,7 +867,7 @@ async function On(e, t, n) {
|
|
|
854
867
|
}
|
|
855
868
|
}
|
|
856
869
|
}
|
|
857
|
-
function
|
|
870
|
+
function An(e, t) {
|
|
858
871
|
let n = [], r = null, i = {
|
|
859
872
|
positions: () => r ?? t.getPositions?.() ?? [],
|
|
860
873
|
reversing: /* @__PURE__ */ new Set()
|
|
@@ -864,8 +877,8 @@ function kn(e, t) {
|
|
|
864
877
|
e.data && t.onFill?.(e.data);
|
|
865
878
|
};
|
|
866
879
|
e.on("orders", a), e.on("positions", o), e.on("error", s), e.on("fill", c), n.push(() => e.off("orders", a), () => e.off("positions", o), () => e.off("error", s), () => e.off("fill", c));
|
|
867
|
-
for (let r of Object.keys(
|
|
868
|
-
let a =
|
|
880
|
+
for (let r of Object.keys(On)) {
|
|
881
|
+
let a = On[r], o = t.onIntent(r, (n) => {
|
|
869
882
|
Promise.resolve(a(e, n, i)).catch((e) => t.onError({
|
|
870
883
|
message: `Execution command failed: ${r}`,
|
|
871
884
|
cause: e
|
|
@@ -879,16 +892,16 @@ function kn(e, t) {
|
|
|
879
892
|
}
|
|
880
893
|
//#endregion
|
|
881
894
|
//#region src/Chart.ts
|
|
882
|
-
var
|
|
895
|
+
var jn = {
|
|
883
896
|
min: 0,
|
|
884
897
|
max: 100
|
|
885
|
-
},
|
|
898
|
+
}, Mn = "exchange";
|
|
886
899
|
function Nn(e) {
|
|
887
|
-
if (typeof e == "string" && e !== "exchange" && !
|
|
900
|
+
if (typeof e == "string" && e !== "exchange" && !m(e)) throw RangeError(`Unknown time zone: ${e}`);
|
|
888
901
|
if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
|
|
889
902
|
}
|
|
890
903
|
var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine", "crossLine"]), Bn = new Set(["verticalLine", "crossLine"]), Vn = class {
|
|
891
|
-
static version = "1.
|
|
904
|
+
static version = "1.25.0";
|
|
892
905
|
engine;
|
|
893
906
|
viewport;
|
|
894
907
|
dataManager;
|
|
@@ -956,7 +969,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
956
969
|
replayRevealMarks = !0;
|
|
957
970
|
replayOffset = 0;
|
|
958
971
|
undoRedoManager;
|
|
959
|
-
autoSaveScheduler = new
|
|
972
|
+
autoSaveScheduler = new tn((e) => this.saveState(e));
|
|
960
973
|
animator;
|
|
961
974
|
crosshairTooltip;
|
|
962
975
|
pinnedTooltip;
|
|
@@ -976,7 +989,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
976
989
|
requestedSymbols = /* @__PURE__ */ new Set();
|
|
977
990
|
gridRenderer;
|
|
978
991
|
priceAxis;
|
|
979
|
-
leftPriceAxis = new
|
|
992
|
+
leftPriceAxis = new k();
|
|
980
993
|
leftScaleRequested = !1;
|
|
981
994
|
leftAxisWidth = a;
|
|
982
995
|
leftViewport = null;
|
|
@@ -1045,11 +1058,11 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1045
1058
|
logScale: n.logScale ?? !0,
|
|
1046
1059
|
timeframes: n.timeframes ?? [],
|
|
1047
1060
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
1048
|
-
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.dataManager = new B(), this.history = new
|
|
1061
|
+
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.dataManager = new B(), this.history = new sn({
|
|
1049
1062
|
oldestTime: () => this.dataManager.getData()[0]?.time ?? null,
|
|
1050
1063
|
prepend: (e) => this.prependBars(e),
|
|
1051
1064
|
emit: (e) => this.eventBus.emit("historyLoad", e)
|
|
1052
|
-
}), this.themeManager = new
|
|
1065
|
+
}), this.themeManager = new cn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(un(t), "host", !1), this.layoutManager = new pn(), this.indicatorEngine = new D(), this.pluginManager = new Dn(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Ae(), j(this.indicatorEngine), this.indicatorEngine.register(new ye(this.symbolSeries)), this.indicatorEngine.register(new tt(this.symbolSeries)), this.indicatorEngine.register(new be(this.symbolSeries)), this.indicatorEngine.register(new xe(this.symbolSeries)), this.drawingManager = new De(), Tt(this.drawingManager), this.drawingRenderer = new Oe(this.drawingManager), this.drawingManager.setRequestRender(() => {
|
|
1053
1066
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
1054
1067
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
1055
1068
|
this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
|
|
@@ -1080,16 +1093,17 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1080
1093
|
if (e.width <= 0 || e.height <= 0) return;
|
|
1081
1094
|
let t = this.viewport.isAtEnd();
|
|
1082
1095
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
|
|
1083
|
-
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new je(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new
|
|
1096
|
+
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new je(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new k(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.timeAxis = new at(), this.crosshairHandler = new Se(), this.crosshairHandler.setLocale(this.numberLocale), this.applyTimeSpacing(), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setDataSource(() => this.crosshairSeries()), this.crosshairHandler.setCallback((e, t) => {
|
|
1084
1097
|
if (e !== null && t) {
|
|
1085
|
-
let n = this.
|
|
1086
|
-
this.chartLegend.setHoverBar(r ?? null);
|
|
1098
|
+
let n = this.crosshairSeries(), r = e >= 0 && e < n.length ? n[e] : void 0;
|
|
1099
|
+
this.chartLegend.setHoverBar(r ?? null, e > 0 ? n[e - 1] ?? null : null);
|
|
1087
1100
|
let i = this.viewport.getState(), a = t.y >= i.chartRect.y && t.y <= i.chartRect.y + i.chartRect.height;
|
|
1088
1101
|
r && a && this.features.crosshairTooltip ? this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize(), {
|
|
1089
1102
|
prevClose: e > 0 ? n[e - 1]?.close : void 0,
|
|
1090
1103
|
priceRange: i.priceRange,
|
|
1091
1104
|
plot: i.chartRect,
|
|
1092
|
-
barStepMs: gt(n)
|
|
1105
|
+
barStepMs: gt(n),
|
|
1106
|
+
timeUnit: c(n)
|
|
1093
1107
|
}) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
|
|
1094
1108
|
point: t,
|
|
1095
1109
|
bar: r,
|
|
@@ -1118,7 +1132,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1118
1132
|
},
|
|
1119
1133
|
fitContent: () => this.fitContent()
|
|
1120
1134
|
}), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
|
|
1121
|
-
this.a11y = new
|
|
1135
|
+
this.a11y = new Wt(e, {
|
|
1122
1136
|
symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
|
|
1123
1137
|
timeframe: () => this.streamTimeframe ?? "",
|
|
1124
1138
|
chartType: () => this.options.chartType ?? "candlestick",
|
|
@@ -1128,7 +1142,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1128
1142
|
formatTime: (e) => se(this.numberLocale || "en-US", {
|
|
1129
1143
|
dateStyle: "medium",
|
|
1130
1144
|
timeStyle: "short"
|
|
1131
|
-
}, this.displayTz)(e
|
|
1145
|
+
}, this.displayTz)(e * c(this.getDisplayData())),
|
|
1132
1146
|
showBar: (e) => this.setCrosshairTime(e)
|
|
1133
1147
|
}, t.a11y?.labels);
|
|
1134
1148
|
for (let e of [
|
|
@@ -1187,7 +1201,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1187
1201
|
}), this.replayManager.on("stateChange", (e) => {
|
|
1188
1202
|
this.replayRestarting || this.eventBus.emit("replayState", { state: e });
|
|
1189
1203
|
}), this.measureOverlay = new Be(), this.interactionManager = new Pe(e), this.features.panning) {
|
|
1190
|
-
let e = new
|
|
1204
|
+
let e = new bn();
|
|
1191
1205
|
this.interactionManager.setPanHandler(new Ve((t, n) => {
|
|
1192
1206
|
t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.options.autoScale = !1, this.viewport.panPriceRange(n)), this.updateViewportAndRender();
|
|
1193
1207
|
}, () => e.reset()));
|
|
@@ -1223,7 +1237,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1223
1237
|
y: t.y
|
|
1224
1238
|
});
|
|
1225
1239
|
})), this.interactionManager.setChartContextMenu((e, t) => this.eventBus.hasListeners("chartContextMenu") ? (this.eventBus.emit("chartContextMenu", this.contextAt(e, t)), !0) : !1), this.priceAxisAddButton.setEnabled(this.features.priceAxisAddButton && this.features.crosshair), this.interactionManager.setPriceAxisAddButton(this.priceAxisAddButton, (e) => {
|
|
1226
|
-
let t =
|
|
1240
|
+
let t = It(e.y, this.viewport.getState());
|
|
1227
1241
|
Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
|
|
1228
1242
|
price: t,
|
|
1229
1243
|
x: e.x,
|
|
@@ -1241,7 +1255,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1241
1255
|
let t = this.getDisplayData();
|
|
1242
1256
|
if (t.length === 0) return;
|
|
1243
1257
|
let n = this.viewport.getState(), i = n.barWidth + n.barSpacing, a = Math.round((n.offset + e.x) / i);
|
|
1244
|
-
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));
|
|
1258
|
+
a < 0 || a >= t.length || (this.pinnedTooltip.isPinned() && this.pinnedTooltip.getPinnedIndex() === a ? this.pinnedTooltip.unpin() : this.pinnedTooltip.pin(t[a], a, this.themeManager.getTheme(), c(t)), this.pinnedTooltip.reposition(this.viewport.getState(), this.dataManager.getData()[a] ?? null, a, this.themeManager.getTheme()), this.engine.requestRender(r.Overlay));
|
|
1245
1259
|
}), this.interactionManager.setSignalMarkerHitTest((e) => this.eventBus.hasListeners("signalMarkerHover") || this.eventBus.hasListeners("signalMarkerClick") ? this.signalMarkerManager.markerAt(e, this.viewport.getState()) : null, (e, t) => this.eventBus.emit("signalMarkerHover", {
|
|
1246
1260
|
marker: e,
|
|
1247
1261
|
x: t.x,
|
|
@@ -1260,7 +1274,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1260
1274
|
x: e.x,
|
|
1261
1275
|
y: e.y
|
|
1262
1276
|
}), t.length === 0) return;
|
|
1263
|
-
let r =
|
|
1277
|
+
let r = Ft(e.x, this.viewport.getState());
|
|
1264
1278
|
r < 0 || r >= t.length || this.eventBus.emit("barClick", {
|
|
1265
1279
|
bar: t[r],
|
|
1266
1280
|
barIndex: r,
|
|
@@ -1346,7 +1360,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1346
1360
|
if (a === 0) return t ?? 0;
|
|
1347
1361
|
let o = this.dataManager.getData();
|
|
1348
1362
|
if (this.crosshairHandler.setData(o), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.unpin(), this.measureOverlay.end(), this.recalcIndicators(o), i !== void 0) {
|
|
1349
|
-
let e = Math.round(
|
|
1363
|
+
let e = Math.round(P(i, this.getDisplayData()));
|
|
1350
1364
|
this.viewport.prependBars(e - r);
|
|
1351
1365
|
}
|
|
1352
1366
|
return this.updateViewportAndRender(), t ?? a;
|
|
@@ -1384,7 +1398,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1384
1398
|
}
|
|
1385
1399
|
useStreamHistory(e, t) {
|
|
1386
1400
|
if (this.hostHistoryLoader) return;
|
|
1387
|
-
let n =
|
|
1401
|
+
let n = Pt(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
|
|
1388
1402
|
if (!r || i === null || ie(i) !== null) {
|
|
1389
1403
|
this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
|
|
1390
1404
|
return;
|
|
@@ -1470,7 +1484,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1470
1484
|
return this.extendedHours;
|
|
1471
1485
|
}
|
|
1472
1486
|
sessionKeep(e) {
|
|
1473
|
-
return this.extendedHours ? null :
|
|
1487
|
+
return this.extendedHours ? null : zt(this.symbolInfo, e);
|
|
1474
1488
|
}
|
|
1475
1489
|
shownBars(e) {
|
|
1476
1490
|
let t = this.sessionKeep(e);
|
|
@@ -1583,14 +1597,14 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1583
1597
|
this.recordIndicators(e, () => this.updateIndicatorNow(e, t));
|
|
1584
1598
|
}
|
|
1585
1599
|
updateIndicatorNow(e, t) {
|
|
1586
|
-
let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ?
|
|
1600
|
+
let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? N(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
|
|
1587
1601
|
this.indicatorEngine.updateIndicator(e, t, this.dataManager.getData()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
|
|
1588
1602
|
instanceId: e,
|
|
1589
1603
|
change: "params"
|
|
1590
1604
|
}), this.requestMissingSymbols(e);
|
|
1591
1605
|
let a = this.indicatorEngine.getIndicatorConfig(e);
|
|
1592
1606
|
if (n?.placement === "overlay" && a && r && a.params[r] !== i) {
|
|
1593
|
-
let t =
|
|
1607
|
+
let t = _(a.params[r]), n = t ? this.paneHostOf(t.instanceId, e) : _(i) ? null : a.pane ?? null;
|
|
1594
1608
|
(n ?? void 0) !== a.pane && (this.indicatorEngine.setPane(e, n), this.eventBus.emit("indicatorChange", {
|
|
1595
1609
|
instanceId: e,
|
|
1596
1610
|
change: "pane"
|
|
@@ -1601,7 +1615,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1601
1615
|
paneFor(e, t, n, r) {
|
|
1602
1616
|
if (n) return this.paneHostOf(n, r);
|
|
1603
1617
|
if (e.placement !== "overlay") return null;
|
|
1604
|
-
let i =
|
|
1618
|
+
let i = N(e), a = i ? _(t[i]) : null;
|
|
1605
1619
|
return a ? this.paneHostOf(a.instanceId, r) : null;
|
|
1606
1620
|
}
|
|
1607
1621
|
paneHostOf(e, t) {
|
|
@@ -1692,7 +1706,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1692
1706
|
this.indicatorEngine.setStyleDefaults(e, null);
|
|
1693
1707
|
return;
|
|
1694
1708
|
}
|
|
1695
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
1709
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : x(n);
|
|
1696
1710
|
this.indicatorEngine.setStyleDefaults(e, {
|
|
1697
1711
|
...r,
|
|
1698
1712
|
...i ? { plots: i } : {}
|
|
@@ -1700,7 +1714,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1700
1714
|
}
|
|
1701
1715
|
setPaneStyle(e, t) {
|
|
1702
1716
|
let n = this.paneOf(e);
|
|
1703
|
-
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ?
|
|
1717
|
+
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? S(t) : null));
|
|
1704
1718
|
}
|
|
1705
1719
|
setPaneStyleNow(e, t) {
|
|
1706
1720
|
JSON.stringify(t) !== JSON.stringify(this.paneStyles.get(e) ?? null) && (t ? this.paneStyles.set(e, t) : this.paneStyles.delete(e), this.panelInfoCache = null, this.syncRenderContext(), this.engine.requestRender(), this.markStateChanged());
|
|
@@ -1719,8 +1733,8 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1719
1733
|
return this.pluginManager;
|
|
1720
1734
|
}
|
|
1721
1735
|
static indicators() {
|
|
1722
|
-
let e = new
|
|
1723
|
-
return
|
|
1736
|
+
let e = new D();
|
|
1737
|
+
return j(e), e.getAvailableIndicators();
|
|
1724
1738
|
}
|
|
1725
1739
|
setPanelPosition(e, t) {
|
|
1726
1740
|
this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
|
|
@@ -1743,8 +1757,8 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1743
1757
|
paneMoveHost(e, t) {
|
|
1744
1758
|
let n = this.indicatorEngine.getIndicatorConfig(e), r = this.indicatorEngine.getIndicatorDescriptor(e);
|
|
1745
1759
|
if (!n || !r) return;
|
|
1746
|
-
let i =
|
|
1747
|
-
if (r.placement === "overlay" && i &&
|
|
1760
|
+
let i = N(r);
|
|
1761
|
+
if (r.placement === "overlay" && i && _(n.params[i])) return;
|
|
1748
1762
|
if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
|
|
1749
1763
|
if (t === "new") {
|
|
1750
1764
|
let t = this.layoutManager.getPanels().some((t) => t.id === e);
|
|
@@ -1865,7 +1879,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1865
1879
|
}
|
|
1866
1880
|
stepAt(e) {
|
|
1867
1881
|
let t = this.symbolInfo?.minTick ?? this.priceUnit ?? void 0;
|
|
1868
|
-
return t !== void 0 && t > 0 ? t : this.marketConfig ?
|
|
1882
|
+
return t !== void 0 && t > 0 ? t : this.marketConfig ? ee(e, this.marketConfig) : void 0;
|
|
1869
1883
|
}
|
|
1870
1884
|
getPriceStep(e) {
|
|
1871
1885
|
let t = this.stepAt(e ?? this.lastClose());
|
|
@@ -1880,7 +1894,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1880
1894
|
return this.priceFormatter;
|
|
1881
1895
|
}
|
|
1882
1896
|
applyPriceFormat(e) {
|
|
1883
|
-
this.priceFormatter =
|
|
1897
|
+
this.priceFormatter = v(e), this.priceUnit = e && typeof e != "function" ? f(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
|
|
1884
1898
|
}
|
|
1885
1899
|
setTimeFormatter(e) {
|
|
1886
1900
|
this.applyTimeFormatter(e), this.engine.requestRender();
|
|
@@ -1891,7 +1905,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
1891
1905
|
formatPrice(e) {
|
|
1892
1906
|
if (this.priceFormatter) return this.priceFormatter(e);
|
|
1893
1907
|
let { min: t, max: n } = this.viewport.getState().priceRange;
|
|
1894
|
-
return
|
|
1908
|
+
return d(e, this.marketPricePrecision ?? s(t, n), this.numberLocale);
|
|
1895
1909
|
}
|
|
1896
1910
|
setDrawingTool(e) {
|
|
1897
1911
|
this.features.drawings && (e && this.features.drawingTools.length > 0 && !this.features.drawingTools.includes(e) || (e && this.setZoomAreaMode(!1), this.drawingManager.setActiveTool(e)));
|
|
@@ -2058,7 +2072,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
2058
2072
|
x: t.x,
|
|
2059
2073
|
y: t.y
|
|
2060
2074
|
};
|
|
2061
|
-
if ((e === "plot" || e === "priceAxis") && (r.price =
|
|
2075
|
+
if ((e === "plot" || e === "priceAxis") && (r.price = It(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = F(t.x, n)), e === "pane") {
|
|
2062
2076
|
let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
|
|
2063
2077
|
e && (r.pane = e.instanceId);
|
|
2064
2078
|
}
|
|
@@ -2129,7 +2143,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
2129
2143
|
for (let e of this.indicatorEngine.getActiveIndicators()) {
|
|
2130
2144
|
let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
|
|
2131
2145
|
if (!t) continue;
|
|
2132
|
-
let r =
|
|
2146
|
+
let r = qt(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
|
|
2133
2147
|
key: e,
|
|
2134
2148
|
title: e
|
|
2135
2149
|
}));
|
|
@@ -2153,11 +2167,11 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
2153
2167
|
}
|
|
2154
2168
|
getExportText(e = "csv", t = {}) {
|
|
2155
2169
|
let { bars: n, columns: r } = this.getExportData(t);
|
|
2156
|
-
return e === "json" ?
|
|
2170
|
+
return e === "json" ? T.toJSON(n, r) : T.toCSV(n, r);
|
|
2157
2171
|
}
|
|
2158
2172
|
download(e, t, n) {
|
|
2159
2173
|
let r = this.getExportText(e, n);
|
|
2160
|
-
e === "json" ?
|
|
2174
|
+
e === "json" ? T.download(r, t ?? "chart-data.json", "application/json") : T.download(r, t ?? "chart-data.csv", "text/csv");
|
|
2161
2175
|
}
|
|
2162
2176
|
setAutoSave(e, t = 5e3) {
|
|
2163
2177
|
this.autoSaveScheduler.enable(e, t);
|
|
@@ -2207,7 +2221,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
2207
2221
|
this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
|
|
2208
2222
|
}
|
|
2209
2223
|
updateIndicatorStyleNow(e, t) {
|
|
2210
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
2224
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : x(n);
|
|
2211
2225
|
this.indicatorEngine.updateIndicatorStyle(e, {
|
|
2212
2226
|
...r,
|
|
2213
2227
|
...i ? { plots: i } : {}
|
|
@@ -2317,7 +2331,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
2317
2331
|
this.features.trading && this.tradingManager.setConfig(e);
|
|
2318
2332
|
}
|
|
2319
2333
|
async connect(e) {
|
|
2320
|
-
if (!
|
|
2334
|
+
if (!M(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
|
|
2321
2335
|
this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new rt(), this.streamManager.on("snapshot", (t) => {
|
|
2322
2336
|
let n = `${this.currentSymbol}|${this.streamTimeframe}`;
|
|
2323
2337
|
this.replaySession ? this.replaySession.live.setData(t) : n === this.snapshotKey && this.dataManager.getLength() > 0 ? this.mergeSnapshot(t) : this.setData(t), this.snapshotKey = n, this.useStreamHistory(e.adapter, e.historyPageSize);
|
|
@@ -2385,7 +2399,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
2385
2399
|
async switchStream(e, t) {
|
|
2386
2400
|
if (!this.streamManager) return;
|
|
2387
2401
|
let n = this.streamAdapter;
|
|
2388
|
-
if (n && !
|
|
2402
|
+
if (n && !M(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
|
|
2389
2403
|
this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(ae(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
|
|
2390
2404
|
}
|
|
2391
2405
|
isTimeframeAllowed(e) {
|
|
@@ -2401,7 +2415,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
2401
2415
|
}
|
|
2402
2416
|
connectExecution(e, t = {}) {
|
|
2403
2417
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
2404
|
-
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown =
|
|
2418
|
+
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = An(e, {
|
|
2405
2419
|
onIntent: (e, t) => {
|
|
2406
2420
|
let n = (e) => t(e.payload);
|
|
2407
2421
|
return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
|
|
@@ -2492,18 +2506,18 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
2492
2506
|
goToTime(e) {
|
|
2493
2507
|
let t = this.getDisplayData();
|
|
2494
2508
|
if (t.length === 0 || !Number.isFinite(e)) return -1;
|
|
2495
|
-
let n = Math.max(0, Math.min(t.length - 1, Math.floor(
|
|
2509
|
+
let n = Math.max(0, Math.min(t.length - 1, Math.floor(P(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
|
|
2496
2510
|
return this.viewport.scrollBy(i - r.offset), this.updateViewportAndRender(), n;
|
|
2497
2511
|
}
|
|
2498
2512
|
setVisibleRangePreset(e) {
|
|
2499
2513
|
let t = this.getDisplayData();
|
|
2500
2514
|
if (t.length === 0) return;
|
|
2501
|
-
let n = t.length - 1, r = t
|
|
2515
|
+
let n = t.length - 1, r = c(t), i = Ct(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
|
|
2502
2516
|
if (a === null || a < t[0].time) {
|
|
2503
2517
|
this.fitContent();
|
|
2504
2518
|
return;
|
|
2505
2519
|
}
|
|
2506
|
-
let o =
|
|
2520
|
+
let o = P(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
|
|
2507
2521
|
this.viewport.zoomToBarRange(s, n + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender();
|
|
2508
2522
|
}
|
|
2509
2523
|
scrollToEnd() {
|
|
@@ -2515,9 +2529,9 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
2515
2529
|
this.viewport.scrollBy(e * (t + n)), this.updateViewportAndRender();
|
|
2516
2530
|
}
|
|
2517
2531
|
setVisibleRange(e, t) {
|
|
2518
|
-
let n = this.
|
|
2532
|
+
let n = this.getDisplayData();
|
|
2519
2533
|
if (n.length === 0) return;
|
|
2520
|
-
let r =
|
|
2534
|
+
let r = P(Math.min(e, t), n), i = P(Math.max(e, t), n);
|
|
2521
2535
|
this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
|
|
2522
2536
|
}
|
|
2523
2537
|
setPanLimits(e) {
|
|
@@ -2532,7 +2546,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
2532
2546
|
this.viewport.zoom(-.2, e / 2), this.updateViewportAndRender();
|
|
2533
2547
|
}
|
|
2534
2548
|
fitContent() {
|
|
2535
|
-
let e = this.
|
|
2549
|
+
let e = this.getDisplayData().length;
|
|
2536
2550
|
e !== 0 && (this.viewport.zoomToBarRange(0, e - 1 + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender());
|
|
2537
2551
|
}
|
|
2538
2552
|
on(e, t) {
|
|
@@ -2609,7 +2623,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
2609
2623
|
e ? this.crosshairHandler.onPointerMove(e) : this.crosshairHandler.onPointerLeave(), this.engine.requestRender(r.Hover);
|
|
2610
2624
|
}
|
|
2611
2625
|
setCrosshairTime(e) {
|
|
2612
|
-
let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(
|
|
2626
|
+
let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(P(e, t));
|
|
2613
2627
|
n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.engine.requestRender(r.Hover));
|
|
2614
2628
|
}
|
|
2615
2629
|
getData() {
|
|
@@ -2680,7 +2694,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
2680
2694
|
return this.displayTz;
|
|
2681
2695
|
}
|
|
2682
2696
|
applyTimezone() {
|
|
2683
|
-
let e = this.symbolInfo?.timezone, t = this.timezoneSetting === "exchange" ? e &&
|
|
2697
|
+
let e = this.symbolInfo?.timezone, t = this.timezoneSetting === "exchange" ? e && m(e) ? e : "UTC" : this.timezoneSetting;
|
|
2684
2698
|
this.displayTz = t, this.timeAxis.setTimezoneOffset(t), this.crosshairHandler.setTimezoneOffset(t), this.crosshairTooltip.setTimezoneOffset(t), this.pinnedTooltip.setTimezone(t), this.sessionBreaks.setTimezone(t), this.engine.requestRender();
|
|
2685
2699
|
}
|
|
2686
2700
|
setSymbolInfo(e) {
|
|
@@ -2689,13 +2703,13 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
2689
2703
|
sessions: e.sessions?.map((e) => ({ ...e }))
|
|
2690
2704
|
} : null, this.priceAxis.setPriceTick(this.symbolInfo?.minTick ?? null), this.marketConfig?.pricePrecision === void 0 && this.applyPricePrecision(this.symbolInfo?.pricePrecision ?? null);
|
|
2691
2705
|
let t = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
|
|
2692
|
-
let t =
|
|
2706
|
+
let t = C(e.start), n = C(e.end);
|
|
2693
2707
|
return t === null || n === null ? [] : [{
|
|
2694
2708
|
startMinute: t,
|
|
2695
2709
|
endMinute: n
|
|
2696
2710
|
}];
|
|
2697
2711
|
}), n = this.symbolInfo?.timezone;
|
|
2698
|
-
this.sessionShading.replaceConfig(t.length > 0 && n &&
|
|
2712
|
+
this.sessionShading.replaceConfig(t.length > 0 && n && m(n) ? {
|
|
2699
2713
|
timeZone: n,
|
|
2700
2714
|
windows: t,
|
|
2701
2715
|
startMinute: t[0].startMinute,
|
|
@@ -2769,7 +2783,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
2769
2783
|
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? vt() > 0 ? this.takeGpu(e, t, n) : (this.waitForGpu(() => void this.takeGpu(e, t, !1)), n && this.applyRenderer(null, "limit"), this.getRenderer()) : ((r || n) && this.applyRenderer(r, i), this.getRenderer());
|
|
2770
2784
|
}
|
|
2771
2785
|
waitForGpu(e) {
|
|
2772
|
-
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ?
|
|
2786
|
+
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Nt(e) : null;
|
|
2773
2787
|
}
|
|
2774
2788
|
getRenderer() {
|
|
2775
2789
|
return this.engine.getGpu() ? "webgl" : "canvas";
|
|
@@ -2787,23 +2801,23 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
2787
2801
|
this.engine.getGpu() && this.engine.renderNow();
|
|
2788
2802
|
}
|
|
2789
2803
|
screenshot(e) {
|
|
2790
|
-
this.features.screenshot && (this.freshFrame(),
|
|
2804
|
+
this.features.screenshot && (this.freshFrame(), A.download(this.container, e, this.themeManager.getTheme().background));
|
|
2791
2805
|
}
|
|
2792
2806
|
async copyScreenshot() {
|
|
2793
2807
|
if (!this.features.screenshot) return !1;
|
|
2794
2808
|
try {
|
|
2795
2809
|
this.freshFrame();
|
|
2796
|
-
let e = await
|
|
2810
|
+
let e = await A.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
|
|
2797
2811
|
return !e || !navigator.clipboard?.write || !t ? !1 : (await navigator.clipboard.write([new t({ "image/png": e })]), !0);
|
|
2798
2812
|
} catch {
|
|
2799
2813
|
return !1;
|
|
2800
2814
|
}
|
|
2801
2815
|
}
|
|
2802
2816
|
screenshotDataURL() {
|
|
2803
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
2817
|
+
return this.features.screenshot ? (this.freshFrame(), A.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
|
|
2804
2818
|
}
|
|
2805
2819
|
async screenshotBlob() {
|
|
2806
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
2820
|
+
return this.features.screenshot ? (this.freshFrame(), A.toBlob(this.container, this.themeManager.getTheme().background)) : null;
|
|
2807
2821
|
}
|
|
2808
2822
|
addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
|
|
2809
2823
|
if (!this.features.alerts) return null;
|
|
@@ -3083,7 +3097,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
3083
3097
|
return this.replayManager.getProgress();
|
|
3084
3098
|
}
|
|
3085
3099
|
captureSnapshot() {
|
|
3086
|
-
return
|
|
3100
|
+
return w.capture({
|
|
3087
3101
|
getDrawings: () => this.getDrawings(),
|
|
3088
3102
|
getTheme: () => this.themeManager.getBaseTheme(),
|
|
3089
3103
|
getAlerts: () => this.getAlerts(),
|
|
@@ -3111,8 +3125,8 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
3111
3125
|
let s = (e) => {
|
|
3112
3126
|
let t = { ...e };
|
|
3113
3127
|
for (let [e, n] of Object.entries(t)) {
|
|
3114
|
-
let i =
|
|
3115
|
-
a && (t[e] =
|
|
3128
|
+
let i = _(n), a = i && r.get(i.instanceId);
|
|
3129
|
+
a && (t[e] = p(a, i.key));
|
|
3116
3130
|
}
|
|
3117
3131
|
return t;
|
|
3118
3132
|
};
|
|
@@ -3163,7 +3177,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
3163
3177
|
let o = this.indicatorEngine.getIndicatorConfig(e);
|
|
3164
3178
|
(t.visible ?? !0) !== (o?.visible ?? !0) && this.setIndicatorVisible(e, t.visible ?? !0);
|
|
3165
3179
|
let s = t.levels ?? null;
|
|
3166
|
-
JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s), this.setPaneStyleNow(e, t.paneStyle ?
|
|
3180
|
+
JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s), this.setPaneStyleNow(e, t.paneStyle ? S(t.paneStyle) : null);
|
|
3167
3181
|
}
|
|
3168
3182
|
restorePanes(e) {
|
|
3169
3183
|
for (let [t, n] of e) t.paneSize !== void 0 && this.layoutManager.setPanelSize(n, t.paneSize), (t.paneSize !== void 0 || t.paneCollapsed) && this.layoutManager.setPanelCollapsed(n, !!t.paneCollapsed), t.paneSize !== void 0 && this.layoutManager.setPanelScale(n, {
|
|
@@ -3272,12 +3286,12 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
3272
3286
|
}
|
|
3273
3287
|
saveState(e) {
|
|
3274
3288
|
if (!this.features.saveLoad) return null;
|
|
3275
|
-
let t = this.captureSnapshot(), n =
|
|
3276
|
-
return e &&
|
|
3289
|
+
let t = this.captureSnapshot(), n = w.serialize(t);
|
|
3290
|
+
return e && w.saveToStorage(e, t), n;
|
|
3277
3291
|
}
|
|
3278
3292
|
loadState(e) {
|
|
3279
3293
|
if (!this.features.saveLoad) return;
|
|
3280
|
-
let t =
|
|
3294
|
+
let t = w.deserialize(e);
|
|
3281
3295
|
this.chartTypeOptions = t.chartTypeOptions ?? {}, this.displayDataCache = null, t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), (t.theme === "dark" || t.theme === "light") && this.setTheme(t.theme), t.version >= 3 && this.themeManager.setUserOverrides(t.overrides ?? {}) && this.styleChanged("user");
|
|
3282
3296
|
let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
|
|
3283
3297
|
if (this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
|
|
@@ -3308,16 +3322,16 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
3308
3322
|
}
|
|
3309
3323
|
loadStateFromStorage(e) {
|
|
3310
3324
|
if (!this.features.saveLoad) return !1;
|
|
3311
|
-
let t =
|
|
3312
|
-
return t ? (this.loadState(
|
|
3325
|
+
let t = w.loadFromStorage(e);
|
|
3326
|
+
return t ? (this.loadState(w.serialize(t)), !0) : !1;
|
|
3313
3327
|
}
|
|
3314
3328
|
downloadState(e) {
|
|
3315
|
-
this.features.saveLoad &&
|
|
3329
|
+
this.features.saveLoad && w.downloadFile(this.captureSnapshot(), e);
|
|
3316
3330
|
}
|
|
3317
3331
|
async loadStateFromFile() {
|
|
3318
3332
|
if (!this.features.saveLoad) return;
|
|
3319
|
-
let e = await
|
|
3320
|
-
this.loadState(
|
|
3333
|
+
let e = await w.loadFromFile();
|
|
3334
|
+
this.loadState(w.serialize(e));
|
|
3321
3335
|
}
|
|
3322
3336
|
setLocale(e) {
|
|
3323
3337
|
ne(e), this.engine.requestRender();
|
|
@@ -3351,7 +3365,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
3351
3365
|
}
|
|
3352
3366
|
getPriceLimits() {
|
|
3353
3367
|
let e = this.marketConfig;
|
|
3354
|
-
return !e?.priceLimits?.enabled || !e.priceLimits.referencePrice ? null :
|
|
3368
|
+
return !e?.priceLimits?.enabled || !e.priceLimits.referencePrice ? null : u(e.priceLimits.referencePrice, e);
|
|
3355
3369
|
}
|
|
3356
3370
|
setPriceLimits(e) {
|
|
3357
3371
|
this.marketConfig?.priceLimits && (this.marketConfig = {
|
|
@@ -3381,15 +3395,18 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
3381
3395
|
this.disposed = !0, this.waitForGpu(null), this.countdownInterval && clearInterval(this.countdownInterval), this.history.setLoader(null), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.a11y?.destroy(), this.a11y = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayRestarting = !0, this.replayManager.dispose(), this.alertManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
|
|
3382
3396
|
}
|
|
3383
3397
|
createChartRenderer(e) {
|
|
3384
|
-
let t =
|
|
3385
|
-
return t instanceof
|
|
3398
|
+
let t = $t(e, (e) => this.pluginManager.getChartType(e));
|
|
3399
|
+
return t instanceof E && t.setPriceText((e) => this.formatPrice(e)), t;
|
|
3400
|
+
}
|
|
3401
|
+
crosshairSeries() {
|
|
3402
|
+
return this.isTimeAligned() ? this.dataManager.getData() : this.getDisplayData();
|
|
3386
3403
|
}
|
|
3387
3404
|
getDisplayData() {
|
|
3388
3405
|
if (this.displayDataCache) return this.displayDataCache;
|
|
3389
3406
|
let e = this.dataManager.getData();
|
|
3390
3407
|
if (e.length === 0) return e;
|
|
3391
|
-
let t =
|
|
3392
|
-
return this.chartRenderer instanceof
|
|
3408
|
+
let t = en(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
|
|
3409
|
+
return this.chartRenderer instanceof O && !this.pluginManager.getChartType(this.options.chartType) && this.chartRenderer.setBoxSize(Zt(e, this.chartTypeOptions)), this.displayDataCache = t, t;
|
|
3393
3410
|
}
|
|
3394
3411
|
recalcIndicatorsFrom(e, t) {
|
|
3395
3412
|
this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
|
|
@@ -3448,7 +3465,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
3448
3465
|
fitLeftAxisWidth() {
|
|
3449
3466
|
let e = this.leftViewport;
|
|
3450
3467
|
if (!e) return !1;
|
|
3451
|
-
let t = this.themeManager.getTheme(), n =
|
|
3468
|
+
let t = this.themeManager.getTheme(), n = vn({
|
|
3452
3469
|
min: e.priceRange.min,
|
|
3453
3470
|
max: e.priceRange.max,
|
|
3454
3471
|
lastPrice: null,
|
|
@@ -3457,12 +3474,12 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
3457
3474
|
fontFamily: t.font.family,
|
|
3458
3475
|
fontSizeSmall: t.font.sizeSmall,
|
|
3459
3476
|
measure: (e, t) => this.measureText(e, t)
|
|
3460
|
-
}), r =
|
|
3477
|
+
}), r = yn(this.leftAxisWidth, n);
|
|
3461
3478
|
return r === this.leftAxisWidth ? !1 : (this.leftAxisWidth = r, this.layoutManager.setLeftAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
|
|
3462
3479
|
}
|
|
3463
3480
|
fitPriceAxisWidth() {
|
|
3464
3481
|
if (!this.features.priceAxis) return !1;
|
|
3465
|
-
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n =
|
|
3482
|
+
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = vn({
|
|
3466
3483
|
min: e.min,
|
|
3467
3484
|
max: e.max,
|
|
3468
3485
|
lastPrice: this.currentPriceLine.getPrice(),
|
|
@@ -3473,7 +3490,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
3473
3490
|
fontFamily: t.font.family,
|
|
3474
3491
|
fontSizeSmall: t.font.sizeSmall,
|
|
3475
3492
|
measure: (e, t) => this.measureText(e, t)
|
|
3476
|
-
}), r =
|
|
3493
|
+
}), r = yn(this.priceAxisWidth, n);
|
|
3477
3494
|
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);
|
|
3478
3495
|
}
|
|
3479
3496
|
measureText(e, t) {
|
|
@@ -3517,7 +3534,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
3517
3534
|
buildPanelRenderInfos() {
|
|
3518
3535
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
3519
3536
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
3520
|
-
let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...
|
|
3537
|
+
let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...jn }, o = {
|
|
3521
3538
|
x: e.rect.x,
|
|
3522
3539
|
y: e.rect.y + 20,
|
|
3523
3540
|
width: e.rect.width,
|
|
@@ -3599,7 +3616,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
|
|
|
3599
3616
|
});
|
|
3600
3617
|
}
|
|
3601
3618
|
drawOverlayPlugins(e, t) {
|
|
3602
|
-
let n =
|
|
3619
|
+
let n = Sn(this.pluginManager.getOverlays(), t);
|
|
3603
3620
|
if (n.length === 0) return;
|
|
3604
3621
|
let r = {
|
|
3605
3622
|
viewport: this.viewport.getState(),
|
|
@@ -3624,7 +3641,7 @@ function Hn(e) {
|
|
|
3624
3641
|
let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
3625
3642
|
if (r.has(e.instanceId) || i.has(e.instanceId)) return;
|
|
3626
3643
|
i.add(e.instanceId);
|
|
3627
|
-
let o = [e.pane, ...Object.values(e.params).map((e) =>
|
|
3644
|
+
let o = [e.pane, ...Object.values(e.params).map((e) => _(e)?.instanceId)];
|
|
3628
3645
|
for (let e of o) {
|
|
3629
3646
|
let n = e ? t.get(e) : void 0;
|
|
3630
3647
|
n && a(n);
|
|
@@ -3751,7 +3768,7 @@ function nr(e, t) {
|
|
|
3751
3768
|
function K(e, t) {
|
|
3752
3769
|
let n = e[e.length - 1];
|
|
3753
3770
|
if (!n) return "append";
|
|
3754
|
-
let r =
|
|
3771
|
+
let r = g(t.time), i = g(n.time);
|
|
3755
3772
|
return r > i ? "append" : r === i ? "update" : "stale";
|
|
3756
3773
|
}
|
|
3757
3774
|
//#endregion
|
|
@@ -3906,7 +3923,7 @@ function J(e) {
|
|
|
3906
3923
|
let t = e.trim();
|
|
3907
3924
|
if (!t) return null;
|
|
3908
3925
|
let n = Number(t);
|
|
3909
|
-
if (Number.isFinite(n) && n > 0) return n
|
|
3926
|
+
if (Number.isFinite(n) && n > 0) return g(n);
|
|
3910
3927
|
let r = Date.parse(t);
|
|
3911
3928
|
return Number.isFinite(r) ? r : null;
|
|
3912
3929
|
}
|
|
@@ -4243,6 +4260,6 @@ var Tr = class {
|
|
|
4243
4260
|
}
|
|
4244
4261
|
};
|
|
4245
4262
|
//#endregion
|
|
4246
|
-
export {
|
|
4263
|
+
export { qt as C, B as S, H as _, br as a, on as b, Vn as c, En as d, Tn as f, Sn as g, xn as h, xr as i, Mn as l, wn as m, Sr as n, vr as o, Cn as p, $ as r, lr as s, Tr as t, Dn as u, pn as v, rn as x, cn as y };
|
|
4247
4264
|
|
|
4248
|
-
//# sourceMappingURL=LayoutSession-
|
|
4265
|
+
//# sourceMappingURL=LayoutSession-BD1CfXIS.js.map
|