@tradecanvas/chart 0.9.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Chart.d.ts +110 -1
- package/dist/Chart.d.ts.map +1 -1
- package/dist/{DragDropImporter-6QOjnfSj.js → DragDropImporter-Br2ez5Gz.js} +296 -103
- package/dist/DragDropImporter-Br2ez5Gz.js.map +1 -0
- package/dist/DragDropImporter-ycI_Tcs6.cjs +2 -0
- package/dist/DragDropImporter-ycI_Tcs6.cjs.map +1 -0
- package/dist/finance/PerformanceDashboard.d.ts +43 -0
- package/dist/finance/PerformanceDashboard.d.ts.map +1 -0
- package/dist/finance/index.d.ts +4 -0
- package/dist/finance/index.d.ts.map +1 -1
- package/dist/finance/performanceData.d.ts +39 -0
- package/dist/finance/performanceData.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +287 -30
- package/dist/index.js.map +1 -1
- package/dist/io/index.d.ts +2 -0
- package/dist/io/index.d.ts.map +1 -1
- package/dist/io/resampleOHLCV.d.ts +29 -0
- package/dist/io/resampleOHLCV.d.ts.map +1 -0
- package/dist/widget/AlertNotifier.d.ts +32 -0
- package/dist/widget/AlertNotifier.d.ts.map +1 -0
- package/dist/widget/ChartWidget.d.ts +54 -1
- package/dist/widget/ChartWidget.d.ts.map +1 -1
- package/dist/widget/DrawingFavoritesStore.d.ts +22 -0
- package/dist/widget/DrawingFavoritesStore.d.ts.map +1 -0
- package/dist/widget/DrawingTemplateStore.d.ts +29 -0
- package/dist/widget/DrawingTemplateStore.d.ts.map +1 -0
- package/dist/widget/WidgetAlertsPanel.d.ts +58 -0
- package/dist/widget/WidgetAlertsPanel.d.ts.map +1 -0
- package/dist/widget/WidgetBracketBar.d.ts +21 -0
- package/dist/widget/WidgetBracketBar.d.ts.map +1 -0
- package/dist/widget/WidgetDataWindow.d.ts +41 -0
- package/dist/widget/WidgetDataWindow.d.ts.map +1 -0
- package/dist/widget/WidgetDepthLadder.d.ts +29 -0
- package/dist/widget/WidgetDepthLadder.d.ts.map +1 -0
- package/dist/widget/WidgetDrawingSidebar.d.ts +6 -0
- package/dist/widget/WidgetDrawingSidebar.d.ts.map +1 -1
- package/dist/widget/WidgetDrawingStyle.d.ts +36 -0
- package/dist/widget/WidgetDrawingStyle.d.ts.map +1 -0
- package/dist/widget/WidgetHotkeySheet.d.ts.map +1 -1
- package/dist/widget/WidgetIndicatorSettings.d.ts +42 -0
- package/dist/widget/WidgetIndicatorSettings.d.ts.map +1 -0
- package/dist/widget/WidgetObjectTree.d.ts +59 -0
- package/dist/widget/WidgetObjectTree.d.ts.map +1 -0
- package/dist/widget/WidgetSettings.d.ts +1 -0
- package/dist/widget/WidgetSettings.d.ts.map +1 -1
- package/dist/widget/WidgetSymbolSearch.d.ts +3 -1
- package/dist/widget/WidgetSymbolSearch.d.ts.map +1 -1
- package/dist/widget/WidgetToolbar.d.ts.map +1 -1
- package/dist/widget/icons.d.ts.map +1 -1
- package/dist/widget/index.cjs +932 -15
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +1824 -157
- package/dist/widget/index.js.map +1 -1
- package/dist/widget/ladderRows.d.ts +21 -0
- package/dist/widget/ladderRows.d.ts.map +1 -0
- package/dist/widget/types.d.ts +72 -1
- package/dist/widget/types.d.ts.map +1 -1
- package/dist/widget/widgetConfig.d.ts.map +1 -1
- package/dist/widget/widgetShareState.d.ts +26 -0
- package/dist/widget/widgetShareState.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/DragDropImporter-6QOjnfSj.js.map +0 -1
- package/dist/DragDropImporter-CQ3EarQn.cjs +0 -2
- package/dist/DragDropImporter-CQ3EarQn.cjs.map +0 -1
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, computePriceLimits as s, mergeBar as c, setLocale as l, timeframeToMs as u } from "@tradecanvas/commons";
|
|
2
|
-
import {
|
|
2
|
+
import { AlertDragHandler as d, AlertManager as f, Animator as p, AreaRenderer as m, AxisDragHandler as ee, BarCountdown as te, BarRenderer as h, BaselineRenderer as ne, CandlestickRenderer as g, ChartLegend as re, ChartStateManager as _, CompareRenderer as ie, CrosshairHandler as ae, CrosshairTooltip as oe, CurrentPriceLine as se, DataExporter as v, DepthHeatmapRenderer as ce, DrawingManager as le, DrawingRenderer as ue, EquivolumeRenderer as de, EventBus as fe, GridRenderer as pe, HLCAreaRenderer as me, HollowCandleRenderer as he, IndicatorEngine as y, InteractionManager as ge, KagiRenderer as _e, KeyboardHandler as ve, LineRenderer as ye, LineWithMarkersRenderer as be, MarketProfileRenderer as xe, MeasureOverlay as Se, PanHandler as Ce, PeriodLevelsRenderer as we, PinnedTooltip as Te, PivotMarkersRenderer as b, PointAndFigureRenderer as x, PriceAxis as S, RenderEngine as C, RenkoRenderer as w, ReplayManager as T, Screenshot as E, SessionBreaks as D, SessionShading as O, SignalMarkerManager as Ee, StepLineRenderer as De, StreamManager as Oe, TimeAxis as ke, TradeZoneManager as Ae, TradingManager as je, TradingRenderer as Me, UndoRedoManager as Ne, Viewport as Pe, VolumeCandleRenderer as Fe, VolumeProfileRenderer as Ie, VolumeRenderer as Le, Watermark as Re, ZoomHandler as ze, findDominantSwing as Be, registerBuiltInDrawingTools as Ve, registerBuiltInIndicators as k, toHeikinAshi as A, toKagi as He, toLineBreak as Ue, toPointAndFigure as We, toRangeBars as Ge, toRenko as Ke, xToBarIndex as qe } from "@tradecanvas/core";
|
|
3
3
|
//#region src/charts/ChartTypeStrategy.ts
|
|
4
|
-
function
|
|
4
|
+
function Je(e) {
|
|
5
5
|
switch (e) {
|
|
6
6
|
case "candlestick":
|
|
7
7
|
case "heikinAshi":
|
|
8
8
|
case "lineBreak":
|
|
9
|
-
case "rangeBars": return new
|
|
10
|
-
case "line": return new
|
|
11
|
-
case "area": return new
|
|
12
|
-
case "bar": return new
|
|
13
|
-
case "hollowCandle": return new
|
|
9
|
+
case "rangeBars": return new g();
|
|
10
|
+
case "line": return new ye();
|
|
11
|
+
case "area": return new m();
|
|
12
|
+
case "bar": return new h();
|
|
13
|
+
case "hollowCandle": return new he();
|
|
14
14
|
case "baseline": return new ne();
|
|
15
|
-
case "renko": return new
|
|
16
|
-
case "kagi": return new
|
|
17
|
-
case "pointAndFigure": return new
|
|
18
|
-
case "volumeCandles": return new
|
|
19
|
-
case "equivolume": return new
|
|
20
|
-
case "hlcArea": return new
|
|
21
|
-
case "stepLine": return new
|
|
22
|
-
case "lineWithMarkers": return new
|
|
23
|
-
default: return new
|
|
15
|
+
case "renko": return new w();
|
|
16
|
+
case "kagi": return new _e();
|
|
17
|
+
case "pointAndFigure": return new x();
|
|
18
|
+
case "volumeCandles": return new Fe();
|
|
19
|
+
case "equivolume": return new de();
|
|
20
|
+
case "hlcArea": return new me();
|
|
21
|
+
case "stepLine": return new De();
|
|
22
|
+
case "lineWithMarkers": return new be();
|
|
23
|
+
default: return new g();
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function Ye(e, t) {
|
|
27
27
|
if (t.length === 0) return t;
|
|
28
28
|
switch (e) {
|
|
29
|
-
case "heikinAshi": return
|
|
30
|
-
case "renko": return
|
|
29
|
+
case "heikinAshi": return A(t);
|
|
30
|
+
case "renko": return Ke(t, {
|
|
31
31
|
brickSize: 0,
|
|
32
32
|
useATR: !0,
|
|
33
33
|
atrPeriod: 14
|
|
34
34
|
});
|
|
35
|
-
case "lineBreak": return
|
|
36
|
-
case "kagi": return
|
|
37
|
-
case "pointAndFigure": return
|
|
38
|
-
case "rangeBars": return
|
|
35
|
+
case "lineBreak": return Ue(t, 3);
|
|
36
|
+
case "kagi": return He(t, 4);
|
|
37
|
+
case "pointAndFigure": return We(t, j(t) * .01, 3);
|
|
38
|
+
case "rangeBars": return Ge(t, { rangeSize: j(t) * .005 });
|
|
39
39
|
default: return t;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function j(e) {
|
|
43
43
|
let t = 0;
|
|
44
44
|
for (let n of e) t += n.close;
|
|
45
45
|
return t / e.length;
|
|
46
46
|
}
|
|
47
47
|
//#endregion
|
|
48
48
|
//#region src/charts/IndicatorPriceRange.ts
|
|
49
|
-
var
|
|
49
|
+
var M = {
|
|
50
50
|
min: 0,
|
|
51
51
|
max: 100
|
|
52
|
-
},
|
|
53
|
-
function
|
|
54
|
-
if (!e) return { ...
|
|
52
|
+
}, N = .1;
|
|
53
|
+
function Xe(e, t, n) {
|
|
54
|
+
if (!e) return { ...M };
|
|
55
55
|
let r = Infinity, i = -Infinity, a = 0;
|
|
56
56
|
for (let [, o] of e.values) {
|
|
57
57
|
if (a >= t && a <= n) for (let e in o) {
|
|
@@ -60,16 +60,16 @@ function Ue(e, t, n) {
|
|
|
60
60
|
}
|
|
61
61
|
a++;
|
|
62
62
|
}
|
|
63
|
-
if (r === Infinity) return { ...
|
|
63
|
+
if (r === Infinity) return { ...M };
|
|
64
64
|
let o = i - r || 1;
|
|
65
65
|
return {
|
|
66
|
-
min: r - o *
|
|
67
|
-
max: i + o *
|
|
66
|
+
min: r - o * N,
|
|
67
|
+
max: i + o * N
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
//#endregion
|
|
71
71
|
//#region src/state/AutoSaveScheduler.ts
|
|
72
|
-
var
|
|
72
|
+
var Ze = class {
|
|
73
73
|
timer = null;
|
|
74
74
|
delayMs = 0;
|
|
75
75
|
key = null;
|
|
@@ -99,12 +99,12 @@ var We = class {
|
|
|
99
99
|
};
|
|
100
100
|
//#endregion
|
|
101
101
|
//#region src/DataManager.ts
|
|
102
|
-
function
|
|
102
|
+
function P(e) {
|
|
103
103
|
if (!e || typeof e.time != "number") return !1;
|
|
104
104
|
let { open: t, high: n, low: r, close: i } = e;
|
|
105
105
|
return !(!isFinite(t) || !isFinite(n) || !isFinite(r) || !isFinite(i) || t < 0 || n < 0 || r < 0 || i < 0 || n < r || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0));
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function F(e) {
|
|
108
108
|
return {
|
|
109
109
|
...e,
|
|
110
110
|
high: Math.max(e.open, e.high, e.low, e.close),
|
|
@@ -112,20 +112,20 @@ function P(e) {
|
|
|
112
112
|
volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
var
|
|
115
|
+
var I = class {
|
|
116
116
|
data = [];
|
|
117
117
|
getData() {
|
|
118
118
|
return this.data;
|
|
119
119
|
}
|
|
120
120
|
setData(e) {
|
|
121
|
-
this.data = e.filter(
|
|
121
|
+
this.data = e.filter(P).map(F);
|
|
122
122
|
}
|
|
123
123
|
appendBar(e) {
|
|
124
|
-
|
|
124
|
+
P(e) && this.data.push(F(e));
|
|
125
125
|
}
|
|
126
126
|
updateLastBar(e) {
|
|
127
|
-
if (!
|
|
128
|
-
let t =
|
|
127
|
+
if (!P(e)) return;
|
|
128
|
+
let t = F(e);
|
|
129
129
|
if (this.data.length === 0) {
|
|
130
130
|
this.data.push(t);
|
|
131
131
|
return;
|
|
@@ -141,7 +141,7 @@ var F = class {
|
|
|
141
141
|
clear() {
|
|
142
142
|
this.data = [];
|
|
143
143
|
}
|
|
144
|
-
},
|
|
144
|
+
}, L = class {
|
|
145
145
|
theme;
|
|
146
146
|
constructor(t) {
|
|
147
147
|
!t || t === "dark" ? this.theme = { ...e } : t === "light" ? this.theme = { ...n } : this.theme = { ...t };
|
|
@@ -152,7 +152,7 @@ var F = class {
|
|
|
152
152
|
setTheme(t) {
|
|
153
153
|
t === "dark" ? this.theme = { ...e } : t === "light" ? this.theme = { ...n } : this.theme = { ...t };
|
|
154
154
|
}
|
|
155
|
-
},
|
|
155
|
+
}, R = 200, z = 80, B = class {
|
|
156
156
|
panels = [];
|
|
157
157
|
containerWidth = 0;
|
|
158
158
|
containerHeight = 0;
|
|
@@ -164,8 +164,8 @@ var F = class {
|
|
|
164
164
|
this.panels.push({
|
|
165
165
|
id: e,
|
|
166
166
|
position: n,
|
|
167
|
-
size: r ?? (a ?
|
|
168
|
-
minSize: a ?
|
|
167
|
+
size: r ?? (a ? R : t),
|
|
168
|
+
minSize: a ? z : i,
|
|
169
169
|
content: {
|
|
170
170
|
type: "indicator",
|
|
171
171
|
indicatorInstanceId: e
|
|
@@ -179,7 +179,7 @@ var F = class {
|
|
|
179
179
|
let r = this.panels.find((t) => t.id === e);
|
|
180
180
|
if (r) {
|
|
181
181
|
let e = r.position === "left" || r.position === "right", a = n === "left" || n === "right";
|
|
182
|
-
r.position = n, e !== a && (r.size = a ?
|
|
182
|
+
r.position = n, e !== a && (r.size = a ? R : t, r.minSize = a ? z : i);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
setPanelSize(e, t) {
|
|
@@ -280,14 +280,14 @@ var F = class {
|
|
|
280
280
|
getMainChartRect() {
|
|
281
281
|
return this.resolve().mainChartRect;
|
|
282
282
|
}
|
|
283
|
-
},
|
|
283
|
+
}, V = class {
|
|
284
284
|
constructor(e) {
|
|
285
285
|
this.indicatorEngine = e;
|
|
286
286
|
}
|
|
287
287
|
registerIndicator(e) {
|
|
288
288
|
this.indicatorEngine.register(e);
|
|
289
289
|
}
|
|
290
|
-
},
|
|
290
|
+
}, Qe = class {
|
|
291
291
|
static version = "0.7.0";
|
|
292
292
|
engine;
|
|
293
293
|
viewport;
|
|
@@ -313,17 +313,22 @@ var F = class {
|
|
|
313
313
|
watermark;
|
|
314
314
|
barCountdown;
|
|
315
315
|
sessionBreaks;
|
|
316
|
+
sessionShading;
|
|
316
317
|
compareRenderer;
|
|
317
318
|
countdownInterval = null;
|
|
318
319
|
volumeRenderer;
|
|
319
320
|
volumeProfile;
|
|
321
|
+
marketProfile;
|
|
322
|
+
depthHeatmap;
|
|
323
|
+
periodLevels;
|
|
324
|
+
pivotMarkers;
|
|
320
325
|
alertManager;
|
|
321
326
|
signalMarkerManager;
|
|
322
327
|
tradeZoneManager;
|
|
323
328
|
measureOverlay;
|
|
324
329
|
replayManager;
|
|
325
330
|
undoRedoManager;
|
|
326
|
-
autoSaveScheduler = new
|
|
331
|
+
autoSaveScheduler = new Ze((e) => this.saveState(e));
|
|
327
332
|
animator;
|
|
328
333
|
crosshairTooltip;
|
|
329
334
|
pinnedTooltip;
|
|
@@ -375,22 +380,22 @@ var F = class {
|
|
|
375
380
|
logScale: n.logScale ?? !0,
|
|
376
381
|
timeframes: n.timeframes ?? [],
|
|
377
382
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
378
|
-
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", this.dataManager = new
|
|
383
|
+
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", this.dataManager = new I(), this.themeManager = new L(t.theme), this.layoutManager = new B(), this.indicatorEngine = new y(), this.pluginManager = new V(this.indicatorEngine), this.eventBus = new fe(), k(this.indicatorEngine), this.drawingManager = new le(), Ve(this.drawingManager), this.drawingRenderer = new ue(this.drawingManager), this.drawingManager.setRequestRender(() => {
|
|
379
384
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
380
385
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
381
386
|
this.eventBus.emit(e, t);
|
|
382
|
-
}), this.undoRedoManager = new
|
|
387
|
+
}), this.undoRedoManager = new Ne(), this.drawingManager.setUndoRedoManager(this.undoRedoManager), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new je({
|
|
383
388
|
enabled: this.features.trading,
|
|
384
389
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
385
|
-
}), this.tradingRenderer = new
|
|
390
|
+
}), this.tradingRenderer = new Me(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
386
391
|
this.eventBus.emit(e, t);
|
|
387
|
-
}), this.engine = new
|
|
392
|
+
}), this.engine = new C(e);
|
|
388
393
|
let i = this.engine.dprManager.getContainerSize();
|
|
389
|
-
if (this.viewport = new
|
|
394
|
+
if (this.viewport = new Pe(i.width, i.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.layoutManager.resize(i.width, i.height), this.engine.onContainerResize = (e) => {
|
|
390
395
|
if (e.width <= 0 || e.height <= 0) return;
|
|
391
396
|
let t = this.viewport.isAtEnd();
|
|
392
397
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
|
|
393
|
-
}, this.chartRenderer = this.createChartRenderer(t.chartType), this.gridRenderer = new
|
|
398
|
+
}, this.chartRenderer = this.createChartRenderer(t.chartType), this.gridRenderer = new pe(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new S(), this.priceAxis.setLocale(this.numberLocale), this.timeAxis = new ke(), this.crosshairHandler = new ae(), this.crosshairHandler.setLocale(this.numberLocale), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
|
|
394
399
|
if (e !== null && t) {
|
|
395
400
|
let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
|
|
396
401
|
this.chartLegend.setHoverBar(r ?? null), r && this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize()), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
|
|
@@ -399,12 +404,12 @@ var F = class {
|
|
|
399
404
|
barIndex: e
|
|
400
405
|
});
|
|
401
406
|
} else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null);
|
|
402
|
-
}), this.chartLegend = new
|
|
407
|
+
}), this.chartLegend = new re(), this.chartLegend.setChartType(t.chartType), this.watermark = new Re(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Le(), this.volumeProfile = new Ie(), this.marketProfile = new xe(), this.depthHeatmap = new ce(), this.periodLevels = new we(), this.pivotMarkers = new b(), this.barCountdown = new te(), this.sessionBreaks = new D(), this.sessionShading = new O(), this.compareRenderer = new ie(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
403
408
|
visible: t.sessionBreaks.visible ?? !0,
|
|
404
409
|
color: t.sessionBreaks.color,
|
|
405
410
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
406
411
|
lineWidth: t.sessionBreaks.lineWidth
|
|
407
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.viewport.setLogScale(!0), this.animator = new
|
|
412
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.viewport.setLogScale(!0), this.animator = new p(), this.crosshairTooltip = new oe(), this.crosshairTooltip.create(e), this.pinnedTooltip = new Te(), this.pinnedTooltip.create(e), this.keyboardHandler = new ve({
|
|
408
413
|
scrollBars: (e) => {
|
|
409
414
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
410
415
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -424,14 +429,39 @@ var F = class {
|
|
|
424
429
|
if (!this.keyboardHandler) return;
|
|
425
430
|
let t = document.activeElement;
|
|
426
431
|
t && t !== this.container && !this.container.contains(t) || t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable) || this.keyboardHandler.handleKey(e) && e.preventDefault();
|
|
427
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new
|
|
428
|
-
|
|
432
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new se(), this.alertManager = new f(), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
|
|
433
|
+
let t = {
|
|
434
|
+
id: e.id,
|
|
435
|
+
price: e.price,
|
|
436
|
+
condition: e.condition,
|
|
437
|
+
message: e.message,
|
|
438
|
+
triggered: e.triggered
|
|
439
|
+
};
|
|
440
|
+
this.eventBus.emit("alertTriggered", t), this.eventBus.emit("dataUpdate", {
|
|
429
441
|
alert: "triggered",
|
|
430
442
|
alertId: e.id,
|
|
431
443
|
price: e.price,
|
|
432
444
|
message: e.message
|
|
433
445
|
});
|
|
434
|
-
}), this.
|
|
446
|
+
}), this.alertManager.on("added", (e) => {
|
|
447
|
+
this.eventBus.emit("alertAdd", {
|
|
448
|
+
id: e.id,
|
|
449
|
+
price: e.price,
|
|
450
|
+
condition: e.condition,
|
|
451
|
+
message: e.message,
|
|
452
|
+
triggered: e.triggered
|
|
453
|
+
});
|
|
454
|
+
}), this.alertManager.on("removed", (e) => {
|
|
455
|
+
this.eventBus.emit("alertRemove", { id: e });
|
|
456
|
+
}), this.alertManager.on("updated", (e) => {
|
|
457
|
+
this.eventBus.emit("alertUpdate", {
|
|
458
|
+
id: e.id,
|
|
459
|
+
price: e.price,
|
|
460
|
+
condition: e.condition,
|
|
461
|
+
message: e.message,
|
|
462
|
+
triggered: e.triggered
|
|
463
|
+
});
|
|
464
|
+
}), this.signalMarkerManager = new Ee(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
|
|
435
465
|
this.eventBus.emit("signalMarkerAdd", {
|
|
436
466
|
id: e.id,
|
|
437
467
|
source: e.source,
|
|
@@ -439,20 +469,20 @@ var F = class {
|
|
|
439
469
|
});
|
|
440
470
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
441
471
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
442
|
-
}), this.tradeZoneManager = new
|
|
472
|
+
}), this.tradeZoneManager = new Ae(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
|
|
443
473
|
this.eventBus.emit("tradeZoneAdd", {
|
|
444
474
|
id: e.id,
|
|
445
475
|
direction: e.direction
|
|
446
476
|
});
|
|
447
477
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
448
478
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
449
|
-
}), this.replayManager = new
|
|
479
|
+
}), this.replayManager = new T(), this.measureOverlay = new Se(), this.interactionManager = new ge(e), this.features.panning && this.interactionManager.setPanHandler(new Ce((e) => {
|
|
450
480
|
this.viewport.scrollBy(e), this.updateViewportAndRender();
|
|
451
481
|
})), this.features.zooming) {
|
|
452
|
-
this.interactionManager.setZoomHandler(new
|
|
482
|
+
this.interactionManager.setZoomHandler(new ze((e, t) => {
|
|
453
483
|
this.viewport.zoom(e, t), this.updateViewportAndRender();
|
|
454
484
|
}));
|
|
455
|
-
let e = new
|
|
485
|
+
let e = new ee((e) => {
|
|
456
486
|
this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender();
|
|
457
487
|
}, (e) => {
|
|
458
488
|
let t = this.viewport.getState().chartRect.width;
|
|
@@ -462,20 +492,40 @@ var F = class {
|
|
|
462
492
|
e === "price" ? (this.options.autoScale = !0, this.updateViewportAndRender()) : this.fitContent();
|
|
463
493
|
});
|
|
464
494
|
}
|
|
465
|
-
this.features.crosshair && this.interactionManager.setCrosshairHandler(this.crosshairHandler), this.features.drawings && this.interactionManager.setDrawingManager(this.drawingManager, () => ({
|
|
495
|
+
if (this.features.crosshair && this.interactionManager.setCrosshairHandler(this.crosshairHandler), this.features.drawings && this.interactionManager.setDrawingManager(this.drawingManager, () => ({
|
|
466
496
|
...this.viewport.getState(),
|
|
467
497
|
data: this.getDisplayData()
|
|
468
498
|
})), this.features.trading && this.interactionManager.setTradingManager(this.tradingManager, () => ({
|
|
469
499
|
...this.viewport.getState(),
|
|
470
500
|
data: this.getDisplayData()
|
|
471
|
-
})), this.
|
|
501
|
+
})), this.features.alerts) {
|
|
502
|
+
let e = new d(this.alertManager, () => this.viewport.getState());
|
|
503
|
+
this.interactionManager.setAlertDragHandler(e);
|
|
504
|
+
}
|
|
505
|
+
this.interactionManager.setAltClickHandler((e) => {
|
|
472
506
|
let t = this.getDisplayData();
|
|
473
507
|
if (t.length === 0) return;
|
|
474
508
|
let n = this.viewport.getState(), i = n.barWidth + n.barSpacing, a = Math.round((n.offset + e.x) / i);
|
|
475
509
|
a < 0 || a >= t.length || (this.pinnedTooltip.isPinned() && this.pinnedTooltip.getPinnedIndex() === a ? this.pinnedTooltip.unpin() : this.pinnedTooltip.pin(t[a], a, this.themeManager.getTheme()), this.pinnedTooltip.reposition(this.viewport.getState(), this.dataManager.getData()[a] ?? null, a, this.themeManager.getTheme()), this.engine.requestRender(r.Overlay));
|
|
510
|
+
}), this.interactionManager.setClickHandler((e) => {
|
|
511
|
+
let t = this.getDisplayData();
|
|
512
|
+
if (this.eventBus.emit("click", {
|
|
513
|
+
x: e.x,
|
|
514
|
+
y: e.y
|
|
515
|
+
}), t.length === 0) return;
|
|
516
|
+
let n = qe(e.x, this.viewport.getState());
|
|
517
|
+
n < 0 || n >= t.length || this.eventBus.emit("barClick", {
|
|
518
|
+
bar: t[n],
|
|
519
|
+
barIndex: n,
|
|
520
|
+
point: e
|
|
521
|
+
});
|
|
476
522
|
}), this.interactionManager.setEscapeHandler(() => {
|
|
523
|
+
if (this.features.trading && this.tradingManager.isBracketActive()) {
|
|
524
|
+
this.tradingManager.cancelBracket(), this.eventBus.emit("dataUpdate", { bracket: "cancelled" });
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
477
527
|
this.pinnedTooltip.isPinned() && (this.pinnedTooltip.unpin(), this.engine.requestRender(r.Overlay));
|
|
478
|
-
}), this.interactionManager.setMeasureHandlers({
|
|
528
|
+
}), this.interactionManager.setConfirmHandler(() => this.features.trading && this.tradingManager.isBracketActive() ? (this.tradingManager.confirmBracket(), !0) : !1), this.interactionManager.setMeasureHandlers({
|
|
479
529
|
begin: (e) => {
|
|
480
530
|
this.measureOverlay.begin(e, this.viewport.getState(), this.getDisplayData());
|
|
481
531
|
},
|
|
@@ -490,7 +540,7 @@ var F = class {
|
|
|
490
540
|
}), this.interactionManager.attach(), this.syncRenderContext(), this.engine.start();
|
|
491
541
|
}
|
|
492
542
|
setData(e) {
|
|
493
|
-
this.dataManager.setData(e), this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.indicatorEngine.recalculateAll(this.dataManager.getData()), e.length > 0 && this.currentPriceLine.setPrice(e[e.length - 1].close), this.updateViewportAndRender(!0), this.eventBus.emit("dataUpdate", { length: e.length });
|
|
543
|
+
this.dataManager.setData(e), this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.alertManager.clearLastValues(), this.indicatorEngine.recalculateAll(this.dataManager.getData()), e.length > 0 && this.currentPriceLine.setPrice(e[e.length - 1].close), this.updateViewportAndRender(!0), this.eventBus.emit("dataUpdate", { length: e.length });
|
|
494
544
|
}
|
|
495
545
|
appendBar(e) {
|
|
496
546
|
this.dataManager.appendBar(e), this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.autoScrollOnNewBar && this.viewport.scrollToEnd(), this.indicatorEngine.recalculateAll(this.dataManager.getData()), this.updateViewportAndRender();
|
|
@@ -550,15 +600,43 @@ var F = class {
|
|
|
550
600
|
setDrawingStyle(e) {
|
|
551
601
|
this.drawingManager.setStyle(e);
|
|
552
602
|
}
|
|
603
|
+
getDrawingStyle() {
|
|
604
|
+
return this.drawingManager.getActiveStyle();
|
|
605
|
+
}
|
|
606
|
+
getSelectedDrawingId() {
|
|
607
|
+
return this.drawingManager.getSelectedDrawingId();
|
|
608
|
+
}
|
|
609
|
+
setSelectedDrawingStyle(e, t) {
|
|
610
|
+
return this.drawingManager.setSelectedDrawingStyle(e, t);
|
|
611
|
+
}
|
|
553
612
|
getDrawings() {
|
|
554
613
|
return this.drawingManager.getDrawings();
|
|
555
614
|
}
|
|
556
615
|
setDrawings(e) {
|
|
557
616
|
this.drawingManager.setDrawings(e);
|
|
558
617
|
}
|
|
618
|
+
addDrawing(e) {
|
|
619
|
+
if (!this.features.drawings) return null;
|
|
620
|
+
let t = this.drawingManager.addDrawing(e);
|
|
621
|
+
return this.scheduleAutoSave(), t;
|
|
622
|
+
}
|
|
623
|
+
autoFib() {
|
|
624
|
+
if (!this.features.drawings) return null;
|
|
625
|
+
let e = this.getDisplayData(), t = this.viewport.getState(), n = Be(e, t.visibleRange.from, t.visibleRange.to);
|
|
626
|
+
return n ? this.addDrawing({
|
|
627
|
+
type: "fibRetracement",
|
|
628
|
+
anchors: [n[0], n[1]]
|
|
629
|
+
}) : null;
|
|
630
|
+
}
|
|
559
631
|
removeDrawing(e) {
|
|
560
632
|
this.drawingManager.removeDrawing(e);
|
|
561
633
|
}
|
|
634
|
+
setDrawingVisible(e, t) {
|
|
635
|
+
this.drawingManager.setDrawingVisible(e, t);
|
|
636
|
+
}
|
|
637
|
+
setDrawingLocked(e, t) {
|
|
638
|
+
this.drawingManager.setDrawingLocked(e, t);
|
|
639
|
+
}
|
|
562
640
|
clearDrawings() {
|
|
563
641
|
this.drawingManager.clearDrawings();
|
|
564
642
|
}
|
|
@@ -638,6 +716,9 @@ var F = class {
|
|
|
638
716
|
getActiveIndicators() {
|
|
639
717
|
return this.indicatorEngine.getActiveIndicators();
|
|
640
718
|
}
|
|
719
|
+
setIndicatorVisible(e, t) {
|
|
720
|
+
this.indicatorEngine.setVisible(e, t) !== null && this.updateViewportAndRender();
|
|
721
|
+
}
|
|
641
722
|
getIndicatorConfig(e) {
|
|
642
723
|
let t = this.indicatorEngine.getIndicatorConfig(e);
|
|
643
724
|
return t ? {
|
|
@@ -651,6 +732,23 @@ var F = class {
|
|
|
651
732
|
setOrders(e) {
|
|
652
733
|
this.features.trading && this.tradingManager.setOrders(e);
|
|
653
734
|
}
|
|
735
|
+
startBracket(e, t) {
|
|
736
|
+
if (!this.features.trading) return !1;
|
|
737
|
+
let n = this.dataManager.getData(), r = t ?? (n.length > 0 ? n[n.length - 1].close : null);
|
|
738
|
+
return r === null ? !1 : (this.tradingManager.startBracket(e, r), !0);
|
|
739
|
+
}
|
|
740
|
+
cancelBracket() {
|
|
741
|
+
this.features.trading && this.tradingManager.cancelBracket();
|
|
742
|
+
}
|
|
743
|
+
confirmBracket() {
|
|
744
|
+
return this.features.trading ? this.tradingManager.confirmBracket() : !1;
|
|
745
|
+
}
|
|
746
|
+
isBracketActive() {
|
|
747
|
+
return this.features.trading && this.tradingManager.isBracketActive();
|
|
748
|
+
}
|
|
749
|
+
placeOrderIntent(e) {
|
|
750
|
+
this.features.trading && this.eventBus.emit("orderPlace", e);
|
|
751
|
+
}
|
|
654
752
|
setPositions(e) {
|
|
655
753
|
this.features.trading && this.tradingManager.setPositions(e);
|
|
656
754
|
}
|
|
@@ -658,13 +756,26 @@ var F = class {
|
|
|
658
756
|
this.features.trading && this.tradingManager.setDepthData(e);
|
|
659
757
|
}
|
|
660
758
|
setCurrentPrice(e, t) {
|
|
661
|
-
this.tradingManager.setCurrentPrice(e), this.currentPriceLine.setPrice(e), this.scheduleRender(), this.features.alerts && this.alertManager.checkPrice(e);
|
|
759
|
+
this.tradingManager.setCurrentPrice(e), this.currentPriceLine.setPrice(e), this.scheduleRender(), this.features.alerts && (this.alertManager.checkPrice(e), this.feedIndicatorAlerts());
|
|
760
|
+
}
|
|
761
|
+
feedIndicatorAlerts() {
|
|
762
|
+
let e = this.alertManager.getAlerts(), t = this.dataManager.getData();
|
|
763
|
+
if (t.length === 0) return;
|
|
764
|
+
let n = t.length - 1, r = /* @__PURE__ */ new Set();
|
|
765
|
+
for (let t of e) {
|
|
766
|
+
if (t.channel === "price" || r.has(t.channel)) continue;
|
|
767
|
+
r.add(t.channel);
|
|
768
|
+
let e = t.channel.indexOf(":");
|
|
769
|
+
if (e < 0) continue;
|
|
770
|
+
let i = t.channel.slice(0, e), a = t.channel.slice(e + 1), o = this.indicatorEngine.getOutput(i)?.series?.[n]?.[a];
|
|
771
|
+
typeof o == "number" && Number.isFinite(o) && this.alertManager.checkChannel(t.channel, o);
|
|
772
|
+
}
|
|
662
773
|
}
|
|
663
774
|
setTradingConfig(e) {
|
|
664
775
|
this.features.trading && this.tradingManager.setConfig(e);
|
|
665
776
|
}
|
|
666
777
|
async connect(e) {
|
|
667
|
-
this.disconnectStream(), this.streamManager = new
|
|
778
|
+
this.disconnectStream(), this.streamManager = new Oe(), this.streamManager.on("snapshot", (e) => {
|
|
668
779
|
this.setData(e);
|
|
669
780
|
}), this.streamManager.on("barClose", (e) => {
|
|
670
781
|
this.dataManager.appendBar(e), this.crosshairHandler.setData(this.dataManager.getData()), this.autoScrollOnNewBar && this.viewport.scrollToEnd(), this.indicatorEngine.recalculateAll(this.dataManager.getData()), this.updateViewportAndRender();
|
|
@@ -725,6 +836,12 @@ var F = class {
|
|
|
725
836
|
isLogScale() {
|
|
726
837
|
return this.viewport.isLogScale();
|
|
727
838
|
}
|
|
839
|
+
setScaleMode(e) {
|
|
840
|
+
this.viewport.setScaleMode(e), this.updateViewportAndRender();
|
|
841
|
+
}
|
|
842
|
+
getScaleMode() {
|
|
843
|
+
return this.viewport.getScaleMode();
|
|
844
|
+
}
|
|
728
845
|
setSessionBreaksConfig(e) {
|
|
729
846
|
this.sessionBreaks.setConfig(e), this.engine.requestRender(r.Background);
|
|
730
847
|
}
|
|
@@ -840,6 +957,64 @@ var F = class {
|
|
|
840
957
|
setVolumeProfileConfig(e) {
|
|
841
958
|
e.buckets !== void 0 && this.volumeProfile.setBuckets(e.buckets), e.widthRatio !== void 0 && this.volumeProfile.setWidthRatio(e.widthRatio), e.opacity !== void 0 && this.volumeProfile.setOpacity(e.opacity), e.highlightPoC !== void 0 && this.volumeProfile.setHighlightPoC(e.highlightPoC), this.engine.requestRender(r.Main);
|
|
842
959
|
}
|
|
960
|
+
setMarketProfileVisible(e) {
|
|
961
|
+
this.marketProfile.setVisible(e), this.engine.requestRender(r.Main);
|
|
962
|
+
}
|
|
963
|
+
isMarketProfileVisible() {
|
|
964
|
+
return this.marketProfile.isVisible();
|
|
965
|
+
}
|
|
966
|
+
setMarketProfileConfig(e) {
|
|
967
|
+
e.buckets !== void 0 && this.marketProfile.setBuckets(e.buckets), e.widthRatio !== void 0 && this.marketProfile.setWidthRatio(e.widthRatio), e.opacity !== void 0 && this.marketProfile.setOpacity(e.opacity), e.valueAreaPct !== void 0 && this.marketProfile.setValueAreaPct(e.valueAreaPct), e.highlightPoC !== void 0 && this.marketProfile.setHighlightPoC(e.highlightPoC), e.showStats !== void 0 && this.marketProfile.setShowStats(e.showStats), e.splitBySession !== void 0 && this.marketProfile.setSplitBySession(e.splitBySession), e.letters !== void 0 && this.marketProfile.setLetters(e.letters), this.engine.requestRender(r.Main);
|
|
968
|
+
}
|
|
969
|
+
getMarketProfileStats() {
|
|
970
|
+
return this.marketProfile.getStats();
|
|
971
|
+
}
|
|
972
|
+
setDepthHeatmapVisible(e) {
|
|
973
|
+
this.depthHeatmap.setVisible(e), this.engine.requestRender(r.Main);
|
|
974
|
+
}
|
|
975
|
+
isDepthHeatmapVisible() {
|
|
976
|
+
return this.depthHeatmap.isVisible();
|
|
977
|
+
}
|
|
978
|
+
setDepthHeatmapConfig(e) {
|
|
979
|
+
e.opacity !== void 0 && this.depthHeatmap.setOpacity(e.opacity), e.capacity !== void 0 && this.depthHeatmap.setCapacity(e.capacity), this.engine.requestRender(r.Main);
|
|
980
|
+
}
|
|
981
|
+
pushDepthSnapshot(e) {
|
|
982
|
+
let t = this.dataManager.getData();
|
|
983
|
+
t.length !== 0 && (this.depthHeatmap.push(t[t.length - 1].time, e), this.depthHeatmap.isVisible() && this.engine.requestRender(r.Main));
|
|
984
|
+
}
|
|
985
|
+
clearDepthHeatmap() {
|
|
986
|
+
this.depthHeatmap.clear(), this.engine.requestRender(r.Main);
|
|
987
|
+
}
|
|
988
|
+
setPeriodLevelsVisible(e) {
|
|
989
|
+
this.periodLevels.setVisible(e), this.engine.requestRender(r.Main);
|
|
990
|
+
}
|
|
991
|
+
isPeriodLevelsVisible() {
|
|
992
|
+
return this.periodLevels.isVisible();
|
|
993
|
+
}
|
|
994
|
+
setPeriodLevelsPeriod(e) {
|
|
995
|
+
this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
|
|
996
|
+
}
|
|
997
|
+
setTimezoneOffset(e) {
|
|
998
|
+
this.timeAxis.setTimezoneOffset(e), this.crosshairHandler.setTimezoneOffset(e), this.engine.requestRender(r.UI), this.engine.requestRender(r.Overlay);
|
|
999
|
+
}
|
|
1000
|
+
setPivotMarkersVisible(e) {
|
|
1001
|
+
this.pivotMarkers.setVisible(e), this.engine.requestRender(r.Overlay);
|
|
1002
|
+
}
|
|
1003
|
+
isPivotMarkersVisible() {
|
|
1004
|
+
return this.pivotMarkers.isVisible();
|
|
1005
|
+
}
|
|
1006
|
+
setPivotMarkersConfig(e) {
|
|
1007
|
+
(e.left !== void 0 || e.right !== void 0) && this.pivotMarkers.setStrength(e.left ?? 5, e.right ?? e.left ?? 5), e.showLabels !== void 0 && this.pivotMarkers.setShowLabels(e.showLabels), e.structureLabels !== void 0 && this.pivotMarkers.setStructureLabels(e.structureLabels), this.engine.requestRender(r.Overlay);
|
|
1008
|
+
}
|
|
1009
|
+
setSessionShadingVisible(e) {
|
|
1010
|
+
this.sessionShading.setVisible(e), this.engine.requestRender(r.Background);
|
|
1011
|
+
}
|
|
1012
|
+
isSessionShadingVisible() {
|
|
1013
|
+
return this.sessionShading.isVisible();
|
|
1014
|
+
}
|
|
1015
|
+
setSessionShadingConfig(e) {
|
|
1016
|
+
this.sessionShading.setConfig(e), this.engine.requestRender(r.Background);
|
|
1017
|
+
}
|
|
843
1018
|
setTooltipVisible(e) {
|
|
844
1019
|
e || this.crosshairTooltip.hide();
|
|
845
1020
|
}
|
|
@@ -853,18 +1028,27 @@ var F = class {
|
|
|
853
1028
|
this.chartLegend.setStatusText(e), this.engine.requestRender(r.UI);
|
|
854
1029
|
}
|
|
855
1030
|
screenshot(e) {
|
|
856
|
-
this.features.screenshot &&
|
|
1031
|
+
this.features.screenshot && E.download(this.container, e, this.themeManager.getTheme().background);
|
|
1032
|
+
}
|
|
1033
|
+
async copyScreenshot() {
|
|
1034
|
+
if (!this.features.screenshot) return !1;
|
|
1035
|
+
try {
|
|
1036
|
+
let e = await E.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
|
|
1037
|
+
return !e || !navigator.clipboard?.write || !t ? !1 : (await navigator.clipboard.write([new t({ "image/png": e })]), !0);
|
|
1038
|
+
} catch {
|
|
1039
|
+
return !1;
|
|
1040
|
+
}
|
|
857
1041
|
}
|
|
858
1042
|
screenshotDataURL() {
|
|
859
|
-
return this.features.screenshot ?
|
|
1043
|
+
return this.features.screenshot ? E.toDataURL(this.container, this.themeManager.getTheme().background) : null;
|
|
860
1044
|
}
|
|
861
1045
|
async screenshotBlob() {
|
|
862
|
-
return this.features.screenshot ?
|
|
1046
|
+
return this.features.screenshot ? E.toBlob(this.container, this.themeManager.getTheme().background) : null;
|
|
863
1047
|
}
|
|
864
|
-
addAlert(e, t = "crossing", n) {
|
|
1048
|
+
addAlert(e, t = "crossing", n, r = "price", i) {
|
|
865
1049
|
if (!this.features.alerts) return null;
|
|
866
|
-
let
|
|
867
|
-
return this.scheduleAutoSave(),
|
|
1050
|
+
let a = this.alertManager.addAlert(e, t, n, !1, r, i);
|
|
1051
|
+
return this.scheduleAutoSave(), a;
|
|
868
1052
|
}
|
|
869
1053
|
removeAlert(e) {
|
|
870
1054
|
this.alertManager.removeAlert(e), this.scheduleAutoSave();
|
|
@@ -1037,13 +1221,13 @@ var F = class {
|
|
|
1037
1221
|
this.countdownInterval && clearInterval(this.countdownInterval), this.disableAutoSave(), this.disconnectStream(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
|
|
1038
1222
|
}
|
|
1039
1223
|
createChartRenderer(e) {
|
|
1040
|
-
return
|
|
1224
|
+
return Je(e);
|
|
1041
1225
|
}
|
|
1042
1226
|
getDisplayData() {
|
|
1043
1227
|
if (this.displayDataCache) return this.displayDataCache;
|
|
1044
1228
|
let e = this.dataManager.getData();
|
|
1045
1229
|
if (e.length === 0) return e;
|
|
1046
|
-
let t =
|
|
1230
|
+
let t = Ye(this.options.chartType, e);
|
|
1047
1231
|
return this.displayDataCache = t, t;
|
|
1048
1232
|
}
|
|
1049
1233
|
scheduleRender() {
|
|
@@ -1058,7 +1242,11 @@ var F = class {
|
|
|
1058
1242
|
let t = this.getResolvedLayout();
|
|
1059
1243
|
this.viewport.setChartRect(t.mainChartRect);
|
|
1060
1244
|
let n = this.getDisplayData();
|
|
1061
|
-
if (this.viewport.updateData(n, this.options.autoScale !== !1),
|
|
1245
|
+
if (this.viewport.updateData(n, this.options.autoScale !== !1), n.length > 0) {
|
|
1246
|
+
let e = this.viewport.getState(), t = Math.max(0, Math.min(e.visibleRange.from, n.length - 1));
|
|
1247
|
+
this.viewport.setScaleBaseline(n[t]?.close);
|
|
1248
|
+
}
|
|
1249
|
+
if (this.options.autoScale !== !1) {
|
|
1062
1250
|
let e = this.viewport.getState(), t = this.indicatorEngine.getOverlayPriceRange(e.visibleRange.from, Math.min(e.visibleRange.to, n.length - 1));
|
|
1063
1251
|
if (t) {
|
|
1064
1252
|
let n = e.priceRange, r = Math.min(n.min, t.min), i = Math.max(n.max, t.max);
|
|
@@ -1080,7 +1268,7 @@ var F = class {
|
|
|
1080
1268
|
buildPanelRenderInfos() {
|
|
1081
1269
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
1082
1270
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
1083
|
-
let i =
|
|
1271
|
+
let i = Xe(this.indicatorEngine.getOutput(e.config.id), n, r), a = {
|
|
1084
1272
|
x: e.rect.x,
|
|
1085
1273
|
y: e.rect.y + 20,
|
|
1086
1274
|
width: e.rect.width,
|
|
@@ -1114,9 +1302,14 @@ var F = class {
|
|
|
1114
1302
|
chartLegend: this.features.legend ? this.chartLegend : null,
|
|
1115
1303
|
volumeRenderer: this.features.volume ? this.volumeRenderer : null,
|
|
1116
1304
|
volumeProfile: this.volumeProfile,
|
|
1305
|
+
marketProfile: this.marketProfile,
|
|
1306
|
+
depthHeatmap: this.depthHeatmap,
|
|
1307
|
+
periodLevels: this.periodLevels,
|
|
1308
|
+
pivotMarkers: this.pivotMarkers,
|
|
1117
1309
|
watermark: this.features.watermark ? this.watermark : null,
|
|
1118
1310
|
barCountdown: this.barCountdown,
|
|
1119
1311
|
sessionBreaks: this.sessionBreaks,
|
|
1312
|
+
sessionShading: this.sessionShading,
|
|
1120
1313
|
compareRenderer: this.compareRenderer,
|
|
1121
1314
|
alertManager: this.features.alerts ? this.alertManager : null,
|
|
1122
1315
|
measureOverlay: this.measureOverlay,
|
|
@@ -1146,26 +1339,26 @@ var F = class {
|
|
|
1146
1339
|
} : void 0
|
|
1147
1340
|
} : null;
|
|
1148
1341
|
}
|
|
1149
|
-
},
|
|
1342
|
+
}, H = [
|
|
1150
1343
|
"time",
|
|
1151
1344
|
"timestamp",
|
|
1152
1345
|
"date",
|
|
1153
1346
|
"datetime",
|
|
1154
1347
|
"t"
|
|
1155
|
-
],
|
|
1348
|
+
], U = ["open", "o"], W = ["high", "h"], G = ["low", "l"], K = ["close", "c"], q = [
|
|
1156
1349
|
"volume",
|
|
1157
1350
|
"vol",
|
|
1158
1351
|
"v"
|
|
1159
1352
|
];
|
|
1160
|
-
function
|
|
1353
|
+
function J(e) {
|
|
1161
1354
|
let t = e.trim();
|
|
1162
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
1355
|
+
return t ? t[0] === "[" || t[0] === "{" ? $e(t) : et(t) : {
|
|
1163
1356
|
data: [],
|
|
1164
1357
|
rowCount: 0,
|
|
1165
1358
|
skipped: 0
|
|
1166
1359
|
};
|
|
1167
1360
|
}
|
|
1168
|
-
function
|
|
1361
|
+
function $e(e) {
|
|
1169
1362
|
let t;
|
|
1170
1363
|
try {
|
|
1171
1364
|
t = JSON.parse(e);
|
|
@@ -1175,19 +1368,19 @@ function Ke(e) {
|
|
|
1175
1368
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
1176
1369
|
let n = [], r = 0;
|
|
1177
1370
|
for (let e of t) {
|
|
1178
|
-
let t = Array.isArray(e) ?
|
|
1371
|
+
let t = Array.isArray(e) ? it(e) : rt(e);
|
|
1179
1372
|
t ? n.push(t) : r++;
|
|
1180
1373
|
}
|
|
1181
1374
|
return Q(n, t.length, r);
|
|
1182
1375
|
}
|
|
1183
|
-
function
|
|
1376
|
+
function et(e) {
|
|
1184
1377
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
1185
1378
|
if (t.length === 0) return {
|
|
1186
1379
|
data: [],
|
|
1187
1380
|
rowCount: 0,
|
|
1188
1381
|
skipped: 0
|
|
1189
1382
|
};
|
|
1190
|
-
let n =
|
|
1383
|
+
let n = tt(t[0]), r = Y(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? nt(r) : {
|
|
1191
1384
|
time: 0,
|
|
1192
1385
|
open: 1,
|
|
1193
1386
|
high: 2,
|
|
@@ -1198,7 +1391,7 @@ function qe(e) {
|
|
|
1198
1391
|
if (a.time < 0 || a.open < 0 || a.high < 0 || a.low < 0 || a.close < 0) throw Error("CSV is missing required column(s): time, open, high, low, close");
|
|
1199
1392
|
let o = [], s = 0;
|
|
1200
1393
|
for (let e = +!!i; e < t.length; e++) {
|
|
1201
|
-
let r =
|
|
1394
|
+
let r = Y(t[e], n), i = Z(r[a.time]), c = X(r[a.open]), l = X(r[a.high]), u = X(r[a.low]), d = X(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
|
|
1202
1395
|
if (i === null || ![
|
|
1203
1396
|
c,
|
|
1204
1397
|
l,
|
|
@@ -1219,7 +1412,7 @@ function qe(e) {
|
|
|
1219
1412
|
}
|
|
1220
1413
|
return Q(o, t.length - +!!i, s);
|
|
1221
1414
|
}
|
|
1222
|
-
function
|
|
1415
|
+
function tt(e) {
|
|
1223
1416
|
let t = {
|
|
1224
1417
|
",": 0,
|
|
1225
1418
|
";": 0,
|
|
@@ -1231,7 +1424,7 @@ function Je(e) {
|
|
|
1231
1424
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
1232
1425
|
return n;
|
|
1233
1426
|
}
|
|
1234
|
-
function
|
|
1427
|
+
function Y(e, t) {
|
|
1235
1428
|
let n = [], r = "", i = !1;
|
|
1236
1429
|
for (let a = 0; a < e.length; a++) {
|
|
1237
1430
|
let o = e[a];
|
|
@@ -1239,25 +1432,25 @@ function J(e, t) {
|
|
|
1239
1432
|
}
|
|
1240
1433
|
return n.push(r), n;
|
|
1241
1434
|
}
|
|
1242
|
-
function
|
|
1435
|
+
function nt(e) {
|
|
1243
1436
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
1244
1437
|
return {
|
|
1245
|
-
time: t(
|
|
1246
|
-
open: t(
|
|
1247
|
-
high: t(
|
|
1248
|
-
low: t(
|
|
1249
|
-
close: t(
|
|
1250
|
-
volume: t(
|
|
1438
|
+
time: t(H),
|
|
1439
|
+
open: t(U),
|
|
1440
|
+
high: t(W),
|
|
1441
|
+
low: t(G),
|
|
1442
|
+
close: t(K),
|
|
1443
|
+
volume: t(q)
|
|
1251
1444
|
};
|
|
1252
1445
|
}
|
|
1253
|
-
function
|
|
1446
|
+
function rt(e) {
|
|
1254
1447
|
let t = (t) => {
|
|
1255
1448
|
for (let n of t) {
|
|
1256
1449
|
if (e[n] !== void 0) return e[n];
|
|
1257
1450
|
let t = n.toUpperCase();
|
|
1258
1451
|
if (e[t] !== void 0) return e[t];
|
|
1259
1452
|
}
|
|
1260
|
-
}, n = Z(String(t(
|
|
1453
|
+
}, n = Z(String(t(H) ?? "")), r = Number(t(U)), i = Number(t(W)), a = Number(t(G)), o = Number(t(K)), s = Number(t(q) ?? 0);
|
|
1261
1454
|
return n === null || ![
|
|
1262
1455
|
r,
|
|
1263
1456
|
i,
|
|
@@ -1272,7 +1465,7 @@ function Ye(e) {
|
|
|
1272
1465
|
volume: Number.isFinite(s) ? s : 0
|
|
1273
1466
|
};
|
|
1274
1467
|
}
|
|
1275
|
-
function
|
|
1468
|
+
function it(e) {
|
|
1276
1469
|
if (e.length < 5) return null;
|
|
1277
1470
|
let t = Z(String(e[0])), n = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = Number(e[4]), o = e.length >= 6 ? Number(e[5]) : 0;
|
|
1278
1471
|
return t === null || ![
|
|
@@ -1312,7 +1505,7 @@ function Q(e, t, n) {
|
|
|
1312
1505
|
}
|
|
1313
1506
|
//#endregion
|
|
1314
1507
|
//#region src/io/DragDropImporter.ts
|
|
1315
|
-
var
|
|
1508
|
+
var at = class {
|
|
1316
1509
|
host;
|
|
1317
1510
|
overlay = null;
|
|
1318
1511
|
callbacks;
|
|
@@ -1345,7 +1538,7 @@ var Ze = class {
|
|
|
1345
1538
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
1346
1539
|
let t = e.dataTransfer?.files?.[0];
|
|
1347
1540
|
if (t) try {
|
|
1348
|
-
let e =
|
|
1541
|
+
let e = J(await t.text());
|
|
1349
1542
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
1350
1543
|
this.callbacks.onData(e.data, e, t);
|
|
1351
1544
|
} catch (e) {
|
|
@@ -1380,6 +1573,6 @@ function $(e) {
|
|
|
1380
1573
|
return e.dataTransfer?.types?.includes("Files") ?? !1;
|
|
1381
1574
|
}
|
|
1382
1575
|
//#endregion
|
|
1383
|
-
export {
|
|
1576
|
+
export { B as a, V as i, J as n, L as o, Qe as r, I as s, at as t };
|
|
1384
1577
|
|
|
1385
|
-
//# sourceMappingURL=DragDropImporter-
|
|
1578
|
+
//# sourceMappingURL=DragDropImporter-Br2ez5Gz.js.map
|