@tradecanvas/chart 1.17.0 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Chart.d.ts +14 -0
- package/dist/Chart.d.ts.map +1 -1
- package/dist/{LayoutSession-DW5fcwzw.js → LayoutSession-B_rgyCMe.js} +195 -184
- package/dist/LayoutSession-B_rgyCMe.js.map +1 -0
- package/dist/LayoutSession-Cwy_y_BO.cjs +2 -0
- package/dist/LayoutSession-Cwy_y_BO.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -37
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/overlayScale.d.ts +48 -0
- package/dist/plugins/overlayScale.d.ts.map +1 -0
- package/dist/widget/ChartWidget.d.ts.map +1 -1
- package/dist/widget/WidgetDrawingSettings.d.ts +9 -0
- package/dist/widget/WidgetDrawingSettings.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 +11 -2
- package/dist/widget/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/LayoutSession-CDdbkamp.cjs +0 -2
- package/dist/LayoutSession-CDdbkamp.cjs.map +0 -1
- package/dist/LayoutSession-DW5fcwzw.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
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, chartStyleValue as c, computePriceLimits as l, formatPrice as u, fractionTick as d, indicatorSource as f, isValidTimeZone as p, mergeBar as m, normalizeBarTime as h, parseIndicatorSource as g, priceFormatterFor as _, readChartStyleOverrides as v, readChartTypeOptions as y, readIndicatorPlotStyles as ee, readPaneStyle as
|
|
2
|
-
import { AlertDragHandler 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, chartStyleValue as c, computePriceLimits as l, formatPrice as u, fractionTick as d, indicatorSource as f, isValidTimeZone as p, mergeBar as m, normalizeBarTime as h, parseIndicatorSource as g, priceFormatterFor as _, readChartStyleOverrides as v, readChartTypeOptions as y, readIndicatorPlotStyles as ee, readPaneStyle as te, resolveChartTheme as ne, sessionMinute as b, setLocale as re, stepDecimals as ie, tickBarCount as ae, timeframeToMs as x, volumeColor as S, zonedDateFormatter as oe } from "@tradecanvas/commons";
|
|
2
|
+
import { AlertDragHandler as se, AlertManager as ce, Animator as le, AreaRenderer as ue, AxisDragHandler as de, BarCountdown as fe, BarRenderer as pe, BaselineRenderer as me, CandlestickRenderer as he, ChartLegend as ge, ChartStateManager as C, CompareRenderer as _e, CompareSymbolIndicator as ve, CorrelationCoefficientIndicator as ye, CorrelationLogIndicator as be, CrosshairHandler as xe, CrosshairTooltip as Se, CurrentPriceLine as Ce, DEFAULT_SESSION_HOURS as we, DataExporter as w, DepthHeatmapRenderer as Te, DrawingManager as Ee, DrawingRenderer as De, EquivolumeRenderer as Oe, EventBus as ke, GridRenderer as Ae, HLCAreaRenderer as je, HiLoRenderer as Me, HollowCandleRenderer as Ne, IndicatorEngine as Pe, InteractionManager as Fe, KagiRenderer as Ie, KeyboardHandler as Le, LineRenderer as Re, LineWithMarkersRenderer as ze, MarketProfileRenderer as Be, MeasureOverlay as Ve, PanHandler as He, PaneResizeHandler as Ue, PeriodLevelsRenderer as We, PinnedTooltip as Ge, PivotMarkersRenderer as Ke, PointAndFigureRenderer as T, PriceAxis as qe, PriceAxisAddButton as Je, PriceLines as Ye, RenderEngine as Xe, RenkoRenderer as Ze, ReplayManager as Qe, Screenshot as E, SelectionBoxOverlay as $e, SessionBreaks as et, SessionShading as tt, SignalMarkerManager as nt, SpreadIndicator as rt, StepLineRenderer as it, StreamManager as at, SymbolSeriesStore as ot, TimeAxis as st, TradeZoneManager as ct, TradingManager as lt, TradingRenderer as ut, UndoRedoManager as dt, Viewport as ft, VolumeCandleRenderer as pt, VolumeProfileRenderer as mt, VolumeRenderer as ht, Watermark as gt, ZoomHandler as _t, barTimeStepMs as vt, findDominantSwing as yt, gpuContextsLeft as bt, isRegularSession as xt, loadWebGL as St, mergeSessionHours as Ct, rangePresetStart as wt, readAlertOptions as Tt, registerBuiltInDrawingTools as Et, registerBuiltInIndicators as Dt, servesTimeframe as Ot, sourceParam as D, timestampToBarIndex as O, toHeikinAshi as kt, toKagi as At, toLineBreak as jt, toPointAndFigure as Mt, toRangeBars as Nt, toRenko as k, whenGpuContextFree as Pt, withResampling as Ft, xToBarIndex as It, xToTime as A, yToPrice as Lt } from "@tradecanvas/core";
|
|
3
3
|
//#region src/regularHours.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
4
|
+
var Rt = 864e5, zt = 10;
|
|
5
|
+
function Bt(e, t) {
|
|
6
6
|
let n = e?.timezone;
|
|
7
7
|
if (!n || !p(n) || t.length < 2) return null;
|
|
8
8
|
let r = (e?.sessions ?? []).flatMap((e) => {
|
|
9
|
-
let t =
|
|
9
|
+
let t = b(e.start), n = b(e.end);
|
|
10
10
|
return t === null || n === null ? [] : [{
|
|
11
11
|
startMinute: t,
|
|
12
12
|
endMinute: n
|
|
@@ -14,34 +14,34 @@ function Vt(e, t) {
|
|
|
14
14
|
});
|
|
15
15
|
if (r.length === 0) return null;
|
|
16
16
|
let i = Infinity;
|
|
17
|
-
for (let e = Math.max(1, t.length -
|
|
17
|
+
for (let e = Math.max(1, t.length - zt); e < t.length; e++) {
|
|
18
18
|
let n = h(t[e].time) - h(t[e - 1].time);
|
|
19
19
|
n > 0 && n < i && (i = n);
|
|
20
20
|
}
|
|
21
|
-
if (!(i <
|
|
21
|
+
if (!(i < Rt)) return null;
|
|
22
22
|
let a = {
|
|
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) =>
|
|
28
|
+
return (e) => xt(h(e), a);
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/chartA11y.ts
|
|
32
|
-
var
|
|
32
|
+
var Vt = {
|
|
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
|
-
},
|
|
39
|
+
}, j = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), Ht = [
|
|
40
40
|
"role",
|
|
41
41
|
"aria-roledescription",
|
|
42
42
|
"aria-label",
|
|
43
43
|
"aria-describedby"
|
|
44
|
-
],
|
|
44
|
+
], Ut = 400, Wt = 1e3, Gt = class {
|
|
45
45
|
live;
|
|
46
46
|
help;
|
|
47
47
|
labels;
|
|
@@ -55,20 +55,20 @@ var Ht = {
|
|
|
55
55
|
};
|
|
56
56
|
constructor(e, t, n = {}) {
|
|
57
57
|
this.container = e, this.source = t, this.labels = {
|
|
58
|
-
...
|
|
58
|
+
...Vt,
|
|
59
59
|
...n
|
|
60
60
|
};
|
|
61
|
-
for (let t of
|
|
62
|
-
e.setAttribute("role", "application"), this.help =
|
|
61
|
+
for (let t of Ht) this.before.set(t, e.getAttribute(t));
|
|
62
|
+
e.setAttribute("role", "application"), this.help = Kt("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 = Kt("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
|
+
...Vt,
|
|
67
67
|
...e
|
|
68
68
|
}, this.applyLabels();
|
|
69
69
|
}
|
|
70
70
|
refresh(e = !1) {
|
|
71
|
-
let t =
|
|
71
|
+
let t = Wt - (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 Ht = {
|
|
|
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
|
+
}, Ut);
|
|
84
84
|
}
|
|
85
85
|
readBar(e) {
|
|
86
86
|
let t = this.source.bars();
|
|
@@ -93,13 +93,13 @@ var Ht = {
|
|
|
93
93
|
let i = t[this.cursor];
|
|
94
94
|
this.source.showBar(i.time);
|
|
95
95
|
let a = this.source.formatPrice;
|
|
96
|
-
this.say(
|
|
96
|
+
this.say(j(this.labels.bar, {
|
|
97
97
|
time: this.source.formatTime(i.time),
|
|
98
98
|
open: a(i.open),
|
|
99
99
|
high: a(i.high),
|
|
100
100
|
low: a(i.low),
|
|
101
101
|
close: a(i.close),
|
|
102
|
-
volume:
|
|
102
|
+
volume: qt(i.volume ?? 0)
|
|
103
103
|
}));
|
|
104
104
|
}
|
|
105
105
|
destroy() {
|
|
@@ -118,7 +118,7 @@ var Ht = {
|
|
|
118
118
|
this.labels.typeName ? this.labels.typeName(t) : t,
|
|
119
119
|
this.source.timeframe()
|
|
120
120
|
].filter(Boolean).join(", ");
|
|
121
|
-
return
|
|
121
|
+
return j(this.labels.summary, {
|
|
122
122
|
what: n,
|
|
123
123
|
close: this.source.formatPrice(e[e.length - 1].close)
|
|
124
124
|
});
|
|
@@ -128,7 +128,7 @@ var Ht = {
|
|
|
128
128
|
if (e.length === 0) return this.labels.empty;
|
|
129
129
|
let t = this.source.visibleRange(), n = Math.max(0, Math.min(e.length - 1, Math.ceil(t.from))), r = Math.max(n, Math.min(e.length - 1, Math.floor(t.to))), i = -Infinity, a = Infinity;
|
|
130
130
|
for (let t = n; t <= r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
|
|
131
|
-
return
|
|
131
|
+
return j(this.labels.view, {
|
|
132
132
|
count: r - n + 1,
|
|
133
133
|
from: this.source.formatTime(e[n].time),
|
|
134
134
|
to: this.source.formatTime(e[r].time),
|
|
@@ -140,7 +140,7 @@ var Ht = {
|
|
|
140
140
|
this.live.textContent = e;
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function Kt(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 qt(e, t) {
|
|
|
154
154
|
border: "0"
|
|
155
155
|
}), n;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function qt(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 Jt(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,36 +169,36 @@ function Yt(e, t, n, r) {
|
|
|
169
169
|
}
|
|
170
170
|
//#endregion
|
|
171
171
|
//#region src/charts/ChartTypeStrategy.ts
|
|
172
|
-
function
|
|
172
|
+
function Yt(e) {
|
|
173
173
|
switch (e) {
|
|
174
174
|
case "candlestick":
|
|
175
175
|
case "heikinAshi":
|
|
176
176
|
case "lineBreak":
|
|
177
|
-
case "rangeBars": return new
|
|
177
|
+
case "rangeBars": return new he();
|
|
178
178
|
case "line": return new Re();
|
|
179
|
-
case "area": return new
|
|
180
|
-
case "bar": return new
|
|
179
|
+
case "area": return new ue();
|
|
180
|
+
case "bar": return new pe();
|
|
181
181
|
case "hollowCandle": return new Ne();
|
|
182
|
-
case "baseline": return new
|
|
183
|
-
case "renko": return new
|
|
182
|
+
case "baseline": return new me();
|
|
183
|
+
case "renko": return new Ze();
|
|
184
184
|
case "kagi": return new Ie();
|
|
185
|
-
case "pointAndFigure": return new
|
|
186
|
-
case "volumeCandles": return new
|
|
187
|
-
case "equivolume": return new
|
|
188
|
-
case "hlcArea": return new
|
|
189
|
-
case "stepLine": return new
|
|
185
|
+
case "pointAndFigure": return new T();
|
|
186
|
+
case "volumeCandles": return new pt();
|
|
187
|
+
case "equivolume": return new Oe();
|
|
188
|
+
case "hlcArea": return new je();
|
|
189
|
+
case "stepLine": return new it();
|
|
190
190
|
case "lineWithMarkers": return new ze();
|
|
191
|
-
case "hiLo": return new
|
|
192
|
-
default: return new
|
|
191
|
+
case "hiLo": return new Me();
|
|
192
|
+
default: return new he();
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function Xt(e, t, n = {}) {
|
|
196
196
|
if (t.length === 0) return t;
|
|
197
197
|
switch (e) {
|
|
198
198
|
case "heikinAshi": return kt(t);
|
|
199
199
|
case "renko": {
|
|
200
200
|
let e = n.renko?.boxSize;
|
|
201
|
-
return typeof e == "number" ?
|
|
201
|
+
return typeof e == "number" ? k(t, { brickSize: e }) : k(t, {
|
|
202
202
|
brickSize: 0,
|
|
203
203
|
useATR: !0,
|
|
204
204
|
atrPeriod: n.renko?.atrPeriod ?? 14
|
|
@@ -206,15 +206,15 @@ function Zt(e, t, n = {}) {
|
|
|
206
206
|
}
|
|
207
207
|
case "lineBreak": return jt(t, n.lineBreak?.lines ?? 3);
|
|
208
208
|
case "kagi": return At(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
|
|
209
|
-
case "pointAndFigure": return Mt(t,
|
|
209
|
+
case "pointAndFigure": return Mt(t, Qt(t, n), n.pointAndFigure?.reversal ?? 3);
|
|
210
210
|
case "rangeBars": {
|
|
211
211
|
let e = n.rangeBars?.range;
|
|
212
|
-
return Nt(t, { rangeSize: typeof e == "number" ? e :
|
|
212
|
+
return Nt(t, { rangeSize: typeof e == "number" ? e : N(t) * .005 });
|
|
213
213
|
}
|
|
214
214
|
default: return t;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function Zt(e) {
|
|
218
218
|
switch (e) {
|
|
219
219
|
case "heikinAshi":
|
|
220
220
|
case "renko":
|
|
@@ -225,30 +225,30 @@ function Qt(e) {
|
|
|
225
225
|
default: return !1;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
return e !== "heikinAshi" &&
|
|
228
|
+
function M(e) {
|
|
229
|
+
return e !== "heikinAshi" && Zt(e);
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function Qt(e, t = {}) {
|
|
232
232
|
let n = t.pointAndFigure?.boxSize;
|
|
233
|
-
return typeof n == "number" ? n :
|
|
233
|
+
return typeof n == "number" ? n : N(e) * .01;
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function N(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() : Yt(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) : Xt(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;
|
|
@@ -278,15 +278,15 @@ var rn = class {
|
|
|
278
278
|
};
|
|
279
279
|
//#endregion
|
|
280
280
|
//#region src/DataManager.ts
|
|
281
|
-
function
|
|
281
|
+
function P(e) {
|
|
282
282
|
if (!e || typeof e.time != "number" || !Number.isFinite(e.time)) return !1;
|
|
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 F(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
|
-
function
|
|
289
|
+
function I(e) {
|
|
290
290
|
return {
|
|
291
291
|
...e,
|
|
292
292
|
high: Math.max(e.open, e.high, e.low, e.close),
|
|
@@ -294,7 +294,7 @@ function P(e) {
|
|
|
294
294
|
volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
|
-
var
|
|
297
|
+
var L = class {
|
|
298
298
|
data = [];
|
|
299
299
|
getData() {
|
|
300
300
|
return this.data;
|
|
@@ -303,7 +303,7 @@ var F = class {
|
|
|
303
303
|
let t = [];
|
|
304
304
|
for (let n = 0; n < e.length; n++) {
|
|
305
305
|
let r = e[n];
|
|
306
|
-
|
|
306
|
+
P(r) && t.push(F(r) ? r : I(r));
|
|
307
307
|
}
|
|
308
308
|
this.data = t;
|
|
309
309
|
}
|
|
@@ -311,7 +311,7 @@ var F = class {
|
|
|
311
311
|
let t = this.data.length > 0 ? this.data[0].time : Infinity, n = [];
|
|
312
312
|
for (let r = 0; r < e.length; r++) {
|
|
313
313
|
let i = e[r];
|
|
314
|
-
!
|
|
314
|
+
!P(i) || i.time >= t || n.push(F(i) ? i : I(i));
|
|
315
315
|
}
|
|
316
316
|
if (n.length === 0) return 0;
|
|
317
317
|
n.sort((e, t) => e.time - t.time);
|
|
@@ -320,11 +320,11 @@ var F = class {
|
|
|
320
320
|
return n.length = r, this.data = n.concat(this.data), r;
|
|
321
321
|
}
|
|
322
322
|
appendBar(e) {
|
|
323
|
-
|
|
323
|
+
P(e) && this.data.push(I(e));
|
|
324
324
|
}
|
|
325
325
|
updateLastBar(e) {
|
|
326
|
-
if (!
|
|
327
|
-
let t =
|
|
326
|
+
if (!P(e)) return;
|
|
327
|
+
let t = I(e);
|
|
328
328
|
if (this.data.length === 0) {
|
|
329
329
|
this.data.push(t);
|
|
330
330
|
return;
|
|
@@ -340,7 +340,7 @@ var F = class {
|
|
|
340
340
|
clear() {
|
|
341
341
|
this.data = [];
|
|
342
342
|
}
|
|
343
|
-
},
|
|
343
|
+
}, R = 5e3, nn = 6e4, rn = 500, an = class {
|
|
344
344
|
loader = null;
|
|
345
345
|
pageSize = 500;
|
|
346
346
|
loading = !1;
|
|
@@ -381,7 +381,7 @@ var F = class {
|
|
|
381
381
|
try {
|
|
382
382
|
r = await e(t, this.pageSize);
|
|
383
383
|
} catch (e) {
|
|
384
|
-
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(
|
|
384
|
+
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(nn, R * 2 ** (this.failures - 1)), this.emit({
|
|
385
385
|
state: "error",
|
|
386
386
|
count: 0,
|
|
387
387
|
error: e instanceof Error ? e.message : String(e)
|
|
@@ -411,7 +411,7 @@ var F = class {
|
|
|
411
411
|
now() {
|
|
412
412
|
return this.host.now ? this.host.now() : Date.now();
|
|
413
413
|
}
|
|
414
|
-
},
|
|
414
|
+
}, z = class t {
|
|
415
415
|
base;
|
|
416
416
|
shape = null;
|
|
417
417
|
chartType = "candlestick";
|
|
@@ -428,7 +428,7 @@ var F = class {
|
|
|
428
428
|
return i;
|
|
429
429
|
}
|
|
430
430
|
getTheme() {
|
|
431
|
-
return this.effective ??=
|
|
431
|
+
return this.effective ??= ne(this.base, this.chartType, this.merged()), this.effective;
|
|
432
432
|
}
|
|
433
433
|
getBaseTheme() {
|
|
434
434
|
return this.base;
|
|
@@ -497,7 +497,7 @@ var F = class {
|
|
|
497
497
|
};
|
|
498
498
|
//#endregion
|
|
499
499
|
//#region src/style/styleOptions.ts
|
|
500
|
-
function
|
|
500
|
+
function B(e, t) {
|
|
501
501
|
return t ? {
|
|
502
502
|
...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
|
|
503
503
|
...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
|
|
@@ -505,22 +505,22 @@ function R(e, t) {
|
|
|
505
505
|
...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
|
|
506
506
|
} : {};
|
|
507
507
|
}
|
|
508
|
-
function
|
|
508
|
+
function on(e) {
|
|
509
509
|
let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
|
|
510
510
|
return {
|
|
511
511
|
...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
|
|
512
512
|
...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
|
|
513
513
|
...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
|
|
514
514
|
...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
|
|
515
|
-
...
|
|
516
|
-
...
|
|
515
|
+
...B("horizontal", n?.hLine),
|
|
516
|
+
...B("vertical", n?.vLine),
|
|
517
517
|
...r === void 0 ? {} : { "crosshair.labelBackground": r },
|
|
518
518
|
...e.overrides
|
|
519
519
|
};
|
|
520
520
|
}
|
|
521
521
|
//#endregion
|
|
522
522
|
//#region src/layout/LayoutManager.ts
|
|
523
|
-
var
|
|
523
|
+
var V = 200, sn = 80, H = (e) => e.position === "top" || e.position === "bottom", cn = class {
|
|
524
524
|
panels = [];
|
|
525
525
|
containerWidth = 0;
|
|
526
526
|
containerHeight = 0;
|
|
@@ -536,8 +536,8 @@ var z = 200, B = 80, V = (e) => e.position === "top" || e.position === "bottom",
|
|
|
536
536
|
this.panels.push({
|
|
537
537
|
id: e,
|
|
538
538
|
position: n,
|
|
539
|
-
size: r ?? (a ?
|
|
540
|
-
minSize: a ?
|
|
539
|
+
size: r ?? (a ? V : t),
|
|
540
|
+
minSize: a ? sn : i,
|
|
541
541
|
content: {
|
|
542
542
|
type: "indicator",
|
|
543
543
|
indicatorInstanceId: e
|
|
@@ -556,14 +556,14 @@ var z = 200, B = 80, V = (e) => e.position === "top" || e.position === "bottom",
|
|
|
556
556
|
}
|
|
557
557
|
setPanelCollapsed(e, t) {
|
|
558
558
|
let n = this.panels.find((t) => t.id === e);
|
|
559
|
-
return !n || !
|
|
559
|
+
return !n || !H(n) || this.maximized === null && !!n.collapsed === t ? !1 : (this.maximized = null, n.collapsed = t || void 0, !0);
|
|
560
560
|
}
|
|
561
561
|
isPanelCollapsed(e) {
|
|
562
562
|
return !!this.panels.find((t) => t.id === e)?.collapsed;
|
|
563
563
|
}
|
|
564
564
|
isPanelShownCollapsed(e) {
|
|
565
565
|
let t = this.panels.find((t) => t.id === e);
|
|
566
|
-
return !t || !
|
|
566
|
+
return !t || !H(t) ? !1 : this.maximized === null ? !!t.collapsed : this.maximized !== e;
|
|
567
567
|
}
|
|
568
568
|
setPanelScale(e, t) {
|
|
569
569
|
let n = this.panels.find((t) => t.id === e);
|
|
@@ -579,7 +579,7 @@ var z = 200, B = 80, V = (e) => e.position === "top" || e.position === "bottom",
|
|
|
579
579
|
}
|
|
580
580
|
setMaximizedPanel(e) {
|
|
581
581
|
let t = e === null ? null : this.panels.find((t) => t.id === e);
|
|
582
|
-
return e !== null && (!t || !
|
|
582
|
+
return e !== null && (!t || !H(t)) || this.maximized === e ? !1 : (this.maximized = e, t && (t.collapsed = void 0), !0);
|
|
583
583
|
}
|
|
584
584
|
getMaximizedPanel() {
|
|
585
585
|
return this.maximized;
|
|
@@ -600,19 +600,19 @@ var z = 200, B = 80, V = (e) => e.position === "top" || e.position === "bottom",
|
|
|
600
600
|
this.panels = [...this.panels].sort((e, n) => t(e) - t(n));
|
|
601
601
|
}
|
|
602
602
|
shownSize(e, t) {
|
|
603
|
-
return
|
|
603
|
+
return H(e) ? this.maximized ? e.id === this.maximized ? t : 20 : e.collapsed ? 20 : e.size : e.size;
|
|
604
604
|
}
|
|
605
605
|
setPanelPosition(e, n) {
|
|
606
606
|
let r = this.panels.find((t) => t.id === e);
|
|
607
607
|
if (r) {
|
|
608
608
|
let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
|
|
609
|
-
r.position = n, a !== o && (r.size = o ?
|
|
609
|
+
r.position = n, a !== o && (r.size = o ? V : t, r.minSize = o ? sn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
612
|
setPanelSize(e, t) {
|
|
613
613
|
let n = this.panels.find((t) => t.id === e);
|
|
614
614
|
if (n) {
|
|
615
|
-
let e =
|
|
615
|
+
let e = H(n) ? this.containerHeight - o - 48 : this.containerWidth / 2, r = e > n.minSize ? Math.min(t, e) : t;
|
|
616
616
|
n.size = Math.max(n.minSize, r), n.collapsed = void 0, this.maximized = null;
|
|
617
617
|
}
|
|
618
618
|
}
|
|
@@ -722,8 +722,8 @@ var z = 200, B = 80, V = (e) => e.position === "top" || e.position === "bottom",
|
|
|
722
722
|
getMainChartRect() {
|
|
723
723
|
return this.resolve().mainChartRect;
|
|
724
724
|
}
|
|
725
|
-
},
|
|
726
|
-
function
|
|
725
|
+
}, ln = 14, un = 14, dn = 22, fn = 4;
|
|
726
|
+
function pn(e) {
|
|
727
727
|
let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: l } = e, d = e.tagPrecision ?? s(t, n), f = d, p = r === null ? [t, n] : [
|
|
728
728
|
t,
|
|
729
729
|
n,
|
|
@@ -732,14 +732,14 @@ function mn(e) {
|
|
|
732
732
|
for (let t of p) {
|
|
733
733
|
if (!Number.isFinite(t)) continue;
|
|
734
734
|
let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : u(t, d, i), r = e.format ? n : u(t, f, i);
|
|
735
|
-
m = Math.max(m, l(n, `500 ${c}px ${o}`) +
|
|
735
|
+
m = Math.max(m, l(n, `500 ${c}px ${o}`) + ln, l(r, `bold 11px ${o}`) + un, l(r, `600 ${c}px ${o}`) + dn);
|
|
736
736
|
}
|
|
737
|
-
return m <= a ? a : Math.ceil(m /
|
|
737
|
+
return m <= a ? a : Math.ceil(m / fn) * fn;
|
|
738
738
|
}
|
|
739
|
-
function
|
|
739
|
+
function mn(e, t) {
|
|
740
740
|
return t > e || t <= e - 12 ? t : e;
|
|
741
741
|
}
|
|
742
|
-
var
|
|
742
|
+
var hn = class {
|
|
743
743
|
netY = 0;
|
|
744
744
|
travelX = 0;
|
|
745
745
|
engaged = !1;
|
|
@@ -755,11 +755,11 @@ var gn = class {
|
|
|
755
755
|
}
|
|
756
756
|
return this.engaged;
|
|
757
757
|
}
|
|
758
|
-
},
|
|
759
|
-
function
|
|
758
|
+
}, gn = 1;
|
|
759
|
+
function _n(e, t) {
|
|
760
760
|
return e.filter((e) => (e.descriptor.layer ?? "overlay") === t);
|
|
761
761
|
}
|
|
762
|
-
function
|
|
762
|
+
function U(e) {
|
|
763
763
|
switch (e.kind) {
|
|
764
764
|
case "indicator": return `indicator:${e.plugin.descriptor.id}`;
|
|
765
765
|
case "drawing": return `drawing:${e.plugin.descriptor.type}`;
|
|
@@ -769,25 +769,25 @@ function H(e) {
|
|
|
769
769
|
}
|
|
770
770
|
//#endregion
|
|
771
771
|
//#region src/plugins/registry.ts
|
|
772
|
-
var
|
|
773
|
-
function
|
|
774
|
-
|
|
772
|
+
var W = /* @__PURE__ */ new Map();
|
|
773
|
+
function vn(e) {
|
|
774
|
+
W.set(U(e), e);
|
|
775
775
|
}
|
|
776
|
-
function
|
|
777
|
-
return
|
|
776
|
+
function yn(e) {
|
|
777
|
+
return W.delete(e);
|
|
778
778
|
}
|
|
779
|
-
function
|
|
780
|
-
return [...
|
|
779
|
+
function bn() {
|
|
780
|
+
return [...W.values()];
|
|
781
781
|
}
|
|
782
782
|
function xn() {
|
|
783
|
-
|
|
783
|
+
W.clear();
|
|
784
784
|
}
|
|
785
785
|
//#endregion
|
|
786
786
|
//#region src/plugins/PluginManager.ts
|
|
787
787
|
var Sn = class {
|
|
788
788
|
plugins = /* @__PURE__ */ new Map();
|
|
789
789
|
constructor(e, t = {}) {
|
|
790
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
790
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of bn()) this.add(e);
|
|
791
791
|
for (let e of t.plugins ?? []) this.add(e);
|
|
792
792
|
}
|
|
793
793
|
register(e) {
|
|
@@ -815,7 +815,7 @@ var Sn = class {
|
|
|
815
815
|
return e;
|
|
816
816
|
}
|
|
817
817
|
add(e) {
|
|
818
|
-
this.plugins.set(
|
|
818
|
+
this.plugins.set(U(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
819
819
|
}
|
|
820
820
|
}, Cn = {
|
|
821
821
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
@@ -888,7 +888,7 @@ function kn(e) {
|
|
|
888
888
|
if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
|
|
889
889
|
}
|
|
890
890
|
var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
891
|
-
static version = "1.
|
|
891
|
+
static version = "1.18.1";
|
|
892
892
|
engine;
|
|
893
893
|
viewport;
|
|
894
894
|
dataManager;
|
|
@@ -926,14 +926,14 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
926
926
|
indicatorHistoryDepth = 0;
|
|
927
927
|
removedDrawingAlerts = /* @__PURE__ */ new Map();
|
|
928
928
|
zoomAreaMode = !1;
|
|
929
|
-
priceAxisAddButton = new
|
|
929
|
+
priceAxisAddButton = new Je();
|
|
930
930
|
displayTz = null;
|
|
931
931
|
timezoneSetting = null;
|
|
932
932
|
symbolInfo = null;
|
|
933
933
|
symbolInfoSeq = 0;
|
|
934
934
|
sessionBreaks;
|
|
935
935
|
sessionShading;
|
|
936
|
-
hostSessionHours = { ...
|
|
936
|
+
hostSessionHours = { ...we };
|
|
937
937
|
compareRenderer;
|
|
938
938
|
countdownInterval = null;
|
|
939
939
|
volumeRenderer;
|
|
@@ -946,7 +946,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
946
946
|
signalMarkerManager;
|
|
947
947
|
tradeZoneManager;
|
|
948
948
|
measureOverlay;
|
|
949
|
-
selectionBoxOverlay = new
|
|
949
|
+
selectionBoxOverlay = new $e();
|
|
950
950
|
replayManager;
|
|
951
951
|
replayBarUnsub = null;
|
|
952
952
|
replaySeeking = !1;
|
|
@@ -956,7 +956,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
956
956
|
replayRevealMarks = !0;
|
|
957
957
|
replayOffset = 0;
|
|
958
958
|
undoRedoManager;
|
|
959
|
-
autoSaveScheduler = new
|
|
959
|
+
autoSaveScheduler = new tn((e) => this.saveState(e));
|
|
960
960
|
animator;
|
|
961
961
|
crosshairTooltip;
|
|
962
962
|
pinnedTooltip;
|
|
@@ -968,15 +968,15 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
968
968
|
disposed = !1;
|
|
969
969
|
chartTypeOptions = {};
|
|
970
970
|
mainSeriesVisible = !0;
|
|
971
|
-
priceLines = new
|
|
972
|
-
symbolSeries = new
|
|
971
|
+
priceLines = new Ye();
|
|
972
|
+
symbolSeries = new ot();
|
|
973
973
|
extendedHours = !0;
|
|
974
974
|
replayRestarting = !1;
|
|
975
975
|
fullSeries = null;
|
|
976
976
|
requestedSymbols = /* @__PURE__ */ new Set();
|
|
977
977
|
gridRenderer;
|
|
978
978
|
priceAxis;
|
|
979
|
-
leftPriceAxis = new
|
|
979
|
+
leftPriceAxis = new qe();
|
|
980
980
|
leftScaleRequested = !1;
|
|
981
981
|
leftAxisWidth = a;
|
|
982
982
|
leftViewport = null;
|
|
@@ -997,6 +997,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
997
997
|
onWindowKeyDown = null;
|
|
998
998
|
currentSymbol = "";
|
|
999
999
|
streamTimeframe = null;
|
|
1000
|
+
tickStream = !1;
|
|
1000
1001
|
announcedSymbol = null;
|
|
1001
1002
|
announcedTimeframe = null;
|
|
1002
1003
|
streamAdapter = null;
|
|
@@ -1044,15 +1045,15 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1044
1045
|
logScale: n.logScale ?? !0,
|
|
1045
1046
|
timeframes: n.timeframes ?? [],
|
|
1046
1047
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
1047
|
-
}, 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
|
|
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 L(), this.history = new an({
|
|
1048
1049
|
oldestTime: () => this.dataManager.getData()[0]?.time ?? null,
|
|
1049
1050
|
prepend: (e) => this.prependBars(e),
|
|
1050
1051
|
emit: (e) => this.eventBus.emit("historyLoad", e)
|
|
1051
|
-
}), this.themeManager = new
|
|
1052
|
+
}), this.themeManager = new z(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(on(t), "host", !1), this.layoutManager = new cn(), this.indicatorEngine = new Pe(), this.pluginManager = new Sn(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new ke(), Dt(this.indicatorEngine), this.indicatorEngine.register(new ve(this.symbolSeries)), this.indicatorEngine.register(new rt(this.symbolSeries)), this.indicatorEngine.register(new ye(this.symbolSeries)), this.indicatorEngine.register(new be(this.symbolSeries)), this.drawingManager = new Ee(), Et(this.drawingManager), this.drawingRenderer = new De(this.drawingManager), this.drawingManager.setRequestRender(() => {
|
|
1052
1053
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
1053
1054
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
1054
1055
|
this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
|
|
1055
|
-
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new
|
|
1056
|
+
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new dt();
|
|
1056
1057
|
let i = "";
|
|
1057
1058
|
this.undoRedoManager.setOnChange(() => {
|
|
1058
1059
|
let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
|
|
@@ -1065,21 +1066,21 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1065
1066
|
primary: e[0] ?? null
|
|
1066
1067
|
})), this.drawingManager.setForeignHistory((e, t) => {
|
|
1067
1068
|
e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
|
|
1068
|
-
}), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new
|
|
1069
|
+
}), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new lt({
|
|
1069
1070
|
enabled: this.features.trading,
|
|
1070
1071
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
1071
|
-
}), this.tradingRenderer = new
|
|
1072
|
+
}), this.tradingRenderer = new ut(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
1072
1073
|
this.eventBus.emit(e, t);
|
|
1073
|
-
}), this.engine = new
|
|
1074
|
+
}), this.engine = new Xe(e);
|
|
1074
1075
|
let a = this.engine.dprManager.getContainerSize();
|
|
1075
|
-
if (this.viewport = new
|
|
1076
|
+
if (this.viewport = new ft(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
|
|
1076
1077
|
freePan: t.freePan ?? !0,
|
|
1077
1078
|
minVisibleBars: t.panLimits?.minVisibleBars ?? 3
|
|
1078
1079
|
}), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
|
|
1079
1080
|
if (e.width <= 0 || e.height <= 0) return;
|
|
1080
1081
|
let t = this.viewport.isAtEnd();
|
|
1081
1082
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
|
|
1082
|
-
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new
|
|
1083
|
+
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Ae(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new qe(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.timeAxis = new st(), this.crosshairHandler = new xe(), this.crosshairHandler.setLocale(this.numberLocale), this.applyTimeSpacing(), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
|
|
1083
1084
|
if (e !== null && t) {
|
|
1084
1085
|
let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
|
|
1085
1086
|
this.chartLegend.setHoverBar(r ?? null);
|
|
@@ -1088,19 +1089,19 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1088
1089
|
prevClose: e > 0 ? n[e - 1]?.close : void 0,
|
|
1089
1090
|
priceRange: i.priceRange,
|
|
1090
1091
|
plot: i.chartRect,
|
|
1091
|
-
barStepMs:
|
|
1092
|
+
barStepMs: vt(n)
|
|
1092
1093
|
}) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
|
|
1093
1094
|
point: t,
|
|
1094
1095
|
bar: r,
|
|
1095
1096
|
barIndex: e
|
|
1096
1097
|
});
|
|
1097
1098
|
} else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
|
|
1098
|
-
}), this.chartLegend = new
|
|
1099
|
+
}), this.chartLegend = new ge(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new gt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new ht(), this.volumeProfile = new mt(), this.marketProfile = new Be(), this.depthHeatmap = new Te(), this.periodLevels = new We(), this.pivotMarkers = new Ke(), this.barCountdown = new fe(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new et(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new tt(), this.compareRenderer = new _e(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
1099
1100
|
visible: t.sessionBreaks.visible ?? !0,
|
|
1100
1101
|
color: t.sessionBreaks.color,
|
|
1101
1102
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
1102
1103
|
lineWidth: t.sessionBreaks.lineWidth
|
|
1103
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new
|
|
1104
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new le(), this.crosshairTooltip = new Se(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Ge(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = y(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Rn(t.shapes)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Le({
|
|
1104
1105
|
scrollBars: (e) => {
|
|
1105
1106
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
1106
1107
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -1117,14 +1118,14 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1117
1118
|
},
|
|
1118
1119
|
fitContent: () => this.fitContent()
|
|
1119
1120
|
}), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
|
|
1120
|
-
this.a11y = new
|
|
1121
|
+
this.a11y = new Gt(e, {
|
|
1121
1122
|
symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
|
|
1122
1123
|
timeframe: () => this.streamTimeframe ?? "",
|
|
1123
1124
|
chartType: () => this.options.chartType ?? "candlestick",
|
|
1124
1125
|
bars: () => this.getDisplayData(),
|
|
1125
1126
|
visibleRange: () => this.viewport.getState().visibleRange,
|
|
1126
1127
|
formatPrice: (e) => this.formatPrice(e),
|
|
1127
|
-
formatTime: (e) =>
|
|
1128
|
+
formatTime: (e) => oe(this.numberLocale || "en-US", {
|
|
1128
1129
|
dateStyle: "medium",
|
|
1129
1130
|
timeStyle: "short"
|
|
1130
1131
|
}, this.displayTz)(e > Dn ? e : e * 1e3),
|
|
@@ -1147,7 +1148,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1147
1148
|
}
|
|
1148
1149
|
this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
|
|
1149
1150
|
}
|
|
1150
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new
|
|
1151
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Ce(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new ce(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
|
|
1151
1152
|
this.eventBus.emit("alertTriggered", K(e)), this.eventBus.emit("dataUpdate", {
|
|
1152
1153
|
alert: "triggered",
|
|
1153
1154
|
alertId: e.id,
|
|
@@ -1162,7 +1163,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1162
1163
|
this.eventBus.emit("alertExpired", K(e));
|
|
1163
1164
|
}), this.alertManager.on("updated", (e) => {
|
|
1164
1165
|
this.eventBus.emit("alertUpdate", K(e));
|
|
1165
|
-
}), this.signalMarkerManager = new
|
|
1166
|
+
}), this.signalMarkerManager = new nt(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
|
|
1166
1167
|
this.eventBus.emit("signalMarkerAdd", {
|
|
1167
1168
|
id: e.id,
|
|
1168
1169
|
source: e.source,
|
|
@@ -1170,14 +1171,14 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1170
1171
|
});
|
|
1171
1172
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
1172
1173
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
1173
|
-
}), this.tradeZoneManager = new
|
|
1174
|
+
}), this.tradeZoneManager = new ct(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
|
|
1174
1175
|
this.eventBus.emit("tradeZoneAdd", {
|
|
1175
1176
|
id: e.id,
|
|
1176
1177
|
direction: e.direction
|
|
1177
1178
|
});
|
|
1178
1179
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
1179
1180
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
1180
|
-
}), this.replayManager = new
|
|
1181
|
+
}), this.replayManager = new Qe(), this.replayManager.on("complete", () => {
|
|
1181
1182
|
let e = this.getReplayBarIndex(), t = this.replayCoarse?.[e];
|
|
1182
1183
|
t && this.eventBus.emit("replayComplete", {
|
|
1183
1184
|
barIndex: e,
|
|
@@ -1186,7 +1187,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1186
1187
|
}), this.replayManager.on("stateChange", (e) => {
|
|
1187
1188
|
this.replayRestarting || this.eventBus.emit("replayState", { state: e });
|
|
1188
1189
|
}), this.measureOverlay = new Ve(), this.interactionManager = new Fe(e), this.features.panning) {
|
|
1189
|
-
let e = new
|
|
1190
|
+
let e = new hn();
|
|
1190
1191
|
this.interactionManager.setPanHandler(new He((t, n) => {
|
|
1191
1192
|
t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.options.autoScale = !1, this.viewport.panPriceRange(n)), this.updateViewportAndRender();
|
|
1192
1193
|
}, () => e.reset()));
|
|
@@ -1199,10 +1200,10 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1199
1200
|
scales: !this.indicatorEngine.hasLeftScaleOverlays()
|
|
1200
1201
|
}
|
|
1201
1202
|
})), this.features.zooming) {
|
|
1202
|
-
this.interactionManager.setZoomHandler(new
|
|
1203
|
+
this.interactionManager.setZoomHandler(new _t((e, t) => {
|
|
1203
1204
|
this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
|
|
1204
1205
|
}));
|
|
1205
|
-
let e = new
|
|
1206
|
+
let e = new de((e) => {
|
|
1206
1207
|
this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
1207
1208
|
}, (e) => {
|
|
1208
1209
|
let t = this.viewport.getState().chartRect.width;
|
|
@@ -1222,7 +1223,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1222
1223
|
y: t.y
|
|
1223
1224
|
});
|
|
1224
1225
|
})), 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) => {
|
|
1225
|
-
let t =
|
|
1226
|
+
let t = Lt(e.y, this.viewport.getState());
|
|
1226
1227
|
Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
|
|
1227
1228
|
price: t,
|
|
1228
1229
|
x: e.x,
|
|
@@ -1232,7 +1233,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1232
1233
|
...this.viewport.getState(),
|
|
1233
1234
|
data: this.getDisplayData()
|
|
1234
1235
|
})), this.features.alerts) {
|
|
1235
|
-
let e = new
|
|
1236
|
+
let e = new se(this.alertManager, () => this.viewport.getState());
|
|
1236
1237
|
this.interactionManager.setAlertDragHandler(e);
|
|
1237
1238
|
}
|
|
1238
1239
|
let o = new Ue();
|
|
@@ -1259,7 +1260,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1259
1260
|
x: e.x,
|
|
1260
1261
|
y: e.y
|
|
1261
1262
|
}), t.length === 0) return;
|
|
1262
|
-
let r =
|
|
1263
|
+
let r = It(e.x, this.viewport.getState());
|
|
1263
1264
|
r < 0 || r >= t.length || this.eventBus.emit("barClick", {
|
|
1264
1265
|
bar: t[r],
|
|
1265
1266
|
barIndex: r,
|
|
@@ -1376,15 +1377,15 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1376
1377
|
}
|
|
1377
1378
|
checkHistory() {
|
|
1378
1379
|
this.historyCheckQueued || !this.history.hasLoader() || (this.historyCheckQueued = !0, queueMicrotask(() => {
|
|
1379
|
-
if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() ||
|
|
1380
|
+
if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() || M(this.options.chartType)) return;
|
|
1380
1381
|
let { from: e, to: t } = this.viewport.getState().visibleRange;
|
|
1381
1382
|
this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(Nn, t - e));
|
|
1382
1383
|
}));
|
|
1383
1384
|
}
|
|
1384
1385
|
useStreamHistory(e, t) {
|
|
1385
1386
|
if (this.hostHistoryLoader) return;
|
|
1386
|
-
let n =
|
|
1387
|
-
if (!r || i === null ||
|
|
1387
|
+
let n = Ft(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
|
|
1388
|
+
if (!r || i === null || ae(i) !== null) {
|
|
1388
1389
|
this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
|
|
1389
1390
|
return;
|
|
1390
1391
|
}
|
|
@@ -1444,11 +1445,15 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1444
1445
|
}
|
|
1445
1446
|
setChartType(e) {
|
|
1446
1447
|
let t = this.options.chartType ?? "candlestick";
|
|
1447
|
-
this.options.chartType = e, this.themeManager.setChartType(e), this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged(), e !== t && this.eventBus.emit("chartTypeChange", {
|
|
1448
|
+
this.options.chartType = e, this.themeManager.setChartType(e), this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.applyTimeSpacing(), this.updateViewportAndRender(!0), this.markStateChanged(), e !== t && this.eventBus.emit("chartTypeChange", {
|
|
1448
1449
|
type: e,
|
|
1449
1450
|
previous: t
|
|
1450
1451
|
});
|
|
1451
1452
|
}
|
|
1453
|
+
applyTimeSpacing() {
|
|
1454
|
+
let e = !this.tickStream && !M(this.options.chartType);
|
|
1455
|
+
this.timeAxis.setTimesPastData(e), this.crosshairHandler.setTimesPastData(e);
|
|
1456
|
+
}
|
|
1452
1457
|
setChartTypeOptions(e) {
|
|
1453
1458
|
this.chartTypeOptions = {
|
|
1454
1459
|
...this.chartTypeOptions,
|
|
@@ -1465,7 +1470,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1465
1470
|
return this.extendedHours;
|
|
1466
1471
|
}
|
|
1467
1472
|
sessionKeep(e) {
|
|
1468
|
-
return this.extendedHours ? null :
|
|
1473
|
+
return this.extendedHours ? null : Bt(this.symbolInfo, e);
|
|
1469
1474
|
}
|
|
1470
1475
|
shownBars(e) {
|
|
1471
1476
|
let t = this.sessionKeep(e);
|
|
@@ -1695,7 +1700,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1695
1700
|
}
|
|
1696
1701
|
setPaneStyle(e, t) {
|
|
1697
1702
|
let n = this.paneOf(e);
|
|
1698
|
-
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ?
|
|
1703
|
+
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? te(t) : null));
|
|
1699
1704
|
}
|
|
1700
1705
|
setPaneStyleNow(e, t) {
|
|
1701
1706
|
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());
|
|
@@ -1715,7 +1720,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1715
1720
|
}
|
|
1716
1721
|
static indicators() {
|
|
1717
1722
|
let e = new Pe();
|
|
1718
|
-
return
|
|
1723
|
+
return Dt(e), e.getAvailableIndicators();
|
|
1719
1724
|
}
|
|
1720
1725
|
setPanelPosition(e, t) {
|
|
1721
1726
|
this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
|
|
@@ -1845,15 +1850,21 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1845
1850
|
return this.features.legend ? e + this.chartLegend.getHeight() : e;
|
|
1846
1851
|
}
|
|
1847
1852
|
isTimeAligned() {
|
|
1848
|
-
return
|
|
1853
|
+
return M(this.options.chartType) ? !1 : this.getDisplayData().length === this.dataManager.getLength();
|
|
1849
1854
|
}
|
|
1850
1855
|
roundPrice(e) {
|
|
1851
1856
|
if (!Number.isFinite(e)) return e;
|
|
1852
1857
|
let t = this.symbolInfo?.minTick ?? this.priceUnit ?? void 0;
|
|
1853
|
-
if (t !== void 0 && t > 0) return Number((Math.round(e / t) * t).toFixed(
|
|
1858
|
+
if (t !== void 0 && t > 0) return Number((Math.round(e / t) * t).toFixed(ie(t)));
|
|
1854
1859
|
let { min: n, max: r } = this.viewport.getState().priceRange;
|
|
1855
1860
|
return Number(e.toFixed(this.marketPricePrecision ?? s(n, r)));
|
|
1856
1861
|
}
|
|
1862
|
+
getPriceStep() {
|
|
1863
|
+
let e = this.symbolInfo?.minTick ?? this.priceUnit ?? void 0;
|
|
1864
|
+
if (e !== void 0 && e > 0) return e;
|
|
1865
|
+
let { min: t, max: n } = this.viewport.getState().priceRange, r = this.marketPricePrecision ?? s(t, n);
|
|
1866
|
+
return Number((10 ** -r).toFixed(r));
|
|
1867
|
+
}
|
|
1857
1868
|
setPriceFormat(e) {
|
|
1858
1869
|
this.applyPriceFormat(e), this.updateViewportAndRender();
|
|
1859
1870
|
}
|
|
@@ -1917,7 +1928,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
1917
1928
|
}
|
|
1918
1929
|
autoFib() {
|
|
1919
1930
|
if (!this.features.drawings) return null;
|
|
1920
|
-
let e = this.getDisplayData(), t = this.viewport.getState(), n =
|
|
1931
|
+
let e = this.getDisplayData(), t = this.viewport.getState(), n = yt(e, t.visibleRange.from, t.visibleRange.to);
|
|
1921
1932
|
return n ? this.addDrawing({
|
|
1922
1933
|
type: "fibRetracement",
|
|
1923
1934
|
anchors: [n[0], n[1]]
|
|
@@ -2039,7 +2050,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
2039
2050
|
x: t.x,
|
|
2040
2051
|
y: t.y
|
|
2041
2052
|
};
|
|
2042
|
-
if ((e === "plot" || e === "priceAxis") && (r.price =
|
|
2053
|
+
if ((e === "plot" || e === "priceAxis") && (r.price = Lt(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = A(t.x, n)), e === "pane") {
|
|
2043
2054
|
let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
|
|
2044
2055
|
e && (r.pane = e.instanceId);
|
|
2045
2056
|
}
|
|
@@ -2065,7 +2076,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
2065
2076
|
...this.viewport.getState(),
|
|
2066
2077
|
data: this.getDisplayData()
|
|
2067
2078
|
};
|
|
2068
|
-
this.setVisibleRange(
|
|
2079
|
+
this.setVisibleRange(A(e.x0, t), A(e.x1, t));
|
|
2069
2080
|
}
|
|
2070
2081
|
lockAllDrawings() {
|
|
2071
2082
|
this.drawingManager.lockAllDrawings();
|
|
@@ -2110,7 +2121,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
2110
2121
|
for (let e of this.indicatorEngine.getActiveIndicators()) {
|
|
2111
2122
|
let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
|
|
2112
2123
|
if (!t) continue;
|
|
2113
|
-
let r =
|
|
2124
|
+
let r = Jt(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
|
|
2114
2125
|
key: e,
|
|
2115
2126
|
title: e
|
|
2116
2127
|
}));
|
|
@@ -2134,11 +2145,11 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
2134
2145
|
}
|
|
2135
2146
|
getExportText(e = "csv", t = {}) {
|
|
2136
2147
|
let { bars: n, columns: r } = this.getExportData(t);
|
|
2137
|
-
return e === "json" ?
|
|
2148
|
+
return e === "json" ? w.toJSON(n, r) : w.toCSV(n, r);
|
|
2138
2149
|
}
|
|
2139
2150
|
download(e, t, n) {
|
|
2140
2151
|
let r = this.getExportText(e, n);
|
|
2141
|
-
e === "json" ?
|
|
2152
|
+
e === "json" ? w.download(r, t ?? "chart-data.json", "application/json") : w.download(r, t ?? "chart-data.csv", "text/csv");
|
|
2142
2153
|
}
|
|
2143
2154
|
setAutoSave(e, t = 5e3) {
|
|
2144
2155
|
this.autoSaveScheduler.enable(e, t);
|
|
@@ -2299,7 +2310,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
2299
2310
|
}
|
|
2300
2311
|
async connect(e) {
|
|
2301
2312
|
if (!Ot(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
|
|
2302
|
-
this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new
|
|
2313
|
+
this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new at(), this.streamManager.on("snapshot", (t) => {
|
|
2303
2314
|
let n = `${this.currentSymbol}|${this.streamTimeframe}`;
|
|
2304
2315
|
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);
|
|
2305
2316
|
}), this.streamManager.on("barClose", (e) => {
|
|
@@ -2348,14 +2359,14 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
2348
2359
|
}), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
|
|
2349
2360
|
let t = this.streamManager;
|
|
2350
2361
|
if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
|
|
2351
|
-
let n =
|
|
2362
|
+
let n = x(e.timeframe);
|
|
2352
2363
|
this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
|
|
2353
2364
|
this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
|
|
2354
2365
|
}, 1e3);
|
|
2355
2366
|
}
|
|
2356
2367
|
setStreamTarget(e, t) {
|
|
2357
2368
|
let n = this.announcedSymbol, r = this.announcedTimeframe;
|
|
2358
|
-
this.currentSymbol = e, this.streamTimeframe = t, e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
|
|
2369
|
+
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = ae(t) !== null, this.applyTimeSpacing(), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
|
|
2359
2370
|
symbol: e,
|
|
2360
2371
|
previous: n
|
|
2361
2372
|
})), t !== r && (this.announcedTimeframe = t, this.eventBus.emit("timeframeChange", {
|
|
@@ -2367,7 +2378,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
2367
2378
|
if (!this.streamManager) return;
|
|
2368
2379
|
let n = this.streamAdapter;
|
|
2369
2380
|
if (n && !Ot(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
|
|
2370
|
-
this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(
|
|
2381
|
+
this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(x(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
|
|
2371
2382
|
}
|
|
2372
2383
|
isTimeframeAllowed(e) {
|
|
2373
2384
|
let t = this.features.timeframes;
|
|
@@ -2378,7 +2389,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
2378
2389
|
this.isTimeframeAllowed(e) && await this.switchStream(this.currentSymbol, e);
|
|
2379
2390
|
}
|
|
2380
2391
|
disconnectStream() {
|
|
2381
|
-
this.symbolInfoSeq++, this.priceLines.setBidAsk(null), this.streamManager &&= (this.streamManager.dispose(), null), this.historyFromStream &&= (this.history.setLoader(null), !1), this.streamAdapter = null;
|
|
2392
|
+
this.symbolInfoSeq++, this.priceLines.setBidAsk(null), this.streamManager &&= (this.streamManager.dispose(), null), this.historyFromStream &&= (this.history.setLoader(null), !1), this.streamAdapter = null, this.tickStream = !1, this.applyTimeSpacing();
|
|
2382
2393
|
}
|
|
2383
2394
|
connectExecution(e, t = {}) {
|
|
2384
2395
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
@@ -2479,7 +2490,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
2479
2490
|
setVisibleRangePreset(e) {
|
|
2480
2491
|
let t = this.getDisplayData();
|
|
2481
2492
|
if (t.length === 0) return;
|
|
2482
|
-
let n = t.length - 1, r = t[n].time > Dn ? 1 : 1e3, i =
|
|
2493
|
+
let n = t.length - 1, r = t[n].time > Dn ? 1 : 1e3, i = wt(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
|
|
2483
2494
|
if (a === null || a < t[0].time) {
|
|
2484
2495
|
this.fitContent();
|
|
2485
2496
|
return;
|
|
@@ -2670,7 +2681,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
2670
2681
|
sessions: e.sessions?.map((e) => ({ ...e }))
|
|
2671
2682
|
} : null, this.priceAxis.setPriceTick(this.symbolInfo?.minTick ?? null), this.marketConfig?.pricePrecision === void 0 && this.applyPricePrecision(this.symbolInfo?.pricePrecision ?? null);
|
|
2672
2683
|
let t = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
|
|
2673
|
-
let t =
|
|
2684
|
+
let t = b(e.start), n = b(e.end);
|
|
2674
2685
|
return t === null || n === null ? [] : [{
|
|
2675
2686
|
startMinute: t,
|
|
2676
2687
|
endMinute: n
|
|
@@ -2727,7 +2738,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
2727
2738
|
return this.sessionShading.isVisible();
|
|
2728
2739
|
}
|
|
2729
2740
|
setSessionShadingConfig(e) {
|
|
2730
|
-
this.hostSessionHours =
|
|
2741
|
+
this.hostSessionHours = Ct(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
|
|
2731
2742
|
}
|
|
2732
2743
|
setTooltipVisible(e) {
|
|
2733
2744
|
e || this.crosshairTooltip.hide();
|
|
@@ -2746,11 +2757,11 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
2746
2757
|
return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
|
|
2747
2758
|
}
|
|
2748
2759
|
async takeGpu(e, t, n) {
|
|
2749
|
-
let { gpu: r, reason: i } = await
|
|
2750
|
-
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ?
|
|
2760
|
+
let { gpu: r, reason: i } = await St(e);
|
|
2761
|
+
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? bt() > 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());
|
|
2751
2762
|
}
|
|
2752
2763
|
waitForGpu(e) {
|
|
2753
|
-
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ?
|
|
2764
|
+
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Pt(e) : null;
|
|
2754
2765
|
}
|
|
2755
2766
|
getRenderer() {
|
|
2756
2767
|
return this.engine.getGpu() ? "webgl" : "canvas";
|
|
@@ -2768,23 +2779,23 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
2768
2779
|
this.engine.getGpu() && this.engine.renderNow();
|
|
2769
2780
|
}
|
|
2770
2781
|
screenshot(e) {
|
|
2771
|
-
this.features.screenshot && (this.freshFrame(),
|
|
2782
|
+
this.features.screenshot && (this.freshFrame(), E.download(this.container, e, this.themeManager.getTheme().background));
|
|
2772
2783
|
}
|
|
2773
2784
|
async copyScreenshot() {
|
|
2774
2785
|
if (!this.features.screenshot) return !1;
|
|
2775
2786
|
try {
|
|
2776
2787
|
this.freshFrame();
|
|
2777
|
-
let e = await
|
|
2788
|
+
let e = await E.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
|
|
2778
2789
|
return !e || !navigator.clipboard?.write || !t ? !1 : (await navigator.clipboard.write([new t({ "image/png": e })]), !0);
|
|
2779
2790
|
} catch {
|
|
2780
2791
|
return !1;
|
|
2781
2792
|
}
|
|
2782
2793
|
}
|
|
2783
2794
|
screenshotDataURL() {
|
|
2784
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
2795
|
+
return this.features.screenshot ? (this.freshFrame(), E.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
|
|
2785
2796
|
}
|
|
2786
2797
|
async screenshotBlob() {
|
|
2787
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
2798
|
+
return this.features.screenshot ? (this.freshFrame(), E.toBlob(this.container, this.themeManager.getTheme().background)) : null;
|
|
2788
2799
|
}
|
|
2789
2800
|
addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
|
|
2790
2801
|
if (!this.features.alerts) return null;
|
|
@@ -2912,7 +2923,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
2912
2923
|
let t = this.replaySession ? this.replayOffset : 0;
|
|
2913
2924
|
if (!this.replaySession) {
|
|
2914
2925
|
if (this.dataManager.getLength() === 0) return;
|
|
2915
|
-
let e = new
|
|
2926
|
+
let e = new L();
|
|
2916
2927
|
e.setData(this.fullSeries ?? this.dataManager.getData()), this.replaySession = {
|
|
2917
2928
|
live: e,
|
|
2918
2929
|
price: null,
|
|
@@ -3046,7 +3057,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
3046
3057
|
return this.replayManager.getProgress();
|
|
3047
3058
|
}
|
|
3048
3059
|
captureSnapshot() {
|
|
3049
|
-
return
|
|
3060
|
+
return C.capture({
|
|
3050
3061
|
getDrawings: () => this.getDrawings(),
|
|
3051
3062
|
getTheme: () => this.themeManager.getBaseTheme(),
|
|
3052
3063
|
getAlerts: () => this.getAlerts(),
|
|
@@ -3126,7 +3137,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
3126
3137
|
let o = this.indicatorEngine.getIndicatorConfig(e);
|
|
3127
3138
|
(t.visible ?? !0) !== (o?.visible ?? !0) && this.setIndicatorVisible(e, t.visible ?? !0);
|
|
3128
3139
|
let s = t.levels ?? null;
|
|
3129
|
-
JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s), this.setPaneStyleNow(e, t.paneStyle ?
|
|
3140
|
+
JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s), this.setPaneStyleNow(e, t.paneStyle ? te(t.paneStyle) : null);
|
|
3130
3141
|
}
|
|
3131
3142
|
restorePanes(e) {
|
|
3132
3143
|
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, {
|
|
@@ -3235,12 +3246,12 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
3235
3246
|
}
|
|
3236
3247
|
saveState(e) {
|
|
3237
3248
|
if (!this.features.saveLoad) return null;
|
|
3238
|
-
let t = this.captureSnapshot(), n =
|
|
3239
|
-
return e &&
|
|
3249
|
+
let t = this.captureSnapshot(), n = C.serialize(t);
|
|
3250
|
+
return e && C.saveToStorage(e, t), n;
|
|
3240
3251
|
}
|
|
3241
3252
|
loadState(e) {
|
|
3242
3253
|
if (!this.features.saveLoad) return;
|
|
3243
|
-
let t =
|
|
3254
|
+
let t = C.deserialize(e);
|
|
3244
3255
|
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");
|
|
3245
3256
|
let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
|
|
3246
3257
|
if (this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
|
|
@@ -3251,7 +3262,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
3251
3262
|
let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
|
|
3252
3263
|
return r ? r + e.slice(t) : e;
|
|
3253
3264
|
}, r = t(e.channel), i = {
|
|
3254
|
-
...
|
|
3265
|
+
...Tt(e),
|
|
3255
3266
|
...e.target ? { target: t(e.target) } : {}
|
|
3256
3267
|
};
|
|
3257
3268
|
if (!e.expired) {
|
|
@@ -3271,19 +3282,19 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
3271
3282
|
}
|
|
3272
3283
|
loadStateFromStorage(e) {
|
|
3273
3284
|
if (!this.features.saveLoad) return !1;
|
|
3274
|
-
let t =
|
|
3275
|
-
return t ? (this.loadState(
|
|
3285
|
+
let t = C.loadFromStorage(e);
|
|
3286
|
+
return t ? (this.loadState(C.serialize(t)), !0) : !1;
|
|
3276
3287
|
}
|
|
3277
3288
|
downloadState(e) {
|
|
3278
|
-
this.features.saveLoad &&
|
|
3289
|
+
this.features.saveLoad && C.downloadFile(this.captureSnapshot(), e);
|
|
3279
3290
|
}
|
|
3280
3291
|
async loadStateFromFile() {
|
|
3281
3292
|
if (!this.features.saveLoad) return;
|
|
3282
|
-
let e = await
|
|
3283
|
-
this.loadState(
|
|
3293
|
+
let e = await C.loadFromFile();
|
|
3294
|
+
this.loadState(C.serialize(e));
|
|
3284
3295
|
}
|
|
3285
3296
|
setLocale(e) {
|
|
3286
|
-
|
|
3297
|
+
re(e), this.engine.requestRender();
|
|
3287
3298
|
}
|
|
3288
3299
|
setNumberLocale(e) {
|
|
3289
3300
|
this.numberLocale = e, this.priceAxis.setLocale(e), this.leftPriceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.chartLegend.setLocale(e), this.crosshairTooltip.setLocale(e), this.sessionBreaks.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
|
|
@@ -3299,8 +3310,8 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
3299
3310
|
candleDown: e.colorScheme.down,
|
|
3300
3311
|
candleUpWick: e.colorScheme.up,
|
|
3301
3312
|
candleDownWick: e.colorScheme.down,
|
|
3302
|
-
volumeUp:
|
|
3303
|
-
volumeDown:
|
|
3313
|
+
volumeUp: S(e.colorScheme.up),
|
|
3314
|
+
volumeDown: S(e.colorScheme.down)
|
|
3304
3315
|
};
|
|
3305
3316
|
this.themeManager.setTheme(t);
|
|
3306
3317
|
}
|
|
@@ -3337,15 +3348,15 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
3337
3348
|
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 = "";
|
|
3338
3349
|
}
|
|
3339
3350
|
createChartRenderer(e) {
|
|
3340
|
-
let t =
|
|
3341
|
-
return t instanceof
|
|
3351
|
+
let t = $t(e, (e) => this.pluginManager.getChartType(e));
|
|
3352
|
+
return t instanceof Me && t.setPriceText((e) => this.formatPrice(e)), t;
|
|
3342
3353
|
}
|
|
3343
3354
|
getDisplayData() {
|
|
3344
3355
|
if (this.displayDataCache) return this.displayDataCache;
|
|
3345
3356
|
let e = this.dataManager.getData();
|
|
3346
3357
|
if (e.length === 0) return e;
|
|
3347
|
-
let t =
|
|
3348
|
-
return this.chartRenderer instanceof
|
|
3358
|
+
let t = en(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
|
|
3359
|
+
return this.chartRenderer instanceof T && !this.pluginManager.getChartType(this.options.chartType) && this.chartRenderer.setBoxSize(Qt(e, this.chartTypeOptions)), this.displayDataCache = t, t;
|
|
3349
3360
|
}
|
|
3350
3361
|
recalcIndicatorsFrom(e, t) {
|
|
3351
3362
|
this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
|
|
@@ -3401,7 +3412,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
3401
3412
|
fitLeftAxisWidth() {
|
|
3402
3413
|
let e = this.leftViewport;
|
|
3403
3414
|
if (!e) return !1;
|
|
3404
|
-
let t = this.themeManager.getTheme(), n =
|
|
3415
|
+
let t = this.themeManager.getTheme(), n = pn({
|
|
3405
3416
|
min: e.priceRange.min,
|
|
3406
3417
|
max: e.priceRange.max,
|
|
3407
3418
|
lastPrice: null,
|
|
@@ -3410,12 +3421,12 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
3410
3421
|
fontFamily: t.font.family,
|
|
3411
3422
|
fontSizeSmall: t.font.sizeSmall,
|
|
3412
3423
|
measure: (e, t) => this.measureText(e, t)
|
|
3413
|
-
}), r =
|
|
3424
|
+
}), r = mn(this.leftAxisWidth, n);
|
|
3414
3425
|
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);
|
|
3415
3426
|
}
|
|
3416
3427
|
fitPriceAxisWidth() {
|
|
3417
3428
|
if (!this.features.priceAxis) return !1;
|
|
3418
|
-
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n =
|
|
3429
|
+
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = pn({
|
|
3419
3430
|
min: e.min,
|
|
3420
3431
|
max: e.max,
|
|
3421
3432
|
lastPrice: this.currentPriceLine.getPrice(),
|
|
@@ -3426,7 +3437,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
3426
3437
|
fontFamily: t.font.family,
|
|
3427
3438
|
fontSizeSmall: t.font.sizeSmall,
|
|
3428
3439
|
measure: (e, t) => this.measureText(e, t)
|
|
3429
|
-
}), r =
|
|
3440
|
+
}), r = mn(this.priceAxisWidth, n);
|
|
3430
3441
|
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);
|
|
3431
3442
|
}
|
|
3432
3443
|
measureText(e, t) {
|
|
@@ -3552,7 +3563,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
|
|
|
3552
3563
|
});
|
|
3553
3564
|
}
|
|
3554
3565
|
drawOverlayPlugins(e, t) {
|
|
3555
|
-
let n =
|
|
3566
|
+
let n = _n(this.pluginManager.getOverlays(), t);
|
|
3556
3567
|
if (n.length === 0) return;
|
|
3557
3568
|
let r = {
|
|
3558
3569
|
viewport: this.viewport.getState(),
|
|
@@ -4197,6 +4208,6 @@ var br = class {
|
|
|
4197
4208
|
}
|
|
4198
4209
|
};
|
|
4199
4210
|
//#endregion
|
|
4200
|
-
export {
|
|
4211
|
+
export { Jt as C, L as S, U as _, hr as a, rn as b, Fn as c, xn as d, bn as f, _n as g, gn as h, gr as i, On as l, yn as m, _r as n, fr as o, vn as p, $ as r, rr as s, br as t, Sn as u, cn as v, R as x, z as y };
|
|
4201
4212
|
|
|
4202
|
-
//# sourceMappingURL=LayoutSession-
|
|
4213
|
+
//# sourceMappingURL=LayoutSession-B_rgyCMe.js.map
|