@tradecanvas/chart 0.1.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/index.js ADDED
@@ -0,0 +1,966 @@
1
+ import { DARK_THEME as e, DARK_THEME as t, DEFAULT_DRAWING_STYLE as n, DEFAULT_PANEL_HEIGHT as r, DEFAULT_RECONNECT as i, DEFAULT_STREAM_CONFIG as a, DEFAULT_TIMEFRAME_FAVORITES as o, DEFAULT_TRADING_CONFIG as s, LIGHT_THEME as c, LIGHT_THEME as l, LayerType as u, MARKET_CRYPTO as d, MARKET_HNX as f, MARKET_HOSE as ee, MARKET_NYSE as p, MARKET_UPCOM as te, MIN_PANEL_HEIGHT as m, PRICE_AXIS_WIDTH as h, TIMEFRAMES_CRYPTO as g, TIMEFRAMES_FOREX as ne, TIMEFRAMES_STOCK as re, TIME_AXIS_HEIGHT as _, VN_COLORS as ie, computePriceLimits as ae, computePriceLimits as v, createVNTheme as oe, formatNumber as se, formatVND as ce, formatVolumeLoc as le, getCurrentSession as ue, getLocale as de, mergeBar as fe, registerLocale as pe, setLocale as y, setLocale as b, t as x } from "@tradecanvas/commons";
2
+ import { AlertManager as S, AlertManager as C, Animator as w, Animator as T, AreaRenderer as E, BarCountdown as D, BarCountdown as O, BarRenderer as k, BaselineRenderer as A, BinanceAdapter as j, CandlestickRenderer as M, ChartLegend as N, ChartLegend as P, ChartStateManager as F, ChartStateManager as I, CompareRenderer as L, CompareRenderer as R, CrosshairHandler as z, CrosshairTooltip as B, CrosshairTooltip as me, CurrentPriceLine as he, CurrentPriceLine as ge, DEFAULT_LEGEND_CONFIG as _e, DataExporter as ve, DataExporter as V, DrawingBase as ye, DrawingManager as be, DrawingRenderer as xe, Easing as Se, EventBus as Ce, GridRenderer as we, HollowCandleRenderer as Te, IndicatorBase as Ee, IndicatorEngine as H, InteractionManager as De, KagiRenderer as Oe, KeyboardHandler as ke, KeyboardHandler as Ae, LineRenderer as je, MockAdapter as Me, PanHandler as Ne, PointAndFigureRenderer as Pe, PriceAxis as Fe, RenderEngine as Ie, RenkoRenderer as Le, ReplayManager as Re, ReplayManager as ze, Screenshot as Be, Screenshot as U, SessionBreaks as Ve, SessionBreaks as He, StreamManager as Ue, StreamManager as We, TickAggregator as Ge, TimeAxis as Ke, TradingManager as qe, TradingRenderer as Je, UndoRedoManager as Ye, UndoRedoManager as Xe, Viewport as Ze, VolumeRenderer as Qe, VolumeRenderer as $e, Watermark as et, Watermark as tt, ZoomHandler as nt, registerBuiltInDrawingTools as rt, registerBuiltInIndicators as W, toHeikinAshi as it, toHeikinAshi as at, toKagi as ot, toKagi as st, toLineBreak as ct, toLineBreak as lt, toPointAndFigure as G, toPointAndFigure as ut, toRenko as dt, toRenko as ft } from "@tradecanvas/core";
3
+ //#region src/DataManager.ts
4
+ function K(e) {
5
+ if (!e || typeof e.time != "number") return !1;
6
+ let { open: t, high: n, low: r, close: i } = e;
7
+ 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));
8
+ }
9
+ function q(e) {
10
+ return {
11
+ ...e,
12
+ high: Math.max(e.open, e.high, e.low, e.close),
13
+ low: Math.min(e.open, e.high, e.low, e.close),
14
+ volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
15
+ };
16
+ }
17
+ var J = class {
18
+ data = [];
19
+ getData() {
20
+ return this.data;
21
+ }
22
+ setData(e) {
23
+ this.data = e.filter(K).map(q);
24
+ }
25
+ appendBar(e) {
26
+ K(e) && this.data.push(q(e));
27
+ }
28
+ updateLastBar(e) {
29
+ if (!K(e)) return;
30
+ let t = q(e);
31
+ if (this.data.length === 0) {
32
+ this.data.push(t);
33
+ return;
34
+ }
35
+ this.data[this.data.length - 1] = t;
36
+ }
37
+ updateLastBarFromTick(e) {
38
+ 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] = fe(this.data[this.data.length - 1], e)));
39
+ }
40
+ getLength() {
41
+ return this.data.length;
42
+ }
43
+ clear() {
44
+ this.data = [];
45
+ }
46
+ }, Y = class {
47
+ theme;
48
+ constructor(e) {
49
+ !e || e === "dark" ? this.theme = { ...t } : e === "light" ? this.theme = { ...l } : this.theme = { ...e };
50
+ }
51
+ getTheme() {
52
+ return this.theme;
53
+ }
54
+ setTheme(e) {
55
+ e === "dark" ? this.theme = { ...t } : e === "light" ? this.theme = { ...l } : this.theme = { ...e };
56
+ }
57
+ }, X = 200, Z = 80, Q = class {
58
+ panels = [];
59
+ containerWidth = 0;
60
+ containerHeight = 0;
61
+ resize(e, t) {
62
+ this.containerWidth = e, this.containerHeight = t;
63
+ }
64
+ addPanel(e, t = "bottom", n) {
65
+ let i = t === "left" || t === "right";
66
+ this.panels.push({
67
+ id: e,
68
+ position: t,
69
+ size: n ?? (i ? X : r),
70
+ minSize: i ? Z : m,
71
+ content: {
72
+ type: "indicator",
73
+ indicatorInstanceId: e
74
+ }
75
+ });
76
+ }
77
+ removePanel(e) {
78
+ this.panels = this.panels.filter((t) => t.id !== e);
79
+ }
80
+ setPanelPosition(e, t) {
81
+ let n = this.panels.find((t) => t.id === e);
82
+ if (n) {
83
+ let e = n.position === "left" || n.position === "right", i = t === "left" || t === "right";
84
+ n.position = t, e !== i && (n.size = i ? X : r, n.minSize = i ? Z : m);
85
+ }
86
+ }
87
+ setPanelSize(e, t) {
88
+ let n = this.panels.find((t) => t.id === e);
89
+ n && (n.size = Math.max(n.minSize, t));
90
+ }
91
+ getPanels() {
92
+ return this.panels;
93
+ }
94
+ resolve() {
95
+ let e = this.panels.filter((e) => e.position === "left"), t = this.panels.filter((e) => e.position === "right"), n = this.panels.filter((e) => e.position === "top"), r = this.panels.filter((e) => e.position === "bottom"), i = e.reduce((e, t) => e + t.size, 0), a = t.reduce((e, t) => e + t.size, 0), o = n.reduce((e, t) => e + t.size, 0), s = r.reduce((e, t) => e + t.size, 0), c = {
96
+ x: i,
97
+ y: o,
98
+ width: Math.max(0, this.containerWidth - i - a - h),
99
+ height: Math.max(0, this.containerHeight - o - s - _)
100
+ }, l = [], u = [], d = 0;
101
+ for (let t of e) l.push({
102
+ config: t,
103
+ rect: {
104
+ x: d,
105
+ y: 0,
106
+ width: t.size,
107
+ height: this.containerHeight - _
108
+ }
109
+ }), u.push({
110
+ panelId: t.id,
111
+ rect: {
112
+ x: d + t.size - 2,
113
+ y: 0,
114
+ width: 4,
115
+ height: this.containerHeight
116
+ },
117
+ orientation: "vertical"
118
+ }), d += t.size;
119
+ let f = 0;
120
+ for (let e of n) l.push({
121
+ config: e,
122
+ rect: {
123
+ x: i,
124
+ y: f,
125
+ width: c.width,
126
+ height: e.size
127
+ }
128
+ }), u.push({
129
+ panelId: e.id,
130
+ rect: {
131
+ x: i,
132
+ y: f + e.size - 2,
133
+ width: c.width,
134
+ height: 4
135
+ },
136
+ orientation: "horizontal"
137
+ }), f += e.size;
138
+ f = c.y + c.height;
139
+ for (let e of r) l.push({
140
+ config: e,
141
+ rect: {
142
+ x: i,
143
+ y: f,
144
+ width: c.width,
145
+ height: e.size
146
+ }
147
+ }), u.push({
148
+ panelId: e.id,
149
+ rect: {
150
+ x: i,
151
+ y: f - 2,
152
+ width: c.width,
153
+ height: 4
154
+ },
155
+ orientation: "horizontal"
156
+ }), f += e.size;
157
+ d = i + c.width + h;
158
+ for (let e of t) l.push({
159
+ config: e,
160
+ rect: {
161
+ x: d,
162
+ y: 0,
163
+ width: e.size,
164
+ height: this.containerHeight - _
165
+ }
166
+ }), u.push({
167
+ panelId: e.id,
168
+ rect: {
169
+ x: d - 2,
170
+ y: 0,
171
+ width: 4,
172
+ height: this.containerHeight
173
+ },
174
+ orientation: "vertical"
175
+ }), d += e.size;
176
+ return {
177
+ mainChartRect: c,
178
+ panels: l,
179
+ dividers: u
180
+ };
181
+ }
182
+ getMainChartRect() {
183
+ return this.resolve().mainChartRect;
184
+ }
185
+ }, $ = class {
186
+ constructor(e) {
187
+ this.indicatorEngine = e;
188
+ }
189
+ registerIndicator(e) {
190
+ this.indicatorEngine.register(e);
191
+ }
192
+ }, pt = class {
193
+ static version = "0.3.0";
194
+ engine;
195
+ viewport;
196
+ dataManager;
197
+ themeManager;
198
+ layoutManager;
199
+ pluginManager;
200
+ indicatorEngine;
201
+ drawingManager;
202
+ drawingRenderer;
203
+ tradingManager;
204
+ tradingRenderer;
205
+ eventBus;
206
+ streamManager = null;
207
+ autoScrollOnNewBar = !0;
208
+ displayDataCache = null;
209
+ resolvedLayoutCache = null;
210
+ panelInfoCache = null;
211
+ renderScheduled = !1;
212
+ containerSizeCache = null;
213
+ containerSizeCacheTime = 0;
214
+ chartLegend;
215
+ watermark;
216
+ barCountdown;
217
+ sessionBreaks;
218
+ compareRenderer;
219
+ countdownInterval = null;
220
+ volumeRenderer;
221
+ alertManager;
222
+ replayManager;
223
+ undoRedoManager;
224
+ autoSaveTimer = null;
225
+ autoSaveDelay = 0;
226
+ autoSaveKey = null;
227
+ animator;
228
+ crosshairTooltip;
229
+ interactionManager;
230
+ crosshairHandler;
231
+ chartRenderer;
232
+ gridRenderer;
233
+ priceAxis;
234
+ timeAxis;
235
+ options;
236
+ features;
237
+ marketConfig = null;
238
+ container;
239
+ currentPriceLine;
240
+ constructor(e, t) {
241
+ this.container = e, this.options = t;
242
+ let n = t.features ?? {};
243
+ this.features = {
244
+ drawings: n.drawings ?? !0,
245
+ drawingTools: n.drawingTools ?? [],
246
+ drawingMagnet: n.drawingMagnet ?? !0,
247
+ drawingUndoRedo: n.drawingUndoRedo ?? !0,
248
+ trading: n.trading ?? !0,
249
+ tradingContextMenu: n.tradingContextMenu ?? !0,
250
+ indicators: n.indicators ?? !0,
251
+ indicatorIds: n.indicatorIds ?? [],
252
+ panning: n.panning ?? !0,
253
+ zooming: n.zooming ?? !0,
254
+ crosshair: n.crosshair ?? !0,
255
+ keyboard: n.keyboard ?? !0,
256
+ priceAxis: n.priceAxis ?? !0,
257
+ timeAxis: n.timeAxis ?? !0,
258
+ grid: n.grid ?? t.grid?.visible ?? !0,
259
+ legend: n.legend ?? !0,
260
+ volume: n.volume ?? !0,
261
+ watermark: n.watermark ?? !0,
262
+ saveLoad: n.saveLoad ?? !0,
263
+ screenshot: n.screenshot ?? !0,
264
+ alerts: n.alerts ?? !0,
265
+ replay: n.replay ?? !0,
266
+ sessionBreaks: n.sessionBreaks ?? !0,
267
+ barCountdown: n.barCountdown ?? !0,
268
+ compareSymbols: n.compareSymbols ?? !0,
269
+ dataExport: n.dataExport ?? !0,
270
+ logScale: n.logScale ?? !0,
271
+ timeframes: n.timeframes ?? [],
272
+ defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
273
+ }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", this.dataManager = new J(), this.themeManager = new Y(t.theme), this.layoutManager = new Q(), this.indicatorEngine = new H(), this.pluginManager = new $(this.indicatorEngine), this.eventBus = new Ce(), W(this.indicatorEngine), this.drawingManager = new be(), rt(this.drawingManager), this.drawingRenderer = new xe(this.drawingManager), this.drawingManager.setRequestRender(() => {
274
+ this.syncRenderContext(), this.engine.requestRender(u.Overlay), this.scheduleAutoSave();
275
+ }), this.drawingManager.setEventCallback((e, t) => {
276
+ this.eventBus.emit(e, t);
277
+ }), this.undoRedoManager = new Xe(), 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 qe(), this.tradingRenderer = new Je(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(u.Overlay)), this.tradingManager.setEventCallback((e, t) => {
278
+ this.eventBus.emit(e, t);
279
+ }), this.engine = new Ie(e);
280
+ let r = this.engine.dprManager.getContainerSize();
281
+ this.viewport = new Ze(r.width, r.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.layoutManager.resize(r.width, r.height), this.engine.onContainerResize = (e) => {
282
+ if (e.width <= 0 || e.height <= 0) return;
283
+ let t = this.viewport.isAtEnd();
284
+ this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
285
+ }, this.chartRenderer = this.createChartRenderer(t.chartType), this.gridRenderer = new we(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new Fe(), this.timeAxis = new Ke(), this.crosshairHandler = new z(), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
286
+ if (e !== null && t) {
287
+ let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
288
+ this.chartLegend.setHoverBar(r ?? null), r && this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize()), this.eventBus.emit("crosshairMove", {
289
+ point: t,
290
+ bar: r,
291
+ barIndex: e
292
+ });
293
+ } else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null);
294
+ }), this.chartLegend = new P(), this.chartLegend.setChartType(t.chartType), this.watermark = new tt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new $e(), this.barCountdown = new O(), this.sessionBreaks = new He(), this.compareRenderer = new R(), t.sessionBreaks ? this.sessionBreaks.setConfig({
295
+ visible: t.sessionBreaks.visible ?? !0,
296
+ color: t.sessionBreaks.color,
297
+ lineStyle: t.sessionBreaks.lineStyle,
298
+ lineWidth: t.sessionBreaks.lineWidth
299
+ }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.viewport.setLogScale(!0), this.animator = new T(), this.crosshairTooltip = new me(), this.crosshairTooltip.create(e), new Ae({
300
+ scrollBars: (e) => {
301
+ let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
302
+ this.viewport.scrollBy(e * t), this.updateViewportAndRender();
303
+ },
304
+ zoom: (e) => {
305
+ let t = this.viewport.getState().chartRect.width;
306
+ this.viewport.zoom(e, t / 2), this.updateViewportAndRender();
307
+ },
308
+ goToStart: () => {
309
+ this.viewport.scrollBy(-Infinity), this.updateViewportAndRender();
310
+ },
311
+ goToEnd: () => {
312
+ this.viewport.scrollToEnd(), this.updateViewportAndRender();
313
+ },
314
+ fitContent: () => this.fitContent()
315
+ }), this.currentPriceLine = new ge(), this.alertManager = new C(), this.alertManager.setRequestRender(() => this.engine.requestRender(u.Overlay)), this.alertManager.on("triggered", (e) => {
316
+ this.eventBus.emit("dataUpdate", {
317
+ alert: "triggered",
318
+ alertId: e.id,
319
+ price: e.price,
320
+ message: e.message
321
+ });
322
+ }), this.replayManager = new ze(), this.interactionManager = new De(e), this.features.panning && this.interactionManager.setPanHandler(new Ne((e) => {
323
+ this.viewport.scrollBy(e), this.updateViewportAndRender();
324
+ })), this.features.zooming && this.interactionManager.setZoomHandler(new nt((e, t) => {
325
+ this.viewport.zoom(e, t), this.updateViewportAndRender();
326
+ })), this.features.crosshair && this.interactionManager.setCrosshairHandler(this.crosshairHandler), this.features.drawings && this.interactionManager.setDrawingManager(this.drawingManager, () => this.viewport.getState()), this.features.trading && this.interactionManager.setTradingManager(this.tradingManager, () => this.viewport.getState()), this.interactionManager.setOverlayDirtyCallback(() => {
327
+ this.engine.requestRender(u.Overlay), this.layoutManager.getPanels().length > 0 && this.engine.requestRender(u.UI);
328
+ }), this.interactionManager.attach(), this.syncRenderContext(), this.engine.start();
329
+ }
330
+ setData(e) {
331
+ 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 });
332
+ }
333
+ appendBar(e) {
334
+ 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();
335
+ }
336
+ updateLastBar(e) {
337
+ this.dataManager.updateLastBar(e), this.currentPriceLine.setPrice(e.close), this.options.chartType !== "candlestick" && this.options.chartType !== "line" && this.options.chartType !== "area" && this.options.chartType !== "bar" && this.options.chartType !== "hollowCandle" && (this.displayDataCache = null), this.scheduleRender();
338
+ }
339
+ updateLastBarFromTick(e) {
340
+ this.dataManager.updateLastBarFromTick(e), this.currentPriceLine.setPrice(e.price), this.options.chartType !== "candlestick" && this.options.chartType !== "line" && this.options.chartType !== "area" && this.options.chartType !== "bar" && this.options.chartType !== "hollowCandle" && (this.displayDataCache = null), this.scheduleRender();
341
+ }
342
+ setChartType(e) {
343
+ this.options.chartType = e, this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.updateViewportAndRender(!0);
344
+ }
345
+ addIndicator(e, t = {}, n = "bottom") {
346
+ if (!this.features.indicators || this.features.indicatorIds.length > 0 && !this.features.indicatorIds.includes(e)) return null;
347
+ let r = this.indicatorEngine.addIndicator(e, t, this.dataManager.getData());
348
+ return this.indicatorEngine.getAvailableIndicators().find((t) => t.id === e)?.placement === "panel" && this.layoutManager.addPanel(r, n), this.eventBus.emit("indicatorAdd", {
349
+ instanceId: r,
350
+ id: e
351
+ }), this.engine.requestRender(), r;
352
+ }
353
+ updateIndicator(e, t) {
354
+ this.indicatorEngine.updateIndicator(e, t, this.dataManager.getData()), this.engine.requestRender();
355
+ }
356
+ removeIndicator(e) {
357
+ this.indicatorEngine.removeIndicator(e), this.layoutManager.removePanel(e), this.eventBus.emit("indicatorRemove", { instanceId: e }), this.engine.requestRender();
358
+ }
359
+ getIndicatorOutput(e) {
360
+ return this.indicatorEngine.getOutput(e);
361
+ }
362
+ registerIndicator(e) {
363
+ this.pluginManager.registerIndicator(e);
364
+ }
365
+ static indicators() {
366
+ let e = new H();
367
+ return W(e), e.getAvailableIndicators();
368
+ }
369
+ setPanelPosition(e, t) {
370
+ this.layoutManager.setPanelPosition(e, t), this.engine.requestRender();
371
+ }
372
+ setPanelSize(e, t) {
373
+ this.layoutManager.setPanelSize(e, t), this.engine.requestRender();
374
+ }
375
+ setDrawingTool(e) {
376
+ this.features.drawings && (e && this.features.drawingTools.length > 0 && !this.features.drawingTools.includes(e) || this.drawingManager.setActiveTool(e));
377
+ }
378
+ getDrawingTool() {
379
+ return this.drawingManager.getActiveTool();
380
+ }
381
+ setDrawingStyle(e) {
382
+ this.drawingManager.setStyle(e);
383
+ }
384
+ getDrawings() {
385
+ return this.drawingManager.getDrawings();
386
+ }
387
+ setDrawings(e) {
388
+ this.drawingManager.setDrawings(e);
389
+ }
390
+ removeDrawing(e) {
391
+ this.drawingManager.removeDrawing(e);
392
+ }
393
+ clearDrawings() {
394
+ this.drawingManager.clearDrawings();
395
+ }
396
+ registerDrawingTool(e) {
397
+ this.drawingManager.register(e);
398
+ }
399
+ undo() {
400
+ return this.features.drawingUndoRedo ? this.drawingManager.undo() : !1;
401
+ }
402
+ redo() {
403
+ return this.features.drawingUndoRedo ? this.drawingManager.redo() : !1;
404
+ }
405
+ getUndoRedoState() {
406
+ return this.undoRedoManager.getState();
407
+ }
408
+ setDrawingMagnet(e) {
409
+ this.drawingManager.setMagnetMode(e ? "magnet" : "none");
410
+ }
411
+ getDrawingMagnet() {
412
+ return this.drawingManager.getMagnetMode() === "magnet";
413
+ }
414
+ lockAllDrawings() {
415
+ this.drawingManager.lockAllDrawings();
416
+ }
417
+ unlockAllDrawings() {
418
+ this.drawingManager.unlockAllDrawings();
419
+ }
420
+ hideAllDrawings() {
421
+ this.drawingManager.hideAllDrawings();
422
+ }
423
+ showAllDrawings() {
424
+ this.drawingManager.showAllDrawings();
425
+ }
426
+ duplicateDrawing(e) {
427
+ let t = e ?? this.drawingManager.getSelectedDrawingId();
428
+ return t ? this.drawingManager.duplicateDrawing(t) : null;
429
+ }
430
+ exportVisibleData(e = "csv", t) {
431
+ let n = this.viewport.getState(), r = this.dataManager.getData(), i = Math.max(0, n.visibleRange.from), a = Math.min(r.length - 1, n.visibleRange.to), o = r.slice(i, a + 1);
432
+ if (e === "json") {
433
+ let e = V.toJSON(o);
434
+ V.download(e, t ?? "chart-data.json", "application/json");
435
+ } else {
436
+ let e = V.toCSV(o);
437
+ V.download(e, t ?? "chart-data.csv", "text/csv");
438
+ }
439
+ }
440
+ exportAllData(e = "csv", t) {
441
+ let n = this.dataManager.getData();
442
+ if (e === "json") {
443
+ let e = V.toJSON(n);
444
+ V.download(e, t ?? "chart-data.json", "application/json");
445
+ } else {
446
+ let e = V.toCSV(n);
447
+ V.download(e, t ?? "chart-data.csv", "text/csv");
448
+ }
449
+ }
450
+ setAutoSave(e, t = 5e3) {
451
+ this.autoSaveKey = e, this.autoSaveDelay = t;
452
+ }
453
+ disableAutoSave() {
454
+ this.autoSaveDelay = 0, this.autoSaveKey = null, this.autoSaveTimer &&= (clearTimeout(this.autoSaveTimer), null);
455
+ }
456
+ scheduleAutoSave() {
457
+ this.autoSaveDelay <= 0 || !this.autoSaveKey || (this.autoSaveTimer && clearTimeout(this.autoSaveTimer), this.autoSaveTimer = setTimeout(() => {
458
+ this.autoSaveTimer = null, this.autoSaveKey && this.saveState(this.autoSaveKey);
459
+ }, this.autoSaveDelay));
460
+ }
461
+ getAvailableIndicators() {
462
+ return this.indicatorEngine.getAvailableIndicators();
463
+ }
464
+ getIndicatorInputs(e) {
465
+ let t = this.indicatorEngine.getAvailableIndicators().find((t) => t.id === e);
466
+ return t ? {
467
+ id: t.id,
468
+ params: t.defaultConfig
469
+ } : null;
470
+ }
471
+ getActiveIndicators() {
472
+ return this.indicatorEngine.getActiveIndicators();
473
+ }
474
+ getIndicatorConfig(e) {
475
+ let t = this.indicatorEngine.getIndicatorConfig(e);
476
+ return t ? {
477
+ id: t.id,
478
+ params: { ...t.params }
479
+ } : null;
480
+ }
481
+ updateIndicatorStyle(e, t) {
482
+ this.indicatorEngine.updateIndicatorStyle(e, t), this.engine.requestRender();
483
+ }
484
+ setOrders(e) {
485
+ this.features.trading && this.tradingManager.setOrders(e);
486
+ }
487
+ setPositions(e) {
488
+ this.features.trading && this.tradingManager.setPositions(e);
489
+ }
490
+ setDepthData(e) {
491
+ this.features.trading && this.tradingManager.setDepthData(e);
492
+ }
493
+ setCurrentPrice(e) {
494
+ this.tradingManager.setCurrentPrice(e), this.currentPriceLine.setPrice(e), this.scheduleRender(), this.features.alerts && this.alertManager.checkPrice(e);
495
+ }
496
+ setTradingConfig(e) {
497
+ this.features.trading && this.tradingManager.setConfig(e);
498
+ }
499
+ async connect(e) {
500
+ this.disconnectStream(), this.streamManager = new We(), this.streamManager.on("snapshot", (e) => {
501
+ this.setData(e);
502
+ }), this.streamManager.on("barClose", (e) => {
503
+ this.dataManager.appendBar(e), this.crosshairHandler.setData(this.dataManager.getData()), this.autoScrollOnNewBar && this.viewport.scrollToEnd(), this.indicatorEngine.recalculateAll(this.dataManager.getData()), this.updateViewportAndRender();
504
+ }), this.streamManager.on("barUpdate", (e) => {
505
+ this.dataManager.updateLastBar(e), this.currentPriceLine.setPrice(e.close), this.scheduleRender();
506
+ }), this.streamManager.on("priceChange", ({ price: e }) => {
507
+ this.tradingManager.setCurrentPrice(e), this.currentPriceLine.setPrice(e), this.engine.requestRender(u.Overlay), this.engine.requestRender(u.UI);
508
+ }), this.streamManager.on("connectionChange", (e) => {
509
+ this.eventBus.emit("dataUpdate", { connection: e });
510
+ }), this.streamManager.on("error", (e) => {
511
+ this.eventBus.emit("dataUpdate", { error: e.message });
512
+ }), this.autoScrollOnNewBar = e.autoScroll !== !1, await this.streamManager.connect(e);
513
+ let t = this.timeframeToMs(e.timeframe);
514
+ this.barCountdown.setTimeframeMs(t), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
515
+ this.barCountdown.isVisible() && this.engine.requestRender(u.UI);
516
+ }, 1e3);
517
+ }
518
+ async switchStream(e, t) {
519
+ this.streamManager && await this.streamManager.switchTo(e, t);
520
+ }
521
+ disconnectStream() {
522
+ this.streamManager &&= (this.streamManager.dispose(), null);
523
+ }
524
+ setBarCountdownVisible(e) {
525
+ this.barCountdown.setVisible(e), this.engine.requestRender(u.UI);
526
+ }
527
+ setSessionBreaksVisible(e) {
528
+ this.sessionBreaks.setVisible(e), this.engine.requestRender(u.Background);
529
+ }
530
+ addCompareSymbol(e, t, n, r) {
531
+ this.compareRenderer.addSymbol({
532
+ id: e,
533
+ label: t,
534
+ data: n,
535
+ color: r,
536
+ visible: !0
537
+ }), this.engine.requestRender(u.Main);
538
+ }
539
+ removeCompareSymbol(e) {
540
+ this.compareRenderer.removeSymbol(e), this.engine.requestRender(u.Main);
541
+ }
542
+ updateCompareData(e, t) {
543
+ this.compareRenderer.setSymbolData(e, t), this.engine.requestRender(u.Main);
544
+ }
545
+ setCompareMode(e) {
546
+ this.compareRenderer.setMode(e), this.engine.requestRender(u.Main);
547
+ }
548
+ clearCompareSymbols() {
549
+ this.compareRenderer.clear(), this.engine.requestRender(u.Main);
550
+ }
551
+ setLogScale(e) {
552
+ this.viewport.setLogScale(e), this.updateViewportAndRender();
553
+ }
554
+ isLogScale() {
555
+ return this.viewport.isLogScale();
556
+ }
557
+ setSessionBreaksConfig(e) {
558
+ this.sessionBreaks.setConfig(e), this.engine.requestRender(u.Background);
559
+ }
560
+ getConnectionState() {
561
+ return this.streamManager?.getConnectionState() ?? "disconnected";
562
+ }
563
+ getConnectionInfo() {
564
+ return this.streamManager?.getConnectionInfo() ?? { state: "disconnected" };
565
+ }
566
+ setAutoScroll(e) {
567
+ this.autoScrollOnNewBar = e;
568
+ }
569
+ scrollTo(e) {
570
+ let t = this.dataManager.getData();
571
+ for (let n = 0; n < t.length; n++) if (t[n].time >= e) {
572
+ let e = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
573
+ this.viewport.scrollBy(n * e - this.viewport.getState().offset), this.updateViewportAndRender();
574
+ return;
575
+ }
576
+ }
577
+ scrollToEnd() {
578
+ this.viewport.scrollToEnd(), this.updateViewportAndRender();
579
+ }
580
+ setVisibleRange(e, t) {
581
+ let n = this.dataManager.getData(), r = 0, i = n.length - 1;
582
+ for (let t = 0; t < n.length; t++) if (n[t].time >= e) {
583
+ r = t;
584
+ break;
585
+ }
586
+ for (let e = n.length - 1; e >= 0; e--) if (n[e].time <= t) {
587
+ i = e;
588
+ break;
589
+ }
590
+ let a = i - r + 1;
591
+ if (a > 0) {
592
+ let e = this.viewport.getState().chartRect.width, t = e / a, n = Math.max(2, t - this.viewport.getState().barSpacing);
593
+ this.viewport.zoom((n - this.viewport.getState().barWidth) / this.viewport.getState().barWidth, e / 2);
594
+ }
595
+ this.updateViewportAndRender();
596
+ }
597
+ zoomIn() {
598
+ let e = this.viewport.getState().chartRect.width;
599
+ this.viewport.zoom(.2, e / 2), this.updateViewportAndRender();
600
+ }
601
+ zoomOut() {
602
+ let e = this.viewport.getState().chartRect.width;
603
+ this.viewport.zoom(-.2, e / 2), this.updateViewportAndRender();
604
+ }
605
+ fitContent() {
606
+ let e = this.dataManager.getData();
607
+ e.length !== 0 && this.setVisibleRange(e[0].time, e[e.length - 1].time);
608
+ }
609
+ on(e, t) {
610
+ this.eventBus.on(e, t);
611
+ }
612
+ off(e, t) {
613
+ this.eventBus.off(e, t);
614
+ }
615
+ enableTauriBridge(e) {
616
+ this.eventBus.enableTauriBridge({
617
+ enabled: !0,
618
+ ...e
619
+ });
620
+ }
621
+ disableTauriBridge() {
622
+ this.eventBus.disableTauriBridge();
623
+ }
624
+ setTheme(e) {
625
+ this.themeManager.setTheme(e), this.syncRenderContext(), this.container.style.backgroundColor = this.themeManager.getTheme().background, this.engine.requestRender(), this.eventBus.emit("themeChange", { theme: e });
626
+ }
627
+ getTheme() {
628
+ return this.themeManager.getTheme();
629
+ }
630
+ setWatermark(e, t) {
631
+ this.watermark.setConfig({
632
+ text: e,
633
+ ...t
634
+ }), this.engine.requestRender(u.Background);
635
+ }
636
+ setAutoScale(e) {
637
+ this.options.autoScale = e, this.updateViewportAndRender();
638
+ }
639
+ isAutoScale() {
640
+ return this.options.autoScale !== !1;
641
+ }
642
+ setCrosshairMode(e) {
643
+ this.crosshairHandler.setMode(e), this.engine.requestRender(u.Overlay);
644
+ }
645
+ getCrosshairMode() {
646
+ return this.crosshairHandler.getMode();
647
+ }
648
+ setGridVisible(e) {
649
+ this.gridRenderer.setVisible(e), this.engine.requestRender(u.Background);
650
+ }
651
+ isGridVisible() {
652
+ return this.gridRenderer.isVisible();
653
+ }
654
+ setVolumeVisible(e) {
655
+ this.volumeRenderer.setVisible(e), this.engine.requestRender(u.Main);
656
+ }
657
+ setTooltipVisible(e) {
658
+ e || this.crosshairTooltip.hide();
659
+ }
660
+ setLegend(e) {
661
+ this.chartLegend.setConfig(e), this.engine.requestRender(u.UI);
662
+ }
663
+ setSymbolName(e) {
664
+ this.chartLegend.setSymbol(e), this.engine.requestRender(u.UI);
665
+ }
666
+ screenshot(e) {
667
+ this.features.screenshot && U.download(this.container, e, this.themeManager.getTheme().background);
668
+ }
669
+ screenshotDataURL() {
670
+ return this.features.screenshot ? U.toDataURL(this.container, this.themeManager.getTheme().background) : null;
671
+ }
672
+ async screenshotBlob() {
673
+ return this.features.screenshot ? U.toBlob(this.container, this.themeManager.getTheme().background) : null;
674
+ }
675
+ addAlert(e, t = "crossing", n) {
676
+ if (!this.features.alerts) return null;
677
+ let r = this.alertManager.addAlert(e, t, n);
678
+ return this.scheduleAutoSave(), r;
679
+ }
680
+ removeAlert(e) {
681
+ this.alertManager.removeAlert(e), this.scheduleAutoSave();
682
+ }
683
+ getAlerts() {
684
+ return this.alertManager.getAlerts();
685
+ }
686
+ clearAlerts() {
687
+ this.alertManager.clearAlerts(), this.scheduleAutoSave();
688
+ }
689
+ saveAlerts(e) {
690
+ this.alertManager.saveToStorage(e);
691
+ }
692
+ loadAlerts(e) {
693
+ this.alertManager.loadFromStorage(e), this.engine.requestRender(u.Overlay);
694
+ }
695
+ replay(e) {
696
+ if (!this.features.replay) return;
697
+ let t = this.dataManager.getData();
698
+ this.replayManager.load(t), this.replayManager.on("bar", ({ bar: e, index: n }) => {
699
+ let r = t.slice(0, n + 1);
700
+ this.dataManager.setData(r), this.crosshairHandler.setData(r), this.indicatorEngine.recalculateAll(r), this.updateViewportAndRender();
701
+ }), this.replayManager.play(e);
702
+ }
703
+ replayPause() {
704
+ this.replayManager.pause();
705
+ }
706
+ replayResume() {
707
+ this.replayManager.resume();
708
+ }
709
+ replayStop() {
710
+ this.replayManager.stop();
711
+ }
712
+ replaySeek(e) {
713
+ this.replayManager.seekTo(e);
714
+ }
715
+ setReplaySpeed(e) {
716
+ this.replayManager.setSpeed(e);
717
+ }
718
+ getReplayState() {
719
+ return this.replayManager.getState();
720
+ }
721
+ getReplayProgress() {
722
+ return this.replayManager.getProgress();
723
+ }
724
+ saveState(e) {
725
+ if (!this.features.saveLoad) return null;
726
+ let t = I.capture({
727
+ getDrawings: () => this.getDrawings(),
728
+ getTheme: () => this.getTheme(),
729
+ getAlerts: () => this.getAlerts()
730
+ }, { chartType: this.options.chartType }), n = I.serialize(t);
731
+ return e && I.saveToStorage(e, t), n;
732
+ }
733
+ loadState(e) {
734
+ if (!this.features.saveLoad) return;
735
+ let t = I.deserialize(e);
736
+ if (t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), t.theme && this.setTheme(t.theme), t.alerts) {
737
+ this.clearAlerts();
738
+ for (let e of t.alerts) this.addAlert(e.price, e.condition, e.message);
739
+ }
740
+ }
741
+ loadStateFromStorage(e) {
742
+ if (!this.features.saveLoad) return !1;
743
+ let t = I.loadFromStorage(e);
744
+ return t ? (this.loadState(I.serialize(t)), !0) : !1;
745
+ }
746
+ downloadState(e) {
747
+ if (!this.features.saveLoad) return;
748
+ let t = I.capture({
749
+ getDrawings: () => this.getDrawings(),
750
+ getTheme: () => this.getTheme(),
751
+ getAlerts: () => this.getAlerts()
752
+ }, { chartType: this.options.chartType });
753
+ I.downloadFile(t, e);
754
+ }
755
+ async loadStateFromFile() {
756
+ if (!this.features.saveLoad) return;
757
+ let e = await I.loadFromFile();
758
+ this.loadState(I.serialize(e));
759
+ }
760
+ setLocale(e) {
761
+ b(e), this.engine.requestRender();
762
+ }
763
+ setMarket(e) {
764
+ if (this.marketConfig = e, e.colorScheme) {
765
+ let t = {
766
+ ...this.themeManager.getTheme(),
767
+ candleUp: e.colorScheme.up,
768
+ candleDown: e.colorScheme.down,
769
+ candleUpWick: e.colorScheme.up,
770
+ candleDownWick: e.colorScheme.down,
771
+ volumeUp: e.colorScheme.up.replace(")", ", 0.3)").replace("rgb(", "rgba(") || `${e.colorScheme.up}4D`,
772
+ volumeDown: e.colorScheme.down.replace(")", ", 0.3)").replace("rgb(", "rgba(") || `${e.colorScheme.down}4D`
773
+ };
774
+ this.themeManager.setTheme(t);
775
+ }
776
+ e.pricePrecision !== void 0 && (this.tradingManager.setConfig({ pricePrecision: e.pricePrecision }), this.alertManager.setPricePrecision(e.pricePrecision), this.streamManager?.priceLine.setPricePrecision(e.pricePrecision), this.crosshairHandler.setPricePrecision(e.pricePrecision)), this.syncRenderContext(), this.engine.requestRender();
777
+ }
778
+ getMarket() {
779
+ return this.marketConfig;
780
+ }
781
+ setPriceLimits(e) {
782
+ this.marketConfig && (v(e, this.marketConfig) && (this.marketConfig.priceLimits = {
783
+ ...this.marketConfig.priceLimits,
784
+ referencePrice: e
785
+ }), this.engine.requestRender());
786
+ }
787
+ getFeatures() {
788
+ return this.features;
789
+ }
790
+ setFeatures(e) {
791
+ Object.assign(this.features, e), e.crosshair === !1 && this.crosshairTooltip.hide(), e.grid !== void 0 && this.engine.requestRender(u.Background), e.volume !== void 0 && (this.volumeRenderer.setVisible(e.volume), this.engine.requestRender(u.Main)), e.drawings === !1 && this.drawingManager.setActiveTool(null), e.trading === !1 && (this.tradingManager.setOrders([]), this.tradingManager.setPositions([])), this.engine.requestRender();
792
+ }
793
+ resize() {
794
+ let e = this.engine.dprManager.readContainerSize();
795
+ if (e.width <= 0 || e.height <= 0) return;
796
+ this.containerSizeCache = e, this.containerSizeCacheTime = Date.now();
797
+ let t = this.engine.dprManager.getDpr();
798
+ this.engine.layerManager.resize(e, t);
799
+ let n = this.viewport.isAtEnd();
800
+ this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(n), this.eventBus.emit("resize", e);
801
+ }
802
+ destroy() {
803
+ this.countdownInterval && clearInterval(this.countdownInterval), this.disableAutoSave(), this.disconnectStream(), this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.replayManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
804
+ }
805
+ createChartRenderer(e) {
806
+ switch (e) {
807
+ case "candlestick": return new M();
808
+ case "heikinAshi": return new M();
809
+ case "line": return new je();
810
+ case "area": return new E();
811
+ case "bar": return new k();
812
+ case "hollowCandle": return new Te();
813
+ case "baseline": return new A();
814
+ case "renko": return new Le();
815
+ case "lineBreak": return new M();
816
+ case "kagi": return new Oe();
817
+ case "pointAndFigure": return new Pe();
818
+ default: return new M();
819
+ }
820
+ }
821
+ getDisplayData() {
822
+ if (this.displayDataCache) return this.displayDataCache;
823
+ let e = this.dataManager.getData();
824
+ if (e.length === 0) return e;
825
+ let t;
826
+ switch (this.options.chartType) {
827
+ case "heikinAshi":
828
+ t = at(e);
829
+ break;
830
+ case "renko":
831
+ t = ft(e, {
832
+ brickSize: 0,
833
+ useATR: !0,
834
+ atrPeriod: 14
835
+ });
836
+ break;
837
+ case "lineBreak":
838
+ t = lt(e, 3);
839
+ break;
840
+ case "kagi":
841
+ t = st(e, 4);
842
+ break;
843
+ case "pointAndFigure":
844
+ t = ut(e, e.reduce((e, t) => e + t.close, 0) / e.length * .01, 3);
845
+ break;
846
+ default: t = e;
847
+ }
848
+ return this.displayDataCache = t, t;
849
+ }
850
+ scheduleRender() {
851
+ this.renderScheduled || (this.renderScheduled = !0, requestAnimationFrame(() => {
852
+ this.renderScheduled = !1;
853
+ let e = this.getDisplayData();
854
+ this.viewport.updateData(e, this.options.autoScale !== !1), this.syncRenderContext(), this.engine.requestRender();
855
+ }));
856
+ }
857
+ updateViewportAndRender(e = !1) {
858
+ this.resolvedLayoutCache = null, this.panelInfoCache = null;
859
+ let t = this.getResolvedLayout();
860
+ this.viewport.setChartRect(t.mainChartRect);
861
+ let n = this.getDisplayData();
862
+ this.viewport.updateData(n, this.options.autoScale !== !1), e && this.viewport.scrollToEnd(), this.syncRenderContext(), this.engine.requestRender();
863
+ }
864
+ getResolvedLayout() {
865
+ return this.resolvedLayoutCache ||= this.layoutManager.resolve(), this.resolvedLayoutCache;
866
+ }
867
+ cachedContainerSize() {
868
+ let e = Date.now();
869
+ return (!this.containerSizeCache || e - this.containerSizeCacheTime > 500) && (this.containerSizeCache = this.engine.dprManager.getContainerSize(), this.containerSizeCacheTime = e), this.containerSizeCache;
870
+ }
871
+ buildPanelRenderInfos() {
872
+ if (this.panelInfoCache) return this.panelInfoCache;
873
+ let e = this.getResolvedLayout(), t = this.viewport.getState(), n = e.panels.map((e) => {
874
+ let n = this.indicatorEngine.getOutput(e.config.id), r = 0, i = 100;
875
+ if (n) {
876
+ let e = Infinity, a = -Infinity, { from: o, to: s } = t.visibleRange, c = 0;
877
+ for (let [, t] of n.values) {
878
+ if (c >= o && c <= s) for (let n in t) {
879
+ let r = t[n];
880
+ r !== void 0 && (r < e && (e = r), r > a && (a = r));
881
+ }
882
+ c++;
883
+ }
884
+ if (e !== Infinity) {
885
+ let t = a - e || 1;
886
+ r = e - t * .1, i = a + t * .1;
887
+ }
888
+ }
889
+ let a = {
890
+ x: e.rect.x,
891
+ y: e.rect.y + 20,
892
+ width: e.rect.width,
893
+ height: Math.max(0, e.rect.height - 20)
894
+ };
895
+ return {
896
+ instanceId: e.config.id,
897
+ rect: e.rect,
898
+ viewport: {
899
+ ...t,
900
+ chartRect: a,
901
+ priceRange: {
902
+ min: r,
903
+ max: i
904
+ }
905
+ }
906
+ };
907
+ });
908
+ return this.panelInfoCache = n, n;
909
+ }
910
+ syncRenderContext() {
911
+ let e = this.getResolvedLayout(), t = this.features.indicators ? this.buildPanelRenderInfos() : [], n = e.panels.filter((e) => e.config.position === "bottom").reduce((e, t) => e + t.rect.height, 0), r = e.mainChartRect.y + e.mainChartRect.height + n;
912
+ this.engine.setRenderContext({
913
+ chartRenderer: this.chartRenderer,
914
+ gridRenderer: this.features.grid ? this.gridRenderer : null,
915
+ priceAxis: this.features.priceAxis ? this.priceAxis : null,
916
+ timeAxis: this.features.timeAxis ? this.timeAxis : null,
917
+ crosshairHandler: this.features.crosshair ? this.crosshairHandler : null,
918
+ indicatorEngine: this.features.indicators ? this.indicatorEngine : null,
919
+ drawingRenderer: this.features.drawings ? this.drawingRenderer : null,
920
+ tradingRenderer: this.features.trading ? this.tradingRenderer : null,
921
+ currentPriceLine: this.streamManager?.priceLine ?? this.currentPriceLine,
922
+ chartLegend: this.features.legend ? this.chartLegend : null,
923
+ volumeRenderer: this.features.volume ? this.volumeRenderer : null,
924
+ watermark: this.features.watermark ? this.watermark : null,
925
+ barCountdown: this.barCountdown,
926
+ sessionBreaks: this.sessionBreaks,
927
+ compareRenderer: this.compareRenderer,
928
+ panels: t,
929
+ priceLimits: this.buildPriceLimits(),
930
+ timeAxisY: r,
931
+ viewport: this.viewport.getState(),
932
+ theme: this.themeManager.getTheme(),
933
+ data: this.getDisplayData()
934
+ });
935
+ }
936
+ timeframeToMs(e) {
937
+ let t = e.match(/^(\d+)([smhdwMy])$/);
938
+ if (!t) return 0;
939
+ let n = parseInt(t[1], 10);
940
+ switch (t[2]) {
941
+ case "s": return n * 1e3;
942
+ case "m": return n * 6e4;
943
+ case "h": return n * 36e5;
944
+ case "d": return n * 864e5;
945
+ case "w": return n * 6048e5;
946
+ case "M": return n * 2592e6;
947
+ default: return 0;
948
+ }
949
+ }
950
+ buildPriceLimits() {
951
+ if (!this.marketConfig?.priceLimits?.enabled || !this.marketConfig.priceLimits.referencePrice) return null;
952
+ let e = v(this.marketConfig.priceLimits.referencePrice, this.marketConfig);
953
+ return e ? {
954
+ ...e,
955
+ colors: this.marketConfig.colorScheme ? {
956
+ ceiling: this.marketConfig.colorScheme.ceiling,
957
+ floor: this.marketConfig.colorScheme.floor,
958
+ reference: this.marketConfig.colorScheme.reference
959
+ } : void 0
960
+ } : null;
961
+ }
962
+ };
963
+ //#endregion
964
+ export { S as AlertManager, w as Animator, D as BarCountdown, j as BinanceAdapter, pt as Chart, N as ChartLegend, F as ChartStateManager, L as CompareRenderer, B as CrosshairTooltip, he as CurrentPriceLine, e as DARK_THEME, n as DEFAULT_DRAWING_STYLE, _e as DEFAULT_LEGEND_CONFIG, i as DEFAULT_RECONNECT, a as DEFAULT_STREAM_CONFIG, o as DEFAULT_TIMEFRAME_FAVORITES, s as DEFAULT_TRADING_CONFIG, ve as DataExporter, J as DataManager, ye as DrawingBase, Se as Easing, Ee as IndicatorBase, ke as KeyboardHandler, c as LIGHT_THEME, Q as LayoutManager, d as MARKET_CRYPTO, f as MARKET_HNX, ee as MARKET_HOSE, p as MARKET_NYSE, te as MARKET_UPCOM, Me as MockAdapter, $ as PluginManager, Re as ReplayManager, Be as Screenshot, Ve as SessionBreaks, Ue as StreamManager, g as TIMEFRAMES_CRYPTO, ne as TIMEFRAMES_FOREX, re as TIMEFRAMES_STOCK, Y as ThemeManager, Ge as TickAggregator, Ye as UndoRedoManager, ie as VN_COLORS, Qe as VolumeRenderer, et as Watermark, ae as computePriceLimits, oe as createVNTheme, se as formatNumber, ce as formatVND, le as formatVolumeLoc, ue as getCurrentSession, de as getLocale, pe as registerLocale, y as setLocale, x as t, it as toHeikinAshi, ot as toKagi, ct as toLineBreak, G as toPointAndFigure, dt as toRenko };
965
+
966
+ //# sourceMappingURL=index.js.map