@tradecanvas/chart 1.23.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/README.md +1 -1
- package/dist/Chart.d.ts +19 -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-B7RJJGZJ.js → LayoutSession-BD1CfXIS.js} +381 -346
- 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/i18n-C040vB8g.cjs +2 -0
- package/dist/i18n-C040vB8g.cjs.map +1 -0
- package/dist/{i18n-fBzhlejv.js → i18n-FG3D2x5m.js} +3 -1
- package/dist/i18n-FG3D2x5m.js.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 +17 -0
- package/dist/widget/ChartWidget.d.ts.map +1 -1
- package/dist/widget/WidgetDrawingStyle.d.ts +4 -0
- package/dist/widget/WidgetDrawingStyle.d.ts.map +1 -1
- package/dist/widget/WidgetSelectionToolbar.d.ts +75 -0
- package/dist/widget/WidgetSelectionToolbar.d.ts.map +1 -0
- package/dist/widget/index.cjs +112 -3
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +1052 -794
- package/dist/widget/index.js.map +1 -1
- package/dist/widget/locales/ar.d.ts.map +1 -1
- package/dist/widget/locales/cs.d.ts.map +1 -1
- package/dist/widget/locales/da.d.ts.map +1 -1
- package/dist/widget/locales/de.d.ts.map +1 -1
- package/dist/widget/locales/el.d.ts.map +1 -1
- package/dist/widget/locales/en.d.ts +1 -0
- package/dist/widget/locales/en.d.ts.map +1 -1
- package/dist/widget/locales/es.d.ts.map +1 -1
- package/dist/widget/locales/et.d.ts.map +1 -1
- package/dist/widget/locales/fa.d.ts.map +1 -1
- package/dist/widget/locales/fr.d.ts.map +1 -1
- package/dist/widget/locales/he.d.ts.map +1 -1
- package/dist/widget/locales/hu.d.ts.map +1 -1
- package/dist/widget/locales/id.d.ts.map +1 -1
- package/dist/widget/locales/index.cjs +1 -1
- package/dist/widget/locales/index.cjs.map +1 -1
- package/dist/widget/locales/index.js +29 -1
- package/dist/widget/locales/index.js.map +1 -1
- package/dist/widget/locales/it.d.ts.map +1 -1
- package/dist/widget/locales/ja.d.ts.map +1 -1
- package/dist/widget/locales/ko.d.ts.map +1 -1
- package/dist/widget/locales/ms.d.ts.map +1 -1
- package/dist/widget/locales/nb.d.ts.map +1 -1
- package/dist/widget/locales/nl.d.ts.map +1 -1
- package/dist/widget/locales/pl.d.ts.map +1 -1
- package/dist/widget/locales/pt.d.ts.map +1 -1
- package/dist/widget/locales/ro.d.ts.map +1 -1
- package/dist/widget/locales/ru.d.ts.map +1 -1
- package/dist/widget/locales/sk.d.ts.map +1 -1
- package/dist/widget/locales/sv.d.ts.map +1 -1
- package/dist/widget/locales/th.d.ts.map +1 -1
- package/dist/widget/locales/tr.d.ts.map +1 -1
- package/dist/widget/locales/vi.d.ts.map +1 -1
- package/dist/widget/locales/zh.d.ts.map +1 -1
- package/dist/widget/locales/zhHant.d.ts.map +1 -1
- package/dist/widget/widgetFeatures.d.ts +1 -1
- package/dist/widget/widgetFeatures.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/LayoutSession-B7RJJGZJ.js.map +0 -1
- package/dist/LayoutSession-b3U60maf.cjs +0 -2
- package/dist/LayoutSession-b3U60maf.cjs.map +0 -1
- package/dist/i18n-CIHfGH-4.cjs +0 -2
- package/dist/i18n-CIHfGH-4.cjs.map +0 -1
- package/dist/i18n-fBzhlejv.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
|
|
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) =>
|
|
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
|
-
},
|
|
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 Ut = {
|
|
|
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 Ut = {
|
|
|
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();
|
|
@@ -93,13 +93,13 @@ var Ut = {
|
|
|
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(I(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: Kt(i.volume ?? 0)
|
|
103
103
|
}));
|
|
104
104
|
}
|
|
105
105
|
destroy() {
|
|
@@ -118,7 +118,7 @@ var Ut = {
|
|
|
118
118
|
this.labels.typeName ? this.labels.typeName(t) : t,
|
|
119
119
|
this.source.timeframe()
|
|
120
120
|
].filter(Boolean).join(", ");
|
|
121
|
-
return
|
|
121
|
+
return I(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 Ut = {
|
|
|
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 I(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 Ut = {
|
|
|
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 Jt(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,52 +169,52 @@ function Xt(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":
|
|
176
176
|
case "lineBreak":
|
|
177
|
-
case "rangeBars": return new
|
|
178
|
-
case "line": return new
|
|
179
|
-
case "area": return new
|
|
180
|
-
case "bar": return new
|
|
181
|
-
case "hollowCandle": return new
|
|
182
|
-
case "baseline": return new
|
|
183
|
-
case "renko": return new
|
|
184
|
-
case "kagi": return new
|
|
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
|
|
190
|
-
case "lineWithMarkers": return new
|
|
191
|
-
case "hiLo": return new
|
|
192
|
-
default: return new
|
|
177
|
+
case "rangeBars": return new ge();
|
|
178
|
+
case "line": return new Le();
|
|
179
|
+
case "area": return new de();
|
|
180
|
+
case "bar": return new me();
|
|
181
|
+
case "hollowCandle": return new Ne();
|
|
182
|
+
case "baseline": return new he();
|
|
183
|
+
case "renko": return new Ye();
|
|
184
|
+
case "kagi": return new Fe();
|
|
185
|
+
case "pointAndFigure": return new O();
|
|
186
|
+
case "volumeCandles": return new dt();
|
|
187
|
+
case "equivolume": return new ke();
|
|
188
|
+
case "hlcArea": return new Me();
|
|
189
|
+
case "stepLine": return new nt();
|
|
190
|
+
case "lineWithMarkers": return new Re();
|
|
191
|
+
case "hiLo": return new E();
|
|
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
|
-
case "heikinAshi": return
|
|
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
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
|
-
case "lineBreak": return
|
|
208
|
-
case "kagi": return
|
|
209
|
-
case "pointAndFigure": return
|
|
207
|
+
case "lineBreak": return kt(t, n.lineBreak?.lines ?? 3);
|
|
208
|
+
case "kagi": return Ot(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
|
|
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
|
|
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":
|
|
@@ -225,30 +225,30 @@ function $t(e) {
|
|
|
225
225
|
default: return !1;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
return e !== "heikinAshi" &&
|
|
228
|
+
function L(e) {
|
|
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;
|
|
@@ -278,15 +278,15 @@ var nn = class {
|
|
|
278
278
|
};
|
|
279
279
|
//#endregion
|
|
280
280
|
//#region src/DataManager.ts
|
|
281
|
-
function
|
|
281
|
+
function R(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 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
|
-
function
|
|
289
|
+
function z(e) {
|
|
290
290
|
return {
|
|
291
291
|
...e,
|
|
292
292
|
high: Math.max(e.open, e.high, e.low, e.close),
|
|
@@ -294,8 +294,20 @@ function I(e) {
|
|
|
294
294
|
volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
|
-
var
|
|
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 L = class {
|
|
|
303
315
|
let t = [];
|
|
304
316
|
for (let n = 0; n < e.length; n++) {
|
|
305
317
|
let r = e[n];
|
|
306
|
-
|
|
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 L = class {
|
|
|
320
333
|
return n.length = r, this.data = n.concat(this.data), r;
|
|
321
334
|
}
|
|
322
335
|
appendBar(e) {
|
|
323
|
-
|
|
336
|
+
R(e) && this.data.push(z(this.withSeriesTime(e)));
|
|
324
337
|
}
|
|
325
338
|
updateLastBar(e) {
|
|
326
|
-
if (!
|
|
327
|
-
let t =
|
|
339
|
+
if (!R(e)) return;
|
|
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 L = 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 L = 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 L = 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 L = 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";
|
|
@@ -428,7 +441,7 @@ var L = class {
|
|
|
428
441
|
return i;
|
|
429
442
|
}
|
|
430
443
|
getTheme() {
|
|
431
|
-
return this.effective ??=
|
|
444
|
+
return this.effective ??= te(this.base, this.chartType, this.merged()), this.effective;
|
|
432
445
|
}
|
|
433
446
|
getBaseTheme() {
|
|
434
447
|
return this.base;
|
|
@@ -480,7 +493,7 @@ var L = 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 L = 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 B(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 cn = 200, ln = 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 cn = 200, ln = 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 cn = 200, ln = 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 _n = 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 W = 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 Tn(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 En(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 En(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
|
-
},
|
|
886
|
-
function
|
|
887
|
-
if (typeof e == "string" && e !== "exchange" && !
|
|
898
|
+
}, Mn = "exchange";
|
|
899
|
+
function Nn(e) {
|
|
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
|
-
var
|
|
891
|
-
static version = "1.
|
|
903
|
+
var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine", "crossLine"]), Bn = new Set(["verticalLine", "crossLine"]), Vn = class {
|
|
904
|
+
static version = "1.25.0";
|
|
892
905
|
engine;
|
|
893
906
|
viewport;
|
|
894
907
|
dataManager;
|
|
@@ -926,14 +939,14 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
926
939
|
indicatorHistoryDepth = 0;
|
|
927
940
|
removedDrawingAlerts = /* @__PURE__ */ new Map();
|
|
928
941
|
zoomAreaMode = !1;
|
|
929
|
-
priceAxisAddButton = new
|
|
942
|
+
priceAxisAddButton = new Ke();
|
|
930
943
|
displayTz = null;
|
|
931
944
|
timezoneSetting = null;
|
|
932
945
|
symbolInfo = null;
|
|
933
946
|
symbolInfoSeq = 0;
|
|
934
947
|
sessionBreaks;
|
|
935
948
|
sessionShading;
|
|
936
|
-
hostSessionHours = { ...
|
|
949
|
+
hostSessionHours = { ...Te };
|
|
937
950
|
compareRenderer;
|
|
938
951
|
countdownInterval = null;
|
|
939
952
|
volumeRenderer;
|
|
@@ -946,7 +959,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
946
959
|
signalMarkerManager;
|
|
947
960
|
tradeZoneManager;
|
|
948
961
|
measureOverlay;
|
|
949
|
-
selectionBoxOverlay = new
|
|
962
|
+
selectionBoxOverlay = new Ze();
|
|
950
963
|
replayManager;
|
|
951
964
|
replayBarUnsub = null;
|
|
952
965
|
replaySeeking = !1;
|
|
@@ -956,7 +969,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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;
|
|
@@ -968,15 +981,15 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
968
981
|
disposed = !1;
|
|
969
982
|
chartTypeOptions = {};
|
|
970
983
|
mainSeriesVisible = !0;
|
|
971
|
-
priceLines = new
|
|
972
|
-
symbolSeries = new
|
|
984
|
+
priceLines = new qe();
|
|
985
|
+
symbolSeries = new it();
|
|
973
986
|
extendedHours = !0;
|
|
974
987
|
replayRestarting = !1;
|
|
975
988
|
fullSeries = null;
|
|
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;
|
|
@@ -1007,7 +1020,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1007
1020
|
snapshotKey = null;
|
|
1008
1021
|
historyCheckQueued = !1;
|
|
1009
1022
|
constructor(e, t) {
|
|
1010
|
-
t.timeZone != null &&
|
|
1023
|
+
t.timeZone != null && Nn(t.timeZone), this.container = e, this.options = {
|
|
1011
1024
|
...t,
|
|
1012
1025
|
chartType: t.chartType ?? "candlestick"
|
|
1013
1026
|
}, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
|
|
@@ -1045,15 +1058,15 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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
|
|
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();
|
|
1056
|
-
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new
|
|
1069
|
+
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new lt();
|
|
1057
1070
|
let i = "";
|
|
1058
1071
|
this.undoRedoManager.setOnChange(() => {
|
|
1059
1072
|
let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
|
|
@@ -1066,42 +1079,43 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1066
1079
|
primary: e[0] ?? null
|
|
1067
1080
|
})), this.drawingManager.setForeignHistory((e, t) => {
|
|
1068
1081
|
e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
|
|
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
|
|
1082
|
+
}), 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 st({
|
|
1070
1083
|
enabled: this.features.trading,
|
|
1071
1084
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
1072
|
-
}), this.tradingRenderer = new
|
|
1085
|
+
}), this.tradingRenderer = new ct(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
1073
1086
|
this.eventBus.emit(e, t);
|
|
1074
|
-
}), this.engine = new
|
|
1087
|
+
}), this.engine = new Je(e);
|
|
1075
1088
|
let a = this.engine.dprManager.getContainerSize();
|
|
1076
|
-
if (this.viewport = new
|
|
1089
|
+
if (this.viewport = new ut(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
|
|
1077
1090
|
freePan: t.freePan ?? !0,
|
|
1078
1091
|
minVisibleBars: t.panLimits?.minVisibleBars ?? 3
|
|
1079
1092
|
}), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
|
|
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
|
|
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:
|
|
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,
|
|
1096
1110
|
barIndex: e
|
|
1097
1111
|
});
|
|
1098
1112
|
} else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
|
|
1099
|
-
}), this.chartLegend = new
|
|
1113
|
+
}), this.chartLegend = new _e(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new mt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new pt(), this.volumeProfile = new ft(), this.marketProfile = new ze(), this.depthHeatmap = new Ee(), this.periodLevels = new Ue(), this.pivotMarkers = new Ge(), this.barCountdown = new pe(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new Qe(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new $e(), this.compareRenderer = new ve(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
1100
1114
|
visible: t.sessionBreaks.visible ?? !0,
|
|
1101
1115
|
color: t.sessionBreaks.color,
|
|
1102
1116
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
1103
1117
|
lineWidth: t.sessionBreaks.lineWidth
|
|
1104
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new
|
|
1118
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new ue(), this.crosshairTooltip = new Ce(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new We(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = b(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Wn(t.shapes)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Ie({
|
|
1105
1119
|
scrollBars: (e) => {
|
|
1106
1120
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
1107
1121
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -1118,17 +1132,17 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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",
|
|
1125
1139
|
bars: () => this.getDisplayData(),
|
|
1126
1140
|
visibleRange: () => this.viewport.getState().visibleRange,
|
|
1127
1141
|
formatPrice: (e) => this.formatPrice(e),
|
|
1128
|
-
formatTime: (e) =>
|
|
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 [
|
|
@@ -1148,22 +1162,22 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1148
1162
|
}
|
|
1149
1163
|
this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
|
|
1150
1164
|
}
|
|
1151
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new
|
|
1152
|
-
this.eventBus.emit("alertTriggered",
|
|
1165
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new we(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new le(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
|
|
1166
|
+
this.eventBus.emit("alertTriggered", G(e)), this.eventBus.emit("dataUpdate", {
|
|
1153
1167
|
alert: "triggered",
|
|
1154
1168
|
alertId: e.id,
|
|
1155
1169
|
price: e.price,
|
|
1156
1170
|
message: e.message
|
|
1157
1171
|
});
|
|
1158
1172
|
}), this.alertManager.on("added", (e) => {
|
|
1159
|
-
this.eventBus.emit("alertAdd",
|
|
1173
|
+
this.eventBus.emit("alertAdd", G(e));
|
|
1160
1174
|
}), this.alertManager.on("removed", (e) => {
|
|
1161
1175
|
this.eventBus.emit("alertRemove", { id: e });
|
|
1162
1176
|
}), this.alertManager.on("expired", (e) => {
|
|
1163
|
-
this.eventBus.emit("alertExpired",
|
|
1177
|
+
this.eventBus.emit("alertExpired", G(e));
|
|
1164
1178
|
}), this.alertManager.on("updated", (e) => {
|
|
1165
|
-
this.eventBus.emit("alertUpdate",
|
|
1166
|
-
}), this.signalMarkerManager = new
|
|
1179
|
+
this.eventBus.emit("alertUpdate", G(e));
|
|
1180
|
+
}), this.signalMarkerManager = new et(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
|
|
1167
1181
|
this.eventBus.emit("signalMarkerAdd", {
|
|
1168
1182
|
id: e.id,
|
|
1169
1183
|
source: e.source,
|
|
@@ -1171,14 +1185,14 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1171
1185
|
});
|
|
1172
1186
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
1173
1187
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
1174
|
-
}), this.tradeZoneManager = new
|
|
1188
|
+
}), this.tradeZoneManager = new ot(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
|
|
1175
1189
|
this.eventBus.emit("tradeZoneAdd", {
|
|
1176
1190
|
id: e.id,
|
|
1177
1191
|
direction: e.direction
|
|
1178
1192
|
});
|
|
1179
1193
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
1180
1194
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
1181
|
-
}), this.replayManager = new
|
|
1195
|
+
}), this.replayManager = new Xe(), this.replayManager.on("complete", () => {
|
|
1182
1196
|
let e = this.getReplayBarIndex(), t = this.replayCoarse?.[e];
|
|
1183
1197
|
t && this.eventBus.emit("replayComplete", {
|
|
1184
1198
|
barIndex: e,
|
|
@@ -1186,9 +1200,9 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1186
1200
|
});
|
|
1187
1201
|
}), this.replayManager.on("stateChange", (e) => {
|
|
1188
1202
|
this.replayRestarting || this.eventBus.emit("replayState", { state: e });
|
|
1189
|
-
}), this.measureOverlay = new
|
|
1190
|
-
let e = new
|
|
1191
|
-
this.interactionManager.setPanHandler(new
|
|
1203
|
+
}), this.measureOverlay = new Be(), this.interactionManager = new Pe(e), this.features.panning) {
|
|
1204
|
+
let e = new bn();
|
|
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()));
|
|
1194
1208
|
}
|
|
@@ -1200,10 +1214,10 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1200
1214
|
scales: !this.indicatorEngine.hasLeftScaleOverlays()
|
|
1201
1215
|
}
|
|
1202
1216
|
})), this.features.zooming) {
|
|
1203
|
-
this.interactionManager.setZoomHandler(new
|
|
1217
|
+
this.interactionManager.setZoomHandler(new ht((e, t) => {
|
|
1204
1218
|
this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
|
|
1205
1219
|
}));
|
|
1206
|
-
let e = new
|
|
1220
|
+
let e = new fe((e) => {
|
|
1207
1221
|
this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
1208
1222
|
}, (e) => {
|
|
1209
1223
|
let t = this.viewport.getState().chartRect.width;
|
|
@@ -1223,7 +1237,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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,
|
|
@@ -1233,15 +1247,15 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1233
1247
|
...this.viewport.getState(),
|
|
1234
1248
|
data: this.getDisplayData()
|
|
1235
1249
|
})), this.features.alerts) {
|
|
1236
|
-
let e = new
|
|
1250
|
+
let e = new ce(this.alertManager, () => this.viewport.getState());
|
|
1237
1251
|
this.interactionManager.setAlertDragHandler(e);
|
|
1238
1252
|
}
|
|
1239
|
-
let o = new
|
|
1253
|
+
let o = new He();
|
|
1240
1254
|
o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
|
|
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 jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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,
|
|
@@ -1300,7 +1314,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1300
1314
|
end: () => {
|
|
1301
1315
|
let e = this.selectionBoxOverlay.end();
|
|
1302
1316
|
if (e && this.zoomAreaMode) {
|
|
1303
|
-
if (e.x1 - e.x0 <
|
|
1317
|
+
if (e.x1 - e.x0 < Rn) return;
|
|
1304
1318
|
this.zoomToBox(e), this.setZoomAreaMode(!1);
|
|
1305
1319
|
return;
|
|
1306
1320
|
}
|
|
@@ -1337,7 +1351,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1337
1351
|
if (this.replaySession) return 0;
|
|
1338
1352
|
let t = null;
|
|
1339
1353
|
if (this.fullSeries) {
|
|
1340
|
-
let n = this.fullSeries[0]?.time, r = /* @__PURE__ */ new Set(), i = e.filter((e) =>
|
|
1354
|
+
let n = this.fullSeries[0]?.time, r = /* @__PURE__ */ new Set(), i = e.filter((e) => Qn(e) && (n === void 0 || e.time < n) && !r.has(e.time) && r.add(e.time)).sort((e, t) => e.time - t.time);
|
|
1341
1355
|
this.fullSeries = [...i, ...this.fullSeries];
|
|
1342
1356
|
let a = this.sessionKeep(this.fullSeries);
|
|
1343
1357
|
t = i.length, e = a ? i.filter((e) => a(e.time)) : i;
|
|
@@ -1346,7 +1360,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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;
|
|
@@ -1377,15 +1391,15 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1377
1391
|
}
|
|
1378
1392
|
checkHistory() {
|
|
1379
1393
|
this.historyCheckQueued || !this.history.hasLoader() || (this.historyCheckQueued = !0, queueMicrotask(() => {
|
|
1380
|
-
if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() ||
|
|
1394
|
+
if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() || L(this.options.chartType)) return;
|
|
1381
1395
|
let { from: e, to: t } = this.viewport.getState().visibleRange;
|
|
1382
|
-
this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(
|
|
1396
|
+
this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(Ln, t - e));
|
|
1383
1397
|
}));
|
|
1384
1398
|
}
|
|
1385
1399
|
useStreamHistory(e, t) {
|
|
1386
1400
|
if (this.hostHistoryLoader) return;
|
|
1387
|
-
let n =
|
|
1388
|
-
if (!r || i === null ||
|
|
1401
|
+
let n = Pt(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
|
|
1402
|
+
if (!r || i === null || ie(i) !== null) {
|
|
1389
1403
|
this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
|
|
1390
1404
|
return;
|
|
1391
1405
|
}
|
|
@@ -1451,17 +1465,17 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1451
1465
|
});
|
|
1452
1466
|
}
|
|
1453
1467
|
applyTimeSpacing() {
|
|
1454
|
-
let e = !this.tickStream && !
|
|
1468
|
+
let e = !this.tickStream && !L(this.options.chartType);
|
|
1455
1469
|
this.timeAxis.setTimesPastData(e), this.crosshairHandler.setTimesPastData(e);
|
|
1456
1470
|
}
|
|
1457
1471
|
setChartTypeOptions(e) {
|
|
1458
1472
|
this.chartTypeOptions = {
|
|
1459
1473
|
...this.chartTypeOptions,
|
|
1460
|
-
...
|
|
1474
|
+
...b(e)
|
|
1461
1475
|
}, this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged();
|
|
1462
1476
|
}
|
|
1463
1477
|
getChartTypeOptions() {
|
|
1464
|
-
return
|
|
1478
|
+
return b(this.chartTypeOptions);
|
|
1465
1479
|
}
|
|
1466
1480
|
setExtendedHours(e) {
|
|
1467
1481
|
e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
|
|
@@ -1470,7 +1484,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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);
|
|
@@ -1481,7 +1495,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1481
1495
|
return this.fullSeries = t ? e.slice() : null, t ? e.filter((e) => t(e.time)) : e;
|
|
1482
1496
|
}
|
|
1483
1497
|
placeStreamBar(e) {
|
|
1484
|
-
let t =
|
|
1498
|
+
let t = K(this.dataManager.getData(), e);
|
|
1485
1499
|
return t === "stale" ? !1 : (t === "append" ? this.dataManager.appendBar(e) : this.dataManager.updateLastBar(e), !0);
|
|
1486
1500
|
}
|
|
1487
1501
|
takeBar(e, t) {
|
|
@@ -1511,7 +1525,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1511
1525
|
return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
|
|
1512
1526
|
}
|
|
1513
1527
|
setShapes(e) {
|
|
1514
|
-
let t =
|
|
1528
|
+
let t = Wn(e);
|
|
1515
1529
|
t.tagRadius !== void 0 && (this.themeManager.setShape({
|
|
1516
1530
|
...this.themeManager.getTheme().shape,
|
|
1517
1531
|
...t
|
|
@@ -1556,7 +1570,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1556
1570
|
setSymbolSeries(e, t) {
|
|
1557
1571
|
e = e.trim(), this.symbolSeries.set(e, t), this.requestedSymbols.delete(e);
|
|
1558
1572
|
let n = this.dataManager.getData(), r = !1;
|
|
1559
|
-
for (let t of this.indicatorEngine.getActiveIndicators()) !
|
|
1573
|
+
for (let t of this.indicatorEngine.getActiveIndicators()) !W.has(t.id) || String(t.params.symbol ?? "").trim() !== e.trim() || (this.indicatorEngine.updateIndicator(t.instanceId, {}, n), r = !0);
|
|
1560
1574
|
r && (this.announceIndicatorUpdate(0), this.updateViewportAndRender());
|
|
1561
1575
|
}
|
|
1562
1576
|
forgetUnreadSymbols() {
|
|
@@ -1570,27 +1584,27 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1570
1584
|
let e = /* @__PURE__ */ new Set();
|
|
1571
1585
|
for (let t of this.indicatorEngine.getActiveIndicators()) {
|
|
1572
1586
|
let n = t.params.symbol;
|
|
1573
|
-
|
|
1587
|
+
W.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
|
|
1574
1588
|
}
|
|
1575
1589
|
return [...e];
|
|
1576
1590
|
}
|
|
1577
1591
|
requestMissingSymbols(e) {
|
|
1578
1592
|
this.forgetUnreadSymbols();
|
|
1579
|
-
let t = this.indicatorEngine.getIndicatorConfig(e), n = t &&
|
|
1593
|
+
let t = this.indicatorEngine.getIndicatorConfig(e), n = t && W.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
|
|
1580
1594
|
!n || this.symbolSeries.has(n) || this.requestedSymbols.has(n) || (this.requestedSymbols.add(n), this.eventBus.emit("symbolSeriesRequest", { symbol: n }));
|
|
1581
1595
|
}
|
|
1582
1596
|
updateIndicator(e, t) {
|
|
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 jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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) {
|
|
@@ -1644,8 +1658,8 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1644
1658
|
return {
|
|
1645
1659
|
...e,
|
|
1646
1660
|
priceRange: {
|
|
1647
|
-
min: t.min - n *
|
|
1648
|
-
max: t.max + n *
|
|
1661
|
+
min: t.min - n * Fn,
|
|
1662
|
+
max: t.max + n * Fn
|
|
1649
1663
|
},
|
|
1650
1664
|
logScale: !1,
|
|
1651
1665
|
scaleMode: "regular",
|
|
@@ -1692,7 +1706,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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 jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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 jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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 jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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);
|
|
@@ -1850,12 +1864,12 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1850
1864
|
return this.features.legend ? e + this.chartLegend.getHeight() : e;
|
|
1851
1865
|
}
|
|
1852
1866
|
isTimeAligned() {
|
|
1853
|
-
return
|
|
1867
|
+
return L(this.options.chartType) ? !1 : this.getDisplayData().length === this.dataManager.getLength();
|
|
1854
1868
|
}
|
|
1855
1869
|
roundPrice(e) {
|
|
1856
1870
|
if (!Number.isFinite(e)) return e;
|
|
1857
1871
|
let t = this.stepAt(e);
|
|
1858
|
-
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(
|
|
1872
|
+
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(re(t)));
|
|
1859
1873
|
let { min: n, max: r } = this.viewport.getState().priceRange;
|
|
1860
1874
|
return Number(e.toFixed(this.marketPricePrecision ?? s(n, r)));
|
|
1861
1875
|
}
|
|
@@ -1865,7 +1879,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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 jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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 jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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)));
|
|
@@ -1936,7 +1950,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1936
1950
|
}
|
|
1937
1951
|
autoFib() {
|
|
1938
1952
|
if (!this.features.drawings) return null;
|
|
1939
|
-
let e = this.getDisplayData(), t = this.viewport.getState(), n =
|
|
1953
|
+
let e = this.getDisplayData(), t = this.viewport.getState(), n = _t(e, t.visibleRange.from, t.visibleRange.to);
|
|
1940
1954
|
return n ? this.addDrawing({
|
|
1941
1955
|
type: "fibRetracement",
|
|
1942
1956
|
anchors: [n[0], n[1]]
|
|
@@ -2011,7 +2025,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2011
2025
|
recordUndo(e) {
|
|
2012
2026
|
if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
|
|
2013
2027
|
let t = performance.now(), n = this.undoRedoManager.last();
|
|
2014
|
-
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at <
|
|
2028
|
+
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < In) {
|
|
2015
2029
|
this.undoRedoManager.replaceLast({
|
|
2016
2030
|
...n,
|
|
2017
2031
|
custom: {
|
|
@@ -2058,7 +2072,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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
|
}
|
|
@@ -2084,7 +2098,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2084
2098
|
...this.viewport.getState(),
|
|
2085
2099
|
data: this.getDisplayData()
|
|
2086
2100
|
};
|
|
2087
|
-
this.setVisibleRange(
|
|
2101
|
+
this.setVisibleRange(F(e.x0, t), F(e.x1, t));
|
|
2088
2102
|
}
|
|
2089
2103
|
lockAllDrawings() {
|
|
2090
2104
|
this.drawingManager.lockAllDrawings();
|
|
@@ -2129,7 +2143,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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 jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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 jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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,8 +2331,8 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2317
2331
|
this.features.trading && this.tradingManager.setConfig(e);
|
|
2318
2332
|
}
|
|
2319
2333
|
async connect(e) {
|
|
2320
|
-
if (!
|
|
2321
|
-
this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new
|
|
2334
|
+
if (!M(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
|
|
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);
|
|
2324
2338
|
}), this.streamManager.on("barClose", (e) => {
|
|
@@ -2326,7 +2340,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2326
2340
|
this.replaySession.live.appendBar(e);
|
|
2327
2341
|
return;
|
|
2328
2342
|
}
|
|
2329
|
-
let t =
|
|
2343
|
+
let t = K(this.fullSeries ?? this.dataManager.getData(), e);
|
|
2330
2344
|
if (t === "stale" || !this.takeBar(e, t)) return;
|
|
2331
2345
|
let n = this.autoScrollOnNewBar && this.viewport.isAtEnd();
|
|
2332
2346
|
if (!this.placeStreamBar(e)) return;
|
|
@@ -2338,7 +2352,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2338
2352
|
return;
|
|
2339
2353
|
}
|
|
2340
2354
|
this.currentPriceLine.setPrice(e.close);
|
|
2341
|
-
let t =
|
|
2355
|
+
let t = K(this.fullSeries ?? this.dataManager.getData(), e);
|
|
2342
2356
|
if (t === "stale" || !this.takeBar(e, t) || !this.placeStreamBar(e)) {
|
|
2343
2357
|
this.scheduleRender();
|
|
2344
2358
|
return;
|
|
@@ -2367,14 +2381,14 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2367
2381
|
}), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
|
|
2368
2382
|
let t = this.streamManager;
|
|
2369
2383
|
if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
|
|
2370
|
-
let n =
|
|
2384
|
+
let n = ae(e.timeframe);
|
|
2371
2385
|
this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
|
|
2372
2386
|
this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
|
|
2373
2387
|
}, 1e3);
|
|
2374
2388
|
}
|
|
2375
2389
|
setStreamTarget(e, t) {
|
|
2376
2390
|
let n = this.announcedSymbol, r = this.announcedTimeframe;
|
|
2377
|
-
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream =
|
|
2391
|
+
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = ie(t) !== null, this.applyTimeSpacing(), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
|
|
2378
2392
|
symbol: e,
|
|
2379
2393
|
previous: n
|
|
2380
2394
|
})), t !== r && (this.announcedTimeframe = t, this.eventBus.emit("timeframeChange", {
|
|
@@ -2385,8 +2399,8 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2385
2399
|
async switchStream(e, t) {
|
|
2386
2400
|
if (!this.streamManager) return;
|
|
2387
2401
|
let n = this.streamAdapter;
|
|
2388
|
-
if (n && !
|
|
2389
|
-
this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(
|
|
2402
|
+
if (n && !M(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
|
|
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) {
|
|
2392
2406
|
let t = this.features.timeframes;
|
|
@@ -2401,7 +2415,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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 jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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 jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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 jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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) {
|
|
@@ -2560,7 +2574,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2560
2574
|
this.applyStyle(e, t.layer ?? "host", !0);
|
|
2561
2575
|
}
|
|
2562
2576
|
setOverrides(e, t = {}) {
|
|
2563
|
-
let n = t.layer ?? "host", { overrides: r, rejected: i } =
|
|
2577
|
+
let n = t.layer ?? "host", { overrides: r, rejected: i } = y(e);
|
|
2564
2578
|
i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`);
|
|
2565
2579
|
let a = Object.fromEntries(Object.entries(r).filter(([, e]) => e !== null));
|
|
2566
2580
|
this.themeManager.setOverrides(a, n) && this.styleChanged(n);
|
|
@@ -2579,7 +2593,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2579
2593
|
return this.themeManager.getStyleValue(e);
|
|
2580
2594
|
}
|
|
2581
2595
|
applyStyle(e, t, n) {
|
|
2582
|
-
let { overrides: r, rejected: i } =
|
|
2596
|
+
let { overrides: r, rejected: i } = y(e);
|
|
2583
2597
|
i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`), this.themeManager.applyOverrides(r, t) && n && this.styleChanged(t);
|
|
2584
2598
|
}
|
|
2585
2599
|
styleChanged(e) {
|
|
@@ -2609,7 +2623,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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() {
|
|
@@ -2671,7 +2685,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2671
2685
|
this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
|
|
2672
2686
|
}
|
|
2673
2687
|
setTimezone(e) {
|
|
2674
|
-
|
|
2688
|
+
Nn(e), this.timezoneSetting = e, this.applyTimezone();
|
|
2675
2689
|
}
|
|
2676
2690
|
getTimezone() {
|
|
2677
2691
|
return this.timezoneSetting;
|
|
@@ -2680,7 +2694,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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 jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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,
|
|
@@ -2746,7 +2760,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2746
2760
|
return this.sessionShading.isVisible();
|
|
2747
2761
|
}
|
|
2748
2762
|
setSessionShadingConfig(e) {
|
|
2749
|
-
this.hostSessionHours =
|
|
2763
|
+
this.hostSessionHours = xt(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
|
|
2750
2764
|
}
|
|
2751
2765
|
setTooltipVisible(e) {
|
|
2752
2766
|
e || this.crosshairTooltip.hide();
|
|
@@ -2765,11 +2779,11 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2765
2779
|
return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
|
|
2766
2780
|
}
|
|
2767
2781
|
async takeGpu(e, t, n) {
|
|
2768
|
-
let { gpu: r, reason: i } = await
|
|
2769
|
-
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ?
|
|
2782
|
+
let { gpu: r, reason: i } = await bt(e);
|
|
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 jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
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;
|
|
@@ -2931,7 +2945,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2931
2945
|
let t = this.replaySession ? this.replayOffset : 0;
|
|
2932
2946
|
if (!this.replaySession) {
|
|
2933
2947
|
if (this.dataManager.getLength() === 0) return;
|
|
2934
|
-
let e = new
|
|
2948
|
+
let e = new B();
|
|
2935
2949
|
e.setData(this.fullSeries ?? this.dataManager.getData()), this.replaySession = {
|
|
2936
2950
|
live: e,
|
|
2937
2951
|
price: null,
|
|
@@ -2939,23 +2953,23 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2939
2953
|
};
|
|
2940
2954
|
}
|
|
2941
2955
|
let { steps: n, startTime: r, hideHistory: i, revealMarks: a, ...o } = e ?? {}, s = this.shownBars(this.replaySession.live.getData()), c = t > 0 && r === void 0 && i !== !1, l = o.startIndex;
|
|
2942
|
-
r !== void 0 && l === void 0 ? l =
|
|
2956
|
+
r !== void 0 && l === void 0 ? l = qn(s, r) : c && l !== void 0 && (l += t);
|
|
2943
2957
|
let u = c ? t : i && l !== void 0 && l > 0 ? Math.min(Math.floor(l), s.length - 1) : 0, d = u > 0 ? s.slice(u) : s;
|
|
2944
2958
|
l !== void 0 && (o.startIndex = l - u), this.replayOffset = u, this.replayRevealMarks = a !== !1;
|
|
2945
|
-
let f = n ?
|
|
2959
|
+
let f = n ? Zn(n, d) : null;
|
|
2946
2960
|
this.replayStepsSeries = f, this.replayCoarse = d, this.options.autoScale = !0, this.replayRestarting = !0;
|
|
2947
2961
|
try {
|
|
2948
2962
|
this.replayManager.load(f ?? d);
|
|
2949
2963
|
} finally {
|
|
2950
2964
|
this.replayRestarting = !1;
|
|
2951
2965
|
}
|
|
2952
|
-
f && o.startIndex !== void 0 && (o.startIndex =
|
|
2966
|
+
f && o.startIndex !== void 0 && (o.startIndex = er(f, d, o.startIndex)), this.replayBarUnsub?.();
|
|
2953
2967
|
let p = -1, m = -1, h = null, g = f ?? d;
|
|
2954
2968
|
this.replayBarUnsub = this.replayManager.on("bar", ({ index: e }) => {
|
|
2955
2969
|
let t = e, n = d[e];
|
|
2956
2970
|
if (f) {
|
|
2957
2971
|
let r = f[e];
|
|
2958
|
-
t =
|
|
2972
|
+
t = $n(d, r.time), h = h !== null && m === e - 1 && t === p - 1 && h ? nr(h, r) : tr(d[t], f, e), n = h;
|
|
2959
2973
|
}
|
|
2960
2974
|
m = e;
|
|
2961
2975
|
let r = t + 1, i = p > 0 && r >= p && this.dataManager.getLength() === p, a = !(i && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
|
|
@@ -3007,20 +3021,20 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3007
3021
|
return;
|
|
3008
3022
|
}
|
|
3009
3023
|
if (i.time <= n.fedTime) return;
|
|
3010
|
-
let a = e.slice(
|
|
3024
|
+
let a = e.slice(Jn(e, n.fedTime), t + 1);
|
|
3011
3025
|
n.fedTime = i.time;
|
|
3012
|
-
let o = Math.ceil(a.length /
|
|
3013
|
-
for (let e = 0; e < a.length; e += o) for (let [t, n] of
|
|
3026
|
+
let o = Math.ceil(a.length / Kn);
|
|
3027
|
+
for (let e = 0; e < a.length; e += o) for (let [t, n] of Yn(a.slice(e, e + o))) r.setMarkPrice(t, n);
|
|
3014
3028
|
this.tradingManager.setCurrentPrice(i.close);
|
|
3015
3029
|
}
|
|
3016
3030
|
getReplayBarIndex() {
|
|
3017
3031
|
if (!this.replaySession) return -1;
|
|
3018
3032
|
let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
|
|
3019
|
-
return t && this.replayCoarse ?
|
|
3033
|
+
return t && this.replayCoarse ? $n(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
|
|
3020
3034
|
}
|
|
3021
3035
|
replaySeekToBar(e) {
|
|
3022
3036
|
let t = this.replayStepsSeries;
|
|
3023
|
-
this.replaySeek(t && this.replayCoarse ?
|
|
3037
|
+
this.replaySeek(t && this.replayCoarse ? er(t, this.replayCoarse, e) : e);
|
|
3024
3038
|
}
|
|
3025
3039
|
replayPause() {
|
|
3026
3040
|
this.replayManager.pause();
|
|
@@ -3044,6 +3058,24 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3044
3058
|
height: r
|
|
3045
3059
|
};
|
|
3046
3060
|
}
|
|
3061
|
+
getDrawingRect(e) {
|
|
3062
|
+
let t = this.drawingManager.getDrawings().find((t) => t.id === e);
|
|
3063
|
+
if (!t || !t.visible || t.anchors.length === 0) return null;
|
|
3064
|
+
let n = {
|
|
3065
|
+
...this.viewport.getState(),
|
|
3066
|
+
data: this.getDisplayData()
|
|
3067
|
+
}, r = n.chartRect, i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
|
|
3068
|
+
for (let e of t.anchors) {
|
|
3069
|
+
let t = Et(e.time, n), r = St(e.price, n);
|
|
3070
|
+
i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
|
|
3071
|
+
}
|
|
3072
|
+
return zn.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Bn.has(t.type) && ([o, s] = [r.y, r.y + r.height]), i = Math.max(i, r.x), a = Math.min(a, r.x + r.width), o = Math.max(o, r.y), s = Math.min(s, r.y + r.height), i <= a && o <= s ? {
|
|
3073
|
+
x: i,
|
|
3074
|
+
y: o,
|
|
3075
|
+
width: a - i,
|
|
3076
|
+
height: s - o
|
|
3077
|
+
} : null;
|
|
3078
|
+
}
|
|
3047
3079
|
endReplaySession() {
|
|
3048
3080
|
this.replaySession && (this.returnMarkToLive(), this.replaySession = null, this.replayStepsSeries = null, this.replayCoarse = null, this.replayBarUnsub?.(), this.replayBarUnsub = null, this.replayManager.stop(), this.replayOffset = 0, this.revealReplayMarks(null));
|
|
3049
3081
|
}
|
|
@@ -3065,7 +3097,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3065
3097
|
return this.replayManager.getProgress();
|
|
3066
3098
|
}
|
|
3067
3099
|
captureSnapshot() {
|
|
3068
|
-
return
|
|
3100
|
+
return w.capture({
|
|
3069
3101
|
getDrawings: () => this.getDrawings(),
|
|
3070
3102
|
getTheme: () => this.themeManager.getBaseTheme(),
|
|
3071
3103
|
getAlerts: () => this.getAlerts(),
|
|
@@ -3078,14 +3110,14 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3078
3110
|
});
|
|
3079
3111
|
}
|
|
3080
3112
|
restoreIndicators(e, t) {
|
|
3081
|
-
let n =
|
|
3113
|
+
let n = Hn(e), r = /* @__PURE__ */ new Map();
|
|
3082
3114
|
this.unrestoredIndicators = [];
|
|
3083
3115
|
let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
|
|
3084
3116
|
if (t) {
|
|
3085
3117
|
let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
|
|
3086
3118
|
for (let n of t) {
|
|
3087
3119
|
let t = e.get(n.instanceId);
|
|
3088
|
-
t &&
|
|
3120
|
+
t && Un(n, t) && o.add(n.instanceId);
|
|
3089
3121
|
}
|
|
3090
3122
|
for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
|
|
3091
3123
|
for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
|
|
@@ -3093,8 +3125,8 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3093
3125
|
let s = (e) => {
|
|
3094
3126
|
let t = { ...e };
|
|
3095
3127
|
for (let [e, n] of Object.entries(t)) {
|
|
3096
|
-
let i =
|
|
3097
|
-
a && (t[e] =
|
|
3128
|
+
let i = _(n), a = i && r.get(i.instanceId);
|
|
3129
|
+
a && (t[e] = p(a, i.key));
|
|
3098
3130
|
}
|
|
3099
3131
|
return t;
|
|
3100
3132
|
};
|
|
@@ -3145,7 +3177,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3145
3177
|
let o = this.indicatorEngine.getIndicatorConfig(e);
|
|
3146
3178
|
(t.visible ?? !0) !== (o?.visible ?? !0) && this.setIndicatorVisible(e, t.visible ?? !0);
|
|
3147
3179
|
let s = t.levels ?? null;
|
|
3148
|
-
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);
|
|
3149
3181
|
}
|
|
3150
3182
|
restorePanes(e) {
|
|
3151
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, {
|
|
@@ -3226,7 +3258,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3226
3258
|
if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
|
|
3227
3259
|
let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
|
|
3228
3260
|
if (JSON.stringify(n) === JSON.stringify(i)) return r;
|
|
3229
|
-
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) <
|
|
3261
|
+
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < In && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
|
|
3230
3262
|
type: "indicators",
|
|
3231
3263
|
before: null,
|
|
3232
3264
|
after: null
|
|
@@ -3254,12 +3286,12 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3254
3286
|
}
|
|
3255
3287
|
saveState(e) {
|
|
3256
3288
|
if (!this.features.saveLoad) return null;
|
|
3257
|
-
let t = this.captureSnapshot(), n =
|
|
3258
|
-
return e &&
|
|
3289
|
+
let t = this.captureSnapshot(), n = w.serialize(t);
|
|
3290
|
+
return e && w.saveToStorage(e, t), n;
|
|
3259
3291
|
}
|
|
3260
3292
|
loadState(e) {
|
|
3261
3293
|
if (!this.features.saveLoad) return;
|
|
3262
|
-
let t =
|
|
3294
|
+
let t = w.deserialize(e);
|
|
3263
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");
|
|
3264
3296
|
let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
|
|
3265
3297
|
if (this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
|
|
@@ -3270,7 +3302,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3270
3302
|
let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
|
|
3271
3303
|
return r ? r + e.slice(t) : e;
|
|
3272
3304
|
}, r = t(e.channel), i = {
|
|
3273
|
-
...
|
|
3305
|
+
...wt(e),
|
|
3274
3306
|
...e.target ? { target: t(e.target) } : {}
|
|
3275
3307
|
};
|
|
3276
3308
|
if (!e.expired) {
|
|
@@ -3290,19 +3322,19 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3290
3322
|
}
|
|
3291
3323
|
loadStateFromStorage(e) {
|
|
3292
3324
|
if (!this.features.saveLoad) return !1;
|
|
3293
|
-
let t =
|
|
3294
|
-
return t ? (this.loadState(
|
|
3325
|
+
let t = w.loadFromStorage(e);
|
|
3326
|
+
return t ? (this.loadState(w.serialize(t)), !0) : !1;
|
|
3295
3327
|
}
|
|
3296
3328
|
downloadState(e) {
|
|
3297
|
-
this.features.saveLoad &&
|
|
3329
|
+
this.features.saveLoad && w.downloadFile(this.captureSnapshot(), e);
|
|
3298
3330
|
}
|
|
3299
3331
|
async loadStateFromFile() {
|
|
3300
3332
|
if (!this.features.saveLoad) return;
|
|
3301
|
-
let e = await
|
|
3302
|
-
this.loadState(
|
|
3333
|
+
let e = await w.loadFromFile();
|
|
3334
|
+
this.loadState(w.serialize(e));
|
|
3303
3335
|
}
|
|
3304
3336
|
setLocale(e) {
|
|
3305
|
-
|
|
3337
|
+
ne(e), this.engine.requestRender();
|
|
3306
3338
|
}
|
|
3307
3339
|
setNumberLocale(e) {
|
|
3308
3340
|
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();
|
|
@@ -3318,22 +3350,22 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3318
3350
|
candleDown: e.colorScheme.down,
|
|
3319
3351
|
candleUpWick: e.colorScheme.up,
|
|
3320
3352
|
candleDownWick: e.colorScheme.down,
|
|
3321
|
-
volumeUp:
|
|
3322
|
-
volumeDown:
|
|
3353
|
+
volumeUp: oe(e.colorScheme.up),
|
|
3354
|
+
volumeDown: oe(e.colorScheme.down)
|
|
3323
3355
|
};
|
|
3324
3356
|
this.themeManager.setTheme(t);
|
|
3325
3357
|
}
|
|
3326
3358
|
e.pricePrecision !== void 0 && this.applyPricePrecision(e.pricePrecision), this.updateViewportAndRender();
|
|
3327
3359
|
}
|
|
3328
3360
|
applyPricePrecision(e) {
|
|
3329
|
-
this.marketPricePrecision = e, this.priceAxis.setPricePrecision(e), this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ??
|
|
3361
|
+
this.marketPricePrecision = e, this.priceAxis.setPricePrecision(e), this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ?? Pn), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
|
|
3330
3362
|
}
|
|
3331
3363
|
getMarket() {
|
|
3332
3364
|
return this.marketConfig;
|
|
3333
3365
|
}
|
|
3334
3366
|
getPriceLimits() {
|
|
3335
3367
|
let e = this.marketConfig;
|
|
3336
|
-
return !e?.priceLimits?.enabled || !e.priceLimits.referencePrice ? null :
|
|
3368
|
+
return !e?.priceLimits?.enabled || !e.priceLimits.referencePrice ? null : u(e.priceLimits.referencePrice, e);
|
|
3337
3369
|
}
|
|
3338
3370
|
setPriceLimits(e) {
|
|
3339
3371
|
this.marketConfig?.priceLimits && (this.marketConfig = {
|
|
@@ -3363,15 +3395,18 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3363
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 = "";
|
|
3364
3396
|
}
|
|
3365
3397
|
createChartRenderer(e) {
|
|
3366
|
-
let t =
|
|
3367
|
-
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();
|
|
3368
3403
|
}
|
|
3369
3404
|
getDisplayData() {
|
|
3370
3405
|
if (this.displayDataCache) return this.displayDataCache;
|
|
3371
3406
|
let e = this.dataManager.getData();
|
|
3372
3407
|
if (e.length === 0) return e;
|
|
3373
|
-
let t =
|
|
3374
|
-
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;
|
|
3375
3410
|
}
|
|
3376
3411
|
recalcIndicatorsFrom(e, t) {
|
|
3377
3412
|
this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
|
|
@@ -3406,7 +3441,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3406
3441
|
this.viewport.setScaleBaseline(t[e]?.close);
|
|
3407
3442
|
}
|
|
3408
3443
|
if (n) {
|
|
3409
|
-
let e =
|
|
3444
|
+
let e = Gn(this.indicatorEngine.getOverlayPriceRange(r.visibleRange.from, Math.min(r.visibleRange.to, t.length - 1)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(t, r) : null);
|
|
3410
3445
|
if (e) {
|
|
3411
3446
|
let t = r.priceRange, n = Math.min(t.min, e.min), i = Math.max(t.max, e.max);
|
|
3412
3447
|
if (n < t.min || i > t.max) {
|
|
@@ -3430,7 +3465,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3430
3465
|
fitLeftAxisWidth() {
|
|
3431
3466
|
let e = this.leftViewport;
|
|
3432
3467
|
if (!e) return !1;
|
|
3433
|
-
let t = this.themeManager.getTheme(), n =
|
|
3468
|
+
let t = this.themeManager.getTheme(), n = vn({
|
|
3434
3469
|
min: e.priceRange.min,
|
|
3435
3470
|
max: e.priceRange.max,
|
|
3436
3471
|
lastPrice: null,
|
|
@@ -3439,12 +3474,12 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3439
3474
|
fontFamily: t.font.family,
|
|
3440
3475
|
fontSizeSmall: t.font.sizeSmall,
|
|
3441
3476
|
measure: (e, t) => this.measureText(e, t)
|
|
3442
|
-
}), r =
|
|
3477
|
+
}), r = yn(this.leftAxisWidth, n);
|
|
3443
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);
|
|
3444
3479
|
}
|
|
3445
3480
|
fitPriceAxisWidth() {
|
|
3446
3481
|
if (!this.features.priceAxis) return !1;
|
|
3447
|
-
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n =
|
|
3482
|
+
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = vn({
|
|
3448
3483
|
min: e.min,
|
|
3449
3484
|
max: e.max,
|
|
3450
3485
|
lastPrice: this.currentPriceLine.getPrice(),
|
|
@@ -3455,7 +3490,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3455
3490
|
fontFamily: t.font.family,
|
|
3456
3491
|
fontSizeSmall: t.font.sizeSmall,
|
|
3457
3492
|
measure: (e, t) => this.measureText(e, t)
|
|
3458
|
-
}), r =
|
|
3493
|
+
}), r = yn(this.priceAxisWidth, n);
|
|
3459
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);
|
|
3460
3495
|
}
|
|
3461
3496
|
measureText(e, t) {
|
|
@@ -3499,7 +3534,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3499
3534
|
buildPanelRenderInfos() {
|
|
3500
3535
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
3501
3536
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
3502
|
-
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 = {
|
|
3503
3538
|
x: e.rect.x,
|
|
3504
3539
|
y: e.rect.y + 20,
|
|
3505
3540
|
width: e.rect.width,
|
|
@@ -3581,7 +3616,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3581
3616
|
});
|
|
3582
3617
|
}
|
|
3583
3618
|
drawOverlayPlugins(e, t) {
|
|
3584
|
-
let n =
|
|
3619
|
+
let n = Sn(this.pluginManager.getOverlays(), t);
|
|
3585
3620
|
if (n.length === 0) return;
|
|
3586
3621
|
let r = {
|
|
3587
3622
|
viewport: this.viewport.getState(),
|
|
@@ -3602,11 +3637,11 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3602
3637
|
};
|
|
3603
3638
|
}
|
|
3604
3639
|
};
|
|
3605
|
-
function
|
|
3640
|
+
function Hn(e) {
|
|
3606
3641
|
let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
3607
3642
|
if (r.has(e.instanceId) || i.has(e.instanceId)) return;
|
|
3608
3643
|
i.add(e.instanceId);
|
|
3609
|
-
let o = [e.pane, ...Object.values(e.params).map((e) =>
|
|
3644
|
+
let o = [e.pane, ...Object.values(e.params).map((e) => _(e)?.instanceId)];
|
|
3610
3645
|
for (let e of o) {
|
|
3611
3646
|
let n = e ? t.get(e) : void 0;
|
|
3612
3647
|
n && a(n);
|
|
@@ -3616,26 +3651,26 @@ function Ln(e) {
|
|
|
3616
3651
|
for (let t of e) a(t);
|
|
3617
3652
|
return n;
|
|
3618
3653
|
}
|
|
3619
|
-
function
|
|
3654
|
+
function Un(e, t) {
|
|
3620
3655
|
return e.id === t.id && (e.pane ?? null) === (t.pane ?? null) && (e.scale ?? null) === (t.scale ?? null) && e.position === void 0 == (t.position === void 0);
|
|
3621
3656
|
}
|
|
3622
|
-
function
|
|
3657
|
+
function Wn(e) {
|
|
3623
3658
|
let t = e.tagRadius;
|
|
3624
3659
|
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
|
|
3625
3660
|
}
|
|
3626
|
-
var
|
|
3661
|
+
var W = new Set([
|
|
3627
3662
|
"compareSymbol",
|
|
3628
3663
|
"spread",
|
|
3629
3664
|
"correlation",
|
|
3630
3665
|
"correlationlog"
|
|
3631
3666
|
]);
|
|
3632
|
-
function
|
|
3667
|
+
function Gn(e, t) {
|
|
3633
3668
|
return e ? t ? {
|
|
3634
3669
|
min: Math.min(e.min, t.min),
|
|
3635
3670
|
max: Math.max(e.max, t.max)
|
|
3636
3671
|
} : e : t;
|
|
3637
3672
|
}
|
|
3638
|
-
function
|
|
3673
|
+
function G(e) {
|
|
3639
3674
|
return {
|
|
3640
3675
|
id: e.id,
|
|
3641
3676
|
price: e.price,
|
|
@@ -3650,8 +3685,8 @@ function K(e) {
|
|
|
3650
3685
|
bars: e.bars
|
|
3651
3686
|
};
|
|
3652
3687
|
}
|
|
3653
|
-
var
|
|
3654
|
-
function
|
|
3688
|
+
var Kn = 500;
|
|
3689
|
+
function qn(e, t) {
|
|
3655
3690
|
let n = 0, r = e.length;
|
|
3656
3691
|
for (; n < r;) {
|
|
3657
3692
|
let i = n + r >> 1;
|
|
@@ -3659,7 +3694,7 @@ function Hn(e, t) {
|
|
|
3659
3694
|
}
|
|
3660
3695
|
return n;
|
|
3661
3696
|
}
|
|
3662
|
-
function
|
|
3697
|
+
function Jn(e, t) {
|
|
3663
3698
|
let n = 0, r = e.length;
|
|
3664
3699
|
for (; n < r;) {
|
|
3665
3700
|
let i = n + r >> 1;
|
|
@@ -3667,20 +3702,20 @@ function Un(e, t) {
|
|
|
3667
3702
|
}
|
|
3668
3703
|
return n;
|
|
3669
3704
|
}
|
|
3670
|
-
function
|
|
3705
|
+
function Yn(e) {
|
|
3671
3706
|
let t = 0, n = 0;
|
|
3672
3707
|
for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
|
|
3673
3708
|
let r = [e[t].low, e[t].time], i = [e[n].high, e[n].time], a = t === n ? e[t].close >= e[t].open : t < n, o = e[e.length - 1];
|
|
3674
3709
|
return [...a ? [r, i] : [i, r], [o.close, o.time]];
|
|
3675
3710
|
}
|
|
3676
|
-
function
|
|
3711
|
+
function Xn(e) {
|
|
3677
3712
|
let t = 0;
|
|
3678
3713
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
|
|
3679
3714
|
return t > 0 ? t : Infinity;
|
|
3680
3715
|
}
|
|
3681
|
-
function
|
|
3716
|
+
function Zn(e, t) {
|
|
3682
3717
|
if (t.length === 0) return null;
|
|
3683
|
-
let n = t[t.length - 1].time +
|
|
3718
|
+
let n = t[t.length - 1].time + Xn(t), r = e.filter((e) => Qn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
|
|
3684
3719
|
for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
|
|
3685
3720
|
if (i.length === 0) return null;
|
|
3686
3721
|
let a = t.findIndex((e) => e.time >= i[0].time);
|
|
@@ -3688,7 +3723,7 @@ function Kn(e, t) {
|
|
|
3688
3723
|
let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
|
|
3689
3724
|
return [...o, ...s];
|
|
3690
3725
|
}
|
|
3691
|
-
function
|
|
3726
|
+
function Qn(e) {
|
|
3692
3727
|
return [
|
|
3693
3728
|
e.time,
|
|
3694
3729
|
e.open,
|
|
@@ -3697,7 +3732,7 @@ function qn(e) {
|
|
|
3697
3732
|
e.close
|
|
3698
3733
|
].every(Number.isFinite);
|
|
3699
3734
|
}
|
|
3700
|
-
function
|
|
3735
|
+
function $n(e, t) {
|
|
3701
3736
|
let n = 0, r = e.length - 1;
|
|
3702
3737
|
for (; n < r;) {
|
|
3703
3738
|
let i = n + r + 1 >> 1;
|
|
@@ -3705,22 +3740,22 @@ function Jn(e, t) {
|
|
|
3705
3740
|
}
|
|
3706
3741
|
return n;
|
|
3707
3742
|
}
|
|
3708
|
-
function
|
|
3743
|
+
function er(e, t, n) {
|
|
3709
3744
|
let r = Math.max(0, Math.min(Math.floor(Number.isFinite(n) ? n : 0), t.length - 1)), i = r + 1 < t.length ? t[r + 1].time : Infinity, a = -1;
|
|
3710
3745
|
for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
|
|
3711
3746
|
return Math.max(0, a);
|
|
3712
3747
|
}
|
|
3713
|
-
function
|
|
3748
|
+
function tr(e, t, n) {
|
|
3714
3749
|
let r = n;
|
|
3715
3750
|
for (; r > 0 && t[r - 1].time >= e.time;) r--;
|
|
3716
3751
|
let i = {
|
|
3717
3752
|
...t[r],
|
|
3718
3753
|
time: e.time
|
|
3719
3754
|
};
|
|
3720
|
-
for (let e = r + 1; e <= n; e++) i =
|
|
3755
|
+
for (let e = r + 1; e <= n; e++) i = nr(i, t[e]);
|
|
3721
3756
|
return i;
|
|
3722
3757
|
}
|
|
3723
|
-
function
|
|
3758
|
+
function nr(e, t) {
|
|
3724
3759
|
return {
|
|
3725
3760
|
time: e.time,
|
|
3726
3761
|
open: e.open,
|
|
@@ -3730,34 +3765,34 @@ function Zn(e, t) {
|
|
|
3730
3765
|
volume: (e.volume ?? 0) + (t.volume ?? 0)
|
|
3731
3766
|
};
|
|
3732
3767
|
}
|
|
3733
|
-
function
|
|
3768
|
+
function K(e, t) {
|
|
3734
3769
|
let n = e[e.length - 1];
|
|
3735
3770
|
if (!n) return "append";
|
|
3736
|
-
let r =
|
|
3771
|
+
let r = g(t.time), i = g(n.time);
|
|
3737
3772
|
return r > i ? "append" : r === i ? "update" : "stale";
|
|
3738
3773
|
}
|
|
3739
3774
|
//#endregion
|
|
3740
3775
|
//#region src/io/parseOHLCV.ts
|
|
3741
|
-
var
|
|
3776
|
+
var rr = [
|
|
3742
3777
|
"time",
|
|
3743
3778
|
"timestamp",
|
|
3744
3779
|
"date",
|
|
3745
3780
|
"datetime",
|
|
3746
3781
|
"t"
|
|
3747
|
-
],
|
|
3782
|
+
], ir = ["open", "o"], ar = ["high", "h"], or = ["low", "l"], sr = ["close", "c"], cr = [
|
|
3748
3783
|
"volume",
|
|
3749
3784
|
"vol",
|
|
3750
3785
|
"v"
|
|
3751
3786
|
];
|
|
3752
|
-
function
|
|
3787
|
+
function lr(e) {
|
|
3753
3788
|
let t = e.trim();
|
|
3754
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
3789
|
+
return t ? t[0] === "[" || t[0] === "{" ? ur(t) : dr(t) : {
|
|
3755
3790
|
data: [],
|
|
3756
3791
|
rowCount: 0,
|
|
3757
3792
|
skipped: 0
|
|
3758
3793
|
};
|
|
3759
3794
|
}
|
|
3760
|
-
function
|
|
3795
|
+
function ur(e) {
|
|
3761
3796
|
let t;
|
|
3762
3797
|
try {
|
|
3763
3798
|
t = JSON.parse(e);
|
|
@@ -3767,19 +3802,19 @@ function ar(e) {
|
|
|
3767
3802
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
3768
3803
|
let n = [], r = 0;
|
|
3769
3804
|
for (let e of t) {
|
|
3770
|
-
let t = Array.isArray(e) ?
|
|
3805
|
+
let t = Array.isArray(e) ? gr(e) : hr(e);
|
|
3771
3806
|
t ? n.push(t) : r++;
|
|
3772
3807
|
}
|
|
3773
|
-
return
|
|
3808
|
+
return _r(n, t.length, r);
|
|
3774
3809
|
}
|
|
3775
|
-
function
|
|
3810
|
+
function dr(e) {
|
|
3776
3811
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
3777
3812
|
if (t.length === 0) return {
|
|
3778
3813
|
data: [],
|
|
3779
3814
|
rowCount: 0,
|
|
3780
3815
|
skipped: 0
|
|
3781
3816
|
};
|
|
3782
|
-
let n =
|
|
3817
|
+
let n = fr(t[0]), r = pr(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? mr(r) : {
|
|
3783
3818
|
time: 0,
|
|
3784
3819
|
open: 1,
|
|
3785
3820
|
high: 2,
|
|
@@ -3790,7 +3825,7 @@ function or(e) {
|
|
|
3790
3825
|
if (a.time < 0 || a.open < 0 || a.high < 0 || a.low < 0 || a.close < 0) throw Error("CSV is missing required column(s): time, open, high, low, close");
|
|
3791
3826
|
let o = [], s = 0;
|
|
3792
3827
|
for (let e = +!!i; e < t.length; e++) {
|
|
3793
|
-
let r =
|
|
3828
|
+
let r = pr(t[e], n), i = J(r[a.time]), c = q(r[a.open]), l = q(r[a.high]), u = q(r[a.low]), d = q(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
|
|
3794
3829
|
if (i === null || ![
|
|
3795
3830
|
c,
|
|
3796
3831
|
l,
|
|
@@ -3809,9 +3844,9 @@ function or(e) {
|
|
|
3809
3844
|
volume: Number.isFinite(f) ? f : 0
|
|
3810
3845
|
});
|
|
3811
3846
|
}
|
|
3812
|
-
return
|
|
3847
|
+
return _r(o, t.length - +!!i, s);
|
|
3813
3848
|
}
|
|
3814
|
-
function
|
|
3849
|
+
function fr(e) {
|
|
3815
3850
|
let t = {
|
|
3816
3851
|
",": 0,
|
|
3817
3852
|
";": 0,
|
|
@@ -3823,7 +3858,7 @@ function sr(e) {
|
|
|
3823
3858
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
3824
3859
|
return n;
|
|
3825
3860
|
}
|
|
3826
|
-
function
|
|
3861
|
+
function pr(e, t) {
|
|
3827
3862
|
let n = [], r = "", i = !1;
|
|
3828
3863
|
for (let a = 0; a < e.length; a++) {
|
|
3829
3864
|
let o = e[a];
|
|
@@ -3831,25 +3866,25 @@ function cr(e, t) {
|
|
|
3831
3866
|
}
|
|
3832
3867
|
return n.push(r), n;
|
|
3833
3868
|
}
|
|
3834
|
-
function
|
|
3869
|
+
function mr(e) {
|
|
3835
3870
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
3836
3871
|
return {
|
|
3837
|
-
time: t(
|
|
3838
|
-
open: t(
|
|
3839
|
-
high: t(
|
|
3840
|
-
low: t(
|
|
3841
|
-
close: t(
|
|
3842
|
-
volume: t(
|
|
3872
|
+
time: t(rr),
|
|
3873
|
+
open: t(ir),
|
|
3874
|
+
high: t(ar),
|
|
3875
|
+
low: t(or),
|
|
3876
|
+
close: t(sr),
|
|
3877
|
+
volume: t(cr)
|
|
3843
3878
|
};
|
|
3844
3879
|
}
|
|
3845
|
-
function
|
|
3880
|
+
function hr(e) {
|
|
3846
3881
|
let t = (t) => {
|
|
3847
3882
|
for (let n of t) {
|
|
3848
3883
|
if (e[n] !== void 0) return e[n];
|
|
3849
3884
|
let t = n.toUpperCase();
|
|
3850
3885
|
if (e[t] !== void 0) return e[t];
|
|
3851
3886
|
}
|
|
3852
|
-
}, n =
|
|
3887
|
+
}, n = J(String(t(rr) ?? "")), r = Number(t(ir)), i = Number(t(ar)), a = Number(t(or)), o = Number(t(sr)), s = Number(t(cr) ?? 0);
|
|
3853
3888
|
return n === null || ![
|
|
3854
3889
|
r,
|
|
3855
3890
|
i,
|
|
@@ -3864,9 +3899,9 @@ function ur(e) {
|
|
|
3864
3899
|
volume: Number.isFinite(s) ? s : 0
|
|
3865
3900
|
};
|
|
3866
3901
|
}
|
|
3867
|
-
function
|
|
3902
|
+
function gr(e) {
|
|
3868
3903
|
if (e.length < 5) return null;
|
|
3869
|
-
let t =
|
|
3904
|
+
let t = J(String(e[0])), n = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = Number(e[4]), o = e.length >= 6 ? Number(e[5]) : 0;
|
|
3870
3905
|
return t === null || ![
|
|
3871
3906
|
n,
|
|
3872
3907
|
r,
|
|
@@ -3881,18 +3916,18 @@ function dr(e) {
|
|
|
3881
3916
|
volume: Number.isFinite(o) ? o : 0
|
|
3882
3917
|
};
|
|
3883
3918
|
}
|
|
3884
|
-
function
|
|
3919
|
+
function q(e) {
|
|
3885
3920
|
return e === void 0 || e.trim() === "" ? NaN : Number(e);
|
|
3886
3921
|
}
|
|
3887
|
-
function
|
|
3922
|
+
function J(e) {
|
|
3888
3923
|
let t = e.trim();
|
|
3889
3924
|
if (!t) return null;
|
|
3890
3925
|
let n = Number(t);
|
|
3891
|
-
if (Number.isFinite(n) && n > 0) return n
|
|
3926
|
+
if (Number.isFinite(n) && n > 0) return g(n);
|
|
3892
3927
|
let r = Date.parse(t);
|
|
3893
3928
|
return Number.isFinite(r) ? r : null;
|
|
3894
3929
|
}
|
|
3895
|
-
function
|
|
3930
|
+
function _r(e, t, n) {
|
|
3896
3931
|
e.sort((e, t) => e.time - t.time);
|
|
3897
3932
|
let r = [];
|
|
3898
3933
|
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
@@ -3904,7 +3939,7 @@ function fr(e, t, n) {
|
|
|
3904
3939
|
}
|
|
3905
3940
|
//#endregion
|
|
3906
3941
|
//#region src/io/DragDropImporter.ts
|
|
3907
|
-
var
|
|
3942
|
+
var vr = class {
|
|
3908
3943
|
host;
|
|
3909
3944
|
overlay = null;
|
|
3910
3945
|
callbacks;
|
|
@@ -3925,19 +3960,19 @@ var pr = class {
|
|
|
3925
3960
|
this.host.removeEventListener("dragenter", this.bound.dragenter), this.host.removeEventListener("dragover", this.bound.dragover), this.host.removeEventListener("dragleave", this.bound.dragleave), this.host.removeEventListener("drop", this.bound.drop), this.hideOverlay();
|
|
3926
3961
|
}
|
|
3927
3962
|
onDragEnter(e) {
|
|
3928
|
-
|
|
3963
|
+
Y(e) && (e.preventDefault(), this.depth++, this.showOverlay());
|
|
3929
3964
|
}
|
|
3930
3965
|
onDragOver(e) {
|
|
3931
|
-
|
|
3966
|
+
Y(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
|
|
3932
3967
|
}
|
|
3933
3968
|
onDragLeave(e) {
|
|
3934
|
-
|
|
3969
|
+
Y(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
|
|
3935
3970
|
}
|
|
3936
3971
|
async onDrop(e) {
|
|
3937
3972
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
3938
3973
|
let t = e.dataTransfer?.files?.[0];
|
|
3939
3974
|
if (t) try {
|
|
3940
|
-
let e =
|
|
3975
|
+
let e = lr(await t.text());
|
|
3941
3976
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
3942
3977
|
this.callbacks.onData(e.data, e, t);
|
|
3943
3978
|
} catch (e) {
|
|
@@ -3968,12 +4003,12 @@ var pr = class {
|
|
|
3968
4003
|
this.overlay?.remove(), this.overlay = null;
|
|
3969
4004
|
}
|
|
3970
4005
|
};
|
|
3971
|
-
function
|
|
4006
|
+
function Y(e) {
|
|
3972
4007
|
return e.dataTransfer?.types?.includes("Files") ?? !1;
|
|
3973
4008
|
}
|
|
3974
4009
|
//#endregion
|
|
3975
4010
|
//#region src/state/layoutStorage.ts
|
|
3976
|
-
function
|
|
4011
|
+
function X(e) {
|
|
3977
4012
|
let t = {
|
|
3978
4013
|
id: e.id,
|
|
3979
4014
|
name: e.name,
|
|
@@ -3981,11 +4016,11 @@ function Z(e) {
|
|
|
3981
4016
|
};
|
|
3982
4017
|
return e.symbol !== void 0 && (t.symbol = e.symbol), e.timeframe !== void 0 && (t.timeframe = e.timeframe), e.kind !== void 0 && (t.kind = e.kind), t;
|
|
3983
4018
|
}
|
|
3984
|
-
var
|
|
4019
|
+
var Z = (e, t) => t.updatedAt - e.updatedAt;
|
|
3985
4020
|
function Q(e) {
|
|
3986
4021
|
if (typeof e != "object" || !e) return null;
|
|
3987
4022
|
let t = e;
|
|
3988
|
-
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null :
|
|
4023
|
+
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : X({
|
|
3989
4024
|
id: t.id,
|
|
3990
4025
|
name: t.name,
|
|
3991
4026
|
updatedAt: t.updatedAt,
|
|
@@ -3994,17 +4029,17 @@ function Q(e) {
|
|
|
3994
4029
|
kind: typeof t.kind == "string" ? t.kind : void 0
|
|
3995
4030
|
});
|
|
3996
4031
|
}
|
|
3997
|
-
function
|
|
4032
|
+
function yr(e) {
|
|
3998
4033
|
let t = Q(e), n = t ? e.content : void 0;
|
|
3999
4034
|
return t && typeof n == "string" ? {
|
|
4000
4035
|
...t,
|
|
4001
4036
|
content: n
|
|
4002
4037
|
} : null;
|
|
4003
4038
|
}
|
|
4004
|
-
function
|
|
4039
|
+
function br(e = []) {
|
|
4005
4040
|
let t = new Map(e.map((e) => [e.id, { ...e }]));
|
|
4006
4041
|
return {
|
|
4007
|
-
list: () => [...t.values()].map(
|
|
4042
|
+
list: () => [...t.values()].map(X).sort(Z),
|
|
4008
4043
|
load: (e) => {
|
|
4009
4044
|
let n = t.get(e);
|
|
4010
4045
|
return n ? { ...n } : null;
|
|
@@ -4017,7 +4052,7 @@ function gr(e = []) {
|
|
|
4017
4052
|
}
|
|
4018
4053
|
};
|
|
4019
4054
|
}
|
|
4020
|
-
function
|
|
4055
|
+
function xr(e = "tcw:layouts:") {
|
|
4021
4056
|
let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
|
|
4022
4057
|
let e;
|
|
4023
4058
|
try {
|
|
@@ -4028,7 +4063,7 @@ function _r(e = "tcw:layouts:") {
|
|
|
4028
4063
|
return Array.isArray(e) ? e.map(Q).filter((e) => e !== null) : [];
|
|
4029
4064
|
}, i = (e) => localStorage.setItem(t, JSON.stringify(e));
|
|
4030
4065
|
return {
|
|
4031
|
-
list: () => r().sort(
|
|
4066
|
+
list: () => r().sort(Z),
|
|
4032
4067
|
load: (e) => {
|
|
4033
4068
|
let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
|
|
4034
4069
|
return t && i !== null ? {
|
|
@@ -4037,7 +4072,7 @@ function _r(e = "tcw:layouts:") {
|
|
|
4037
4072
|
} : null;
|
|
4038
4073
|
},
|
|
4039
4074
|
save: (e) => {
|
|
4040
|
-
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id),
|
|
4075
|
+
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), X(e)]);
|
|
4041
4076
|
},
|
|
4042
4077
|
remove: (e) => {
|
|
4043
4078
|
i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
|
|
@@ -4046,14 +4081,14 @@ function _r(e = "tcw:layouts:") {
|
|
|
4046
4081
|
}
|
|
4047
4082
|
//#endregion
|
|
4048
4083
|
//#region src/state/LayoutSession.ts
|
|
4049
|
-
var
|
|
4084
|
+
var Sr = 80;
|
|
4050
4085
|
function $(e) {
|
|
4051
4086
|
return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
|
|
4052
4087
|
}
|
|
4053
|
-
function
|
|
4088
|
+
function Cr() {
|
|
4054
4089
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
4055
4090
|
}
|
|
4056
|
-
function
|
|
4091
|
+
function wr(e) {
|
|
4057
4092
|
let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
|
|
4058
4093
|
return {
|
|
4059
4094
|
id: t,
|
|
@@ -4064,7 +4099,7 @@ function br(e) {
|
|
|
4064
4099
|
...o === void 0 ? {} : { kind: o }
|
|
4065
4100
|
};
|
|
4066
4101
|
}
|
|
4067
|
-
var
|
|
4102
|
+
var Tr = class {
|
|
4068
4103
|
currentLayout = null;
|
|
4069
4104
|
savedContent = null;
|
|
4070
4105
|
dirty = !1;
|
|
@@ -4080,7 +4115,7 @@ var xr = class {
|
|
|
4080
4115
|
now;
|
|
4081
4116
|
newId;
|
|
4082
4117
|
constructor(e, t, n = {}) {
|
|
4083
|
-
this.storage = e, this.host = t, this.options = n, this.autoSave = n.autoSave ?? !0, this.debounceMs = n.debounceMs ?? 1500, this.kind = n.kind ?? "chart", this.now = n.now ?? Date.now, this.newId = n.newId ??
|
|
4118
|
+
this.storage = e, this.host = t, this.options = n, this.autoSave = n.autoSave ?? !0, this.debounceMs = n.debounceMs ?? 1500, this.kind = n.kind ?? "chart", this.now = n.now ?? Date.now, this.newId = n.newId ?? Cr;
|
|
4084
4119
|
}
|
|
4085
4120
|
current() {
|
|
4086
4121
|
return this.currentLayout;
|
|
@@ -4110,7 +4145,7 @@ var xr = class {
|
|
|
4110
4145
|
}
|
|
4111
4146
|
open(e) {
|
|
4112
4147
|
return this.queue(async () => {
|
|
4113
|
-
let t =
|
|
4148
|
+
let t = yr(await this.storage.load(e));
|
|
4114
4149
|
if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
|
|
4115
4150
|
this.cancelTimer(), this.applying++;
|
|
4116
4151
|
try {
|
|
@@ -4120,13 +4155,13 @@ var xr = class {
|
|
|
4120
4155
|
} finally {
|
|
4121
4156
|
this.applying--;
|
|
4122
4157
|
}
|
|
4123
|
-
return this.cancelTimer(), this.currentLayout =
|
|
4158
|
+
return this.cancelTimer(), this.currentLayout = wr(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
|
|
4124
4159
|
});
|
|
4125
4160
|
}
|
|
4126
4161
|
rename(e, t) {
|
|
4127
4162
|
let n = $(t);
|
|
4128
4163
|
return n ? this.queue(async () => {
|
|
4129
|
-
let t =
|
|
4164
|
+
let t = yr(await this.storage.load(e));
|
|
4130
4165
|
!t || t.id !== e || (await this.storage.save({
|
|
4131
4166
|
...t,
|
|
4132
4167
|
name: n
|
|
@@ -4204,7 +4239,7 @@ var xr = class {
|
|
|
4204
4239
|
content: n.content
|
|
4205
4240
|
};
|
|
4206
4241
|
await this.storage.save(r);
|
|
4207
|
-
let i =
|
|
4242
|
+
let i = wr(r);
|
|
4208
4243
|
return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
|
|
4209
4244
|
}
|
|
4210
4245
|
forget() {
|
|
@@ -4225,6 +4260,6 @@ var xr = class {
|
|
|
4225
4260
|
}
|
|
4226
4261
|
};
|
|
4227
4262
|
//#endregion
|
|
4228
|
-
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 };
|
|
4229
4264
|
|
|
4230
|
-
//# sourceMappingURL=LayoutSession-
|
|
4265
|
+
//# sourceMappingURL=LayoutSession-BD1CfXIS.js.map
|