@tradecanvas/chart 0.2.0 → 0.4.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 +30 -1
- package/dist/Chart.d.ts +10 -0
- package/dist/Chart.d.ts.map +1 -1
- package/dist/finance/GaugeChart.d.ts +18 -0
- package/dist/finance/GaugeChart.d.ts.map +1 -0
- package/dist/finance/WaterfallChart.d.ts +12 -0
- package/dist/finance/WaterfallChart.d.ts.map +1 -0
- package/dist/finance/index.d.ts +2 -0
- package/dist/finance/index.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +134 -38
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
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 _, TIMEFRAMES_STOCK as ne, TIME_AXIS_HEIGHT as v, VN_COLORS as re, computePriceLimits as ie, computePriceLimits as y, createVNTheme as ae, formatNumber as oe, formatVND as se, formatVolumeLoc as ce, getCurrentSession as le, getLocale as ue, mergeBar as de, registerLocale as fe, setLocale as pe, setLocale as me, t as b } from "@tradecanvas/commons";
|
|
2
|
-
import { AlertManager as x, AlertManager as S, Animator as C, Animator as w, AreaRenderer as T, BarCountdown as E, BarCountdown as D, BarRenderer as O, BaseFinanceChart 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 he, CrosshairTooltip as ge, CurrentPriceLine as _e, CurrentPriceLine as ve, DEFAULT_LEGEND_CONFIG as ye, DataExporter as be, DataExporter as B, DrawingBase as xe, DrawingManager as Se, DrawingRenderer as Ce, Easing as we, EventBus as Te, FinanceCrosshair as V, GridRenderer as Ee, HollowCandleRenderer as De, IndicatorBase as Oe, IndicatorEngine as H, InteractionManager as ke, KagiRenderer as Ae, KeyboardHandler as je, KeyboardHandler as Me, LineRenderer as Ne, MockAdapter as Pe, PanHandler as Fe, PointAndFigureRenderer as Ie, PriceAxis as Le, RenderEngine as Re, RenkoRenderer as ze, ReplayManager as Be, ReplayManager as Ve, Screenshot as He, Screenshot as U, SessionBreaks as Ue, SessionBreaks as We, StreamManager as Ge, StreamManager as Ke, TickAggregator as qe, TimeAxis as Je, TradingManager as Ye, TradingRenderer as Xe, UndoRedoManager as Ze, UndoRedoManager as Qe, Viewport as $e, VolumeRenderer as et, VolumeRenderer as tt, Watermark as nt, Watermark as rt, ZoomHandler as it, layoutSquarifiedTreemap as at, layoutUniformGrid as ot, registerBuiltInDrawingTools as st, registerBuiltInIndicators as W, renderDepthChart as ct, renderEquityCurve as lt,
|
|
2
|
+
import { AlertManager as x, AlertManager as S, Animator as C, Animator as w, AreaRenderer as T, BarCountdown as E, BarCountdown as D, BarRenderer as O, BaseFinanceChart 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 he, CrosshairTooltip as ge, CurrentPriceLine as _e, CurrentPriceLine as ve, DEFAULT_LEGEND_CONFIG as ye, DataExporter as be, DataExporter as B, DrawingBase as xe, DrawingManager as Se, DrawingRenderer as Ce, Easing as we, EventBus as Te, FinanceCrosshair as V, GridRenderer as Ee, HollowCandleRenderer as De, IndicatorBase as Oe, IndicatorEngine as H, InteractionManager as ke, KagiRenderer as Ae, KeyboardHandler as je, KeyboardHandler as Me, LineRenderer as Ne, MockAdapter as Pe, PanHandler as Fe, PointAndFigureRenderer as Ie, PriceAxis as Le, RenderEngine as Re, RenkoRenderer as ze, ReplayManager as Be, ReplayManager as Ve, Screenshot as He, Screenshot as U, SessionBreaks as Ue, SessionBreaks as We, StreamManager as Ge, StreamManager as Ke, TickAggregator as qe, TimeAxis as Je, TradingManager as Ye, TradingRenderer as Xe, UndoRedoManager as Ze, UndoRedoManager as Qe, Viewport as $e, VolumeRenderer as et, VolumeRenderer as tt, Watermark as nt, Watermark as rt, ZoomHandler as it, layoutSquarifiedTreemap as at, layoutUniformGrid as ot, registerBuiltInDrawingTools as st, registerBuiltInIndicators as W, renderDepthChart as ct, renderEquityCurve as lt, renderGauge as ut, renderHeatmap as dt, renderSparkline as ft, renderWaterfall as pt, toHeikinAshi as mt, toHeikinAshi as ht, toKagi as gt, toKagi as _t, toLineBreak as vt, toLineBreak as yt, toPointAndFigure as bt, toPointAndFigure as xt, toRenko as St, toRenko as Ct } from "@tradecanvas/core";
|
|
3
3
|
//#region src/DataManager.ts
|
|
4
|
-
function
|
|
4
|
+
function G(e) {
|
|
5
5
|
if (!e || typeof e.time != "number") return !1;
|
|
6
6
|
let { open: t, high: n, low: r, close: i } = e;
|
|
7
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
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function K(e) {
|
|
10
10
|
return {
|
|
11
11
|
...e,
|
|
12
12
|
high: Math.max(e.open, e.high, e.low, e.close),
|
|
@@ -14,20 +14,20 @@ function q(e) {
|
|
|
14
14
|
volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
var
|
|
17
|
+
var q = class {
|
|
18
18
|
data = [];
|
|
19
19
|
getData() {
|
|
20
20
|
return this.data;
|
|
21
21
|
}
|
|
22
22
|
setData(e) {
|
|
23
|
-
this.data = e.filter(
|
|
23
|
+
this.data = e.filter(G).map(K);
|
|
24
24
|
}
|
|
25
25
|
appendBar(e) {
|
|
26
|
-
|
|
26
|
+
G(e) && this.data.push(K(e));
|
|
27
27
|
}
|
|
28
28
|
updateLastBar(e) {
|
|
29
|
-
if (!
|
|
30
|
-
let t =
|
|
29
|
+
if (!G(e)) return;
|
|
30
|
+
let t = K(e);
|
|
31
31
|
if (this.data.length === 0) {
|
|
32
32
|
this.data.push(t);
|
|
33
33
|
return;
|
|
@@ -43,7 +43,7 @@ var J = class {
|
|
|
43
43
|
clear() {
|
|
44
44
|
this.data = [];
|
|
45
45
|
}
|
|
46
|
-
},
|
|
46
|
+
}, J = class {
|
|
47
47
|
theme;
|
|
48
48
|
constructor(e) {
|
|
49
49
|
!e || e === "dark" ? this.theme = { ...t } : e === "light" ? this.theme = { ...l } : this.theme = { ...e };
|
|
@@ -54,7 +54,7 @@ var J = class {
|
|
|
54
54
|
setTheme(e) {
|
|
55
55
|
e === "dark" ? this.theme = { ...t } : e === "light" ? this.theme = { ...l } : this.theme = { ...e };
|
|
56
56
|
}
|
|
57
|
-
},
|
|
57
|
+
}, Y = 200, X = 80, Z = class {
|
|
58
58
|
panels = [];
|
|
59
59
|
containerWidth = 0;
|
|
60
60
|
containerHeight = 0;
|
|
@@ -66,8 +66,8 @@ var J = class {
|
|
|
66
66
|
this.panels.push({
|
|
67
67
|
id: e,
|
|
68
68
|
position: t,
|
|
69
|
-
size: n ?? (i ?
|
|
70
|
-
minSize: i ?
|
|
69
|
+
size: n ?? (i ? Y : r),
|
|
70
|
+
minSize: i ? X : m,
|
|
71
71
|
content: {
|
|
72
72
|
type: "indicator",
|
|
73
73
|
indicatorInstanceId: e
|
|
@@ -81,7 +81,7 @@ var J = class {
|
|
|
81
81
|
let n = this.panels.find((t) => t.id === e);
|
|
82
82
|
if (n) {
|
|
83
83
|
let e = n.position === "left" || n.position === "right", i = t === "left" || t === "right";
|
|
84
|
-
n.position = t, e !== i && (n.size = i ?
|
|
84
|
+
n.position = t, e !== i && (n.size = i ? Y : r, n.minSize = i ? X : m);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
setPanelSize(e, t) {
|
|
@@ -182,14 +182,14 @@ var J = class {
|
|
|
182
182
|
getMainChartRect() {
|
|
183
183
|
return this.resolve().mainChartRect;
|
|
184
184
|
}
|
|
185
|
-
},
|
|
185
|
+
}, Q = class {
|
|
186
186
|
constructor(e) {
|
|
187
187
|
this.indicatorEngine = e;
|
|
188
188
|
}
|
|
189
189
|
registerIndicator(e) {
|
|
190
190
|
this.indicatorEngine.register(e);
|
|
191
191
|
}
|
|
192
|
-
},
|
|
192
|
+
}, wt = class {
|
|
193
193
|
static version = "0.3.0";
|
|
194
194
|
engine;
|
|
195
195
|
viewport;
|
|
@@ -237,8 +237,11 @@ var J = class {
|
|
|
237
237
|
marketConfig = null;
|
|
238
238
|
container;
|
|
239
239
|
currentPriceLine;
|
|
240
|
+
numberLocale;
|
|
241
|
+
keyboardHandler = null;
|
|
242
|
+
onWindowKeyDown = null;
|
|
240
243
|
constructor(e, t) {
|
|
241
|
-
this.container = e, this.options = t;
|
|
244
|
+
this.container = e, this.options = t, this.numberLocale = t.numberLocale ?? "en-US";
|
|
242
245
|
let n = t.features ?? {};
|
|
243
246
|
this.features = {
|
|
244
247
|
drawings: n.drawings ?? !0,
|
|
@@ -270,7 +273,7 @@ var J = class {
|
|
|
270
273
|
logScale: n.logScale ?? !0,
|
|
271
274
|
timeframes: n.timeframes ?? [],
|
|
272
275
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
273
|
-
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", this.dataManager = new
|
|
276
|
+
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", this.dataManager = new q(), this.themeManager = new J(t.theme), this.layoutManager = new Z(), this.indicatorEngine = new H(), this.pluginManager = new Q(this.indicatorEngine), this.eventBus = new Te(), W(this.indicatorEngine), this.drawingManager = new Se(), st(this.drawingManager), this.drawingRenderer = new Ce(this.drawingManager), this.drawingManager.setRequestRender(() => {
|
|
274
277
|
this.syncRenderContext(), this.engine.requestRender(u.Overlay), this.scheduleAutoSave();
|
|
275
278
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
276
279
|
this.eventBus.emit(e, t);
|
|
@@ -282,7 +285,7 @@ var J = class {
|
|
|
282
285
|
if (e.width <= 0 || e.height <= 0) return;
|
|
283
286
|
let t = this.viewport.isAtEnd();
|
|
284
287
|
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 Ee(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new Le(), this.timeAxis = new Je(), this.crosshairHandler = new z(), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
|
|
288
|
+
}, this.chartRenderer = this.createChartRenderer(t.chartType), this.gridRenderer = new Ee(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new Le(), this.priceAxis.setLocale(this.numberLocale), this.timeAxis = new Je(), this.crosshairHandler = new z(), this.crosshairHandler.setLocale(this.numberLocale), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
|
|
286
289
|
if (e !== null && t) {
|
|
287
290
|
let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
|
|
288
291
|
this.chartLegend.setHoverBar(r ?? null), r && this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize()), this.eventBus.emit("crosshairMove", {
|
|
@@ -296,7 +299,7 @@ var J = class {
|
|
|
296
299
|
color: t.sessionBreaks.color,
|
|
297
300
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
298
301
|
lineWidth: t.sessionBreaks.lineWidth
|
|
299
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.viewport.setLogScale(!0), this.animator = new w(), this.crosshairTooltip = new ge(), this.crosshairTooltip.create(e), new Me({
|
|
302
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.viewport.setLogScale(!0), this.animator = new w(), this.crosshairTooltip = new ge(), this.crosshairTooltip.create(e), this.keyboardHandler = new Me({
|
|
300
303
|
scrollBars: (e) => {
|
|
301
304
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
302
305
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -312,7 +315,11 @@ var J = class {
|
|
|
312
315
|
this.viewport.scrollToEnd(), this.updateViewportAndRender();
|
|
313
316
|
},
|
|
314
317
|
fitContent: () => this.fitContent()
|
|
315
|
-
}), this.
|
|
318
|
+
}), this.keyboardHandler.setEnabled(this.features.keyboard), this.onWindowKeyDown = (e) => {
|
|
319
|
+
if (!this.keyboardHandler) return;
|
|
320
|
+
let t = document.activeElement;
|
|
321
|
+
t && t !== this.container && !this.container.contains(t) || t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable) || this.keyboardHandler.handleKey(e) && e.preventDefault();
|
|
322
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new ve(), this.alertManager = new S(), this.alertManager.setRequestRender(() => this.engine.requestRender(u.Overlay)), this.alertManager.on("triggered", (e) => {
|
|
316
323
|
this.eventBus.emit("dataUpdate", {
|
|
317
324
|
alert: "triggered",
|
|
318
325
|
alertId: e.id,
|
|
@@ -334,10 +341,10 @@ var J = class {
|
|
|
334
341
|
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
342
|
}
|
|
336
343
|
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();
|
|
344
|
+
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.indicatorEngine.recalculateAll(this.dataManager.getData()), this.scheduleRender();
|
|
338
345
|
}
|
|
339
346
|
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();
|
|
347
|
+
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.indicatorEngine.recalculateAll(this.dataManager.getData()), this.scheduleRender();
|
|
341
348
|
}
|
|
342
349
|
setChartType(e) {
|
|
343
350
|
this.options.chartType = e, this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.updateViewportAndRender(!0);
|
|
@@ -503,7 +510,7 @@ var J = class {
|
|
|
503
510
|
}), this.streamManager.on("barClose", (e) => {
|
|
504
511
|
this.dataManager.appendBar(e), this.crosshairHandler.setData(this.dataManager.getData()), this.autoScrollOnNewBar && this.viewport.scrollToEnd(), this.indicatorEngine.recalculateAll(this.dataManager.getData()), this.updateViewportAndRender();
|
|
505
512
|
}), this.streamManager.on("barUpdate", (e) => {
|
|
506
|
-
this.dataManager.updateLastBar(e), this.currentPriceLine.setPrice(e.close), this.scheduleRender();
|
|
513
|
+
this.dataManager.updateLastBar(e), this.currentPriceLine.setPrice(e.close), this.indicatorEngine.recalculateAll(this.dataManager.getData()), this.scheduleRender();
|
|
507
514
|
}), this.streamManager.on("priceChange", ({ price: e }) => {
|
|
508
515
|
this.tradingManager.setCurrentPrice(e), this.currentPriceLine.setPrice(e), this.engine.requestRender(u.Overlay), this.engine.requestRender(u.UI);
|
|
509
516
|
}), this.streamManager.on("connectionChange", (e) => {
|
|
@@ -761,6 +768,12 @@ var J = class {
|
|
|
761
768
|
setLocale(e) {
|
|
762
769
|
me(e), this.engine.requestRender();
|
|
763
770
|
}
|
|
771
|
+
setNumberLocale(e) {
|
|
772
|
+
this.numberLocale = e, this.priceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.syncRenderContext(), this.engine.requestRender();
|
|
773
|
+
}
|
|
774
|
+
getNumberLocale() {
|
|
775
|
+
return this.numberLocale;
|
|
776
|
+
}
|
|
764
777
|
setMarket(e) {
|
|
765
778
|
if (this.marketConfig = e, e.colorScheme) {
|
|
766
779
|
let t = {
|
|
@@ -789,7 +802,7 @@ var J = class {
|
|
|
789
802
|
return this.features;
|
|
790
803
|
}
|
|
791
804
|
setFeatures(e) {
|
|
792
|
-
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();
|
|
805
|
+
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([])), e.keyboard !== void 0 && this.keyboardHandler?.setEnabled(e.keyboard), this.engine.requestRender();
|
|
793
806
|
}
|
|
794
807
|
resize() {
|
|
795
808
|
let e = this.engine.dprManager.readContainerSize();
|
|
@@ -801,7 +814,7 @@ var J = class {
|
|
|
801
814
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(n), this.eventBus.emit("resize", e);
|
|
802
815
|
}
|
|
803
816
|
destroy() {
|
|
804
|
-
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 = "";
|
|
817
|
+
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.replayManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
|
|
805
818
|
}
|
|
806
819
|
createChartRenderer(e) {
|
|
807
820
|
switch (e) {
|
|
@@ -826,23 +839,23 @@ var J = class {
|
|
|
826
839
|
let t;
|
|
827
840
|
switch (this.options.chartType) {
|
|
828
841
|
case "heikinAshi":
|
|
829
|
-
t =
|
|
842
|
+
t = ht(e);
|
|
830
843
|
break;
|
|
831
844
|
case "renko":
|
|
832
|
-
t =
|
|
845
|
+
t = Ct(e, {
|
|
833
846
|
brickSize: 0,
|
|
834
847
|
useATR: !0,
|
|
835
848
|
atrPeriod: 14
|
|
836
849
|
});
|
|
837
850
|
break;
|
|
838
851
|
case "lineBreak":
|
|
839
|
-
t =
|
|
852
|
+
t = yt(e, 3);
|
|
840
853
|
break;
|
|
841
854
|
case "kagi":
|
|
842
|
-
t =
|
|
855
|
+
t = _t(e, 4);
|
|
843
856
|
break;
|
|
844
857
|
case "pointAndFigure":
|
|
845
|
-
t =
|
|
858
|
+
t = xt(e, e.reduce((e, t) => e + t.close, 0) / e.length * .01, 3);
|
|
846
859
|
break;
|
|
847
860
|
default: t = e;
|
|
848
861
|
}
|
|
@@ -941,7 +954,8 @@ var J = class {
|
|
|
941
954
|
timeAxisY: r,
|
|
942
955
|
viewport: this.viewport.getState(),
|
|
943
956
|
theme: this.themeManager.getTheme(),
|
|
944
|
-
data: this.getDisplayData()
|
|
957
|
+
data: this.getDisplayData(),
|
|
958
|
+
numberLocale: this.numberLocale
|
|
945
959
|
});
|
|
946
960
|
}
|
|
947
961
|
timeframeToMs(e) {
|
|
@@ -970,13 +984,13 @@ var J = class {
|
|
|
970
984
|
} : void 0
|
|
971
985
|
} : null;
|
|
972
986
|
}
|
|
973
|
-
},
|
|
987
|
+
}, Tt = class extends k {
|
|
974
988
|
options;
|
|
975
989
|
constructor(e, t) {
|
|
976
990
|
super(e, t.theme), this.options = t, this.requestRender();
|
|
977
991
|
}
|
|
978
992
|
renderChart(e, t, n, r) {
|
|
979
|
-
|
|
993
|
+
ft(e, t, n, this.options, r);
|
|
980
994
|
}
|
|
981
995
|
update(e) {
|
|
982
996
|
this.options = {
|
|
@@ -990,7 +1004,7 @@ var J = class {
|
|
|
990
1004
|
...e
|
|
991
1005
|
}, this.requestRender();
|
|
992
1006
|
}
|
|
993
|
-
},
|
|
1007
|
+
}, $ = class extends k {
|
|
994
1008
|
options;
|
|
995
1009
|
crosshair = null;
|
|
996
1010
|
constructor(e, t) {
|
|
@@ -1015,7 +1029,7 @@ var J = class {
|
|
|
1015
1029
|
destroy() {
|
|
1016
1030
|
this.crosshair?.destroy(), super.destroy();
|
|
1017
1031
|
}
|
|
1018
|
-
},
|
|
1032
|
+
}, Et = class extends k {
|
|
1019
1033
|
options;
|
|
1020
1034
|
crosshair = null;
|
|
1021
1035
|
constructor(e, t) {
|
|
@@ -1043,7 +1057,7 @@ var J = class {
|
|
|
1043
1057
|
destroy() {
|
|
1044
1058
|
this.crosshair?.destroy(), super.destroy();
|
|
1045
1059
|
}
|
|
1046
|
-
},
|
|
1060
|
+
}, Dt = class extends k {
|
|
1047
1061
|
options;
|
|
1048
1062
|
crosshair = null;
|
|
1049
1063
|
cachedRects = [];
|
|
@@ -1082,7 +1096,7 @@ var J = class {
|
|
|
1082
1096
|
renderChart(e, t, n, r) {
|
|
1083
1097
|
(t !== this.lastLayoutWidth || n !== this.lastLayoutHeight) && this.recomputeLayout();
|
|
1084
1098
|
let i = this.crosshair?.getPosition() ?? null;
|
|
1085
|
-
|
|
1099
|
+
dt(e, t, n, this.currentData, this.cachedRects, this.options, r, i);
|
|
1086
1100
|
}
|
|
1087
1101
|
update(e) {
|
|
1088
1102
|
this.currentData = e, this.options = {
|
|
@@ -1099,8 +1113,90 @@ var J = class {
|
|
|
1099
1113
|
destroy() {
|
|
1100
1114
|
this.crosshair?.destroy(), this.handleClick && this.canvas.removeEventListener("click", this.handleClick), super.destroy();
|
|
1101
1115
|
}
|
|
1116
|
+
}, Ot = class extends k {
|
|
1117
|
+
options;
|
|
1118
|
+
crosshair = null;
|
|
1119
|
+
constructor(e, t) {
|
|
1120
|
+
super(e, t.theme), this.options = t, t.crosshair !== !1 && (this.crosshair = new V(this.canvas, () => this.requestRender())), this.requestRender();
|
|
1121
|
+
}
|
|
1122
|
+
renderChart(e, t, n, r) {
|
|
1123
|
+
let i = this.crosshair?.getPosition() ?? null;
|
|
1124
|
+
pt(e, t, n, this.options, r, i);
|
|
1125
|
+
}
|
|
1126
|
+
update(e) {
|
|
1127
|
+
this.options = {
|
|
1128
|
+
...this.options,
|
|
1129
|
+
data: e
|
|
1130
|
+
}, this.requestRender();
|
|
1131
|
+
}
|
|
1132
|
+
setOptions(e) {
|
|
1133
|
+
this.options = {
|
|
1134
|
+
...this.options,
|
|
1135
|
+
...e
|
|
1136
|
+
}, this.requestRender();
|
|
1137
|
+
}
|
|
1138
|
+
destroy() {
|
|
1139
|
+
this.crosshair?.destroy(), super.destroy();
|
|
1140
|
+
}
|
|
1141
|
+
}, kt = 500;
|
|
1142
|
+
function At(e) {
|
|
1143
|
+
let t = 1 - e;
|
|
1144
|
+
return 1 - t * t * t;
|
|
1145
|
+
}
|
|
1146
|
+
var jt = class extends k {
|
|
1147
|
+
options;
|
|
1148
|
+
currentValue;
|
|
1149
|
+
targetValue;
|
|
1150
|
+
animationStart = null;
|
|
1151
|
+
animationFrom = 0;
|
|
1152
|
+
animationFrameId = null;
|
|
1153
|
+
constructor(e, t) {
|
|
1154
|
+
super(e, t.theme), this.options = t, this.currentValue = t.value, this.targetValue = t.value, this.requestRender();
|
|
1155
|
+
}
|
|
1156
|
+
renderChart(e, t, n, r) {
|
|
1157
|
+
ut(e, t, n, this.options, r, this.currentValue);
|
|
1158
|
+
}
|
|
1159
|
+
setValue(e) {
|
|
1160
|
+
if (this.options.animate === !1) {
|
|
1161
|
+
this.cancelAnimation(), this.currentValue = e, this.targetValue = e, this.options = {
|
|
1162
|
+
...this.options,
|
|
1163
|
+
value: e
|
|
1164
|
+
}, this.requestRender();
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
this.targetValue = e, this.animationFrom = this.currentValue, this.animationStart = performance.now(), this.options = {
|
|
1168
|
+
...this.options,
|
|
1169
|
+
value: e
|
|
1170
|
+
}, this.startAnimationLoop();
|
|
1171
|
+
}
|
|
1172
|
+
setOptions(e) {
|
|
1173
|
+
let t = {
|
|
1174
|
+
...this.options,
|
|
1175
|
+
...e
|
|
1176
|
+
};
|
|
1177
|
+
if (e.value !== void 0 && e.value !== this.targetValue) {
|
|
1178
|
+
this.options = t, this.setValue(e.value);
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
this.options = t, this.requestRender();
|
|
1182
|
+
}
|
|
1183
|
+
startAnimationLoop() {
|
|
1184
|
+
if (this.animationFrameId !== null) return;
|
|
1185
|
+
let e = () => {
|
|
1186
|
+
if (this.animationFrameId = null, this.animationStart === null) return;
|
|
1187
|
+
let t = this.options.animationDuration ?? kt, n = performance.now() - this.animationStart, r = Math.min(1, n / Math.max(1, t)), i = At(r);
|
|
1188
|
+
this.currentValue = this.animationFrom + (this.targetValue - this.animationFrom) * i, this.requestRender(), r < 1 ? this.animationFrameId = requestAnimationFrame(e) : (this.currentValue = this.targetValue, this.animationStart = null);
|
|
1189
|
+
};
|
|
1190
|
+
this.animationFrameId = requestAnimationFrame(e);
|
|
1191
|
+
}
|
|
1192
|
+
cancelAnimation() {
|
|
1193
|
+
this.animationFrameId !== null && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null), this.animationStart = null;
|
|
1194
|
+
}
|
|
1195
|
+
destroy() {
|
|
1196
|
+
this.cancelAnimation(), super.destroy();
|
|
1197
|
+
}
|
|
1102
1198
|
};
|
|
1103
1199
|
//#endregion
|
|
1104
|
-
export { x as AlertManager, C as Animator, E as BarCountdown, j as BinanceAdapter,
|
|
1200
|
+
export { x as AlertManager, C as Animator, E as BarCountdown, j as BinanceAdapter, wt as Chart, N as ChartLegend, F as ChartStateManager, L as CompareRenderer, he as CrosshairTooltip, _e as CurrentPriceLine, e as DARK_THEME, n as DEFAULT_DRAWING_STYLE, ye as DEFAULT_LEGEND_CONFIG, i as DEFAULT_RECONNECT, a as DEFAULT_STREAM_CONFIG, o as DEFAULT_TIMEFRAME_FAVORITES, s as DEFAULT_TRADING_CONFIG, be as DataExporter, q as DataManager, $ as DepthChart, xe as DrawingBase, we as Easing, Et as EquityCurveChart, jt as GaugeChart, Dt as HeatmapChart, Oe as IndicatorBase, je as KeyboardHandler, c as LIGHT_THEME, Z as LayoutManager, d as MARKET_CRYPTO, f as MARKET_HNX, ee as MARKET_HOSE, p as MARKET_NYSE, te as MARKET_UPCOM, Pe as MockAdapter, Q as PluginManager, Be as ReplayManager, He as Screenshot, Ue as SessionBreaks, Tt as SparklineChart, Ge as StreamManager, g as TIMEFRAMES_CRYPTO, _ as TIMEFRAMES_FOREX, ne as TIMEFRAMES_STOCK, J as ThemeManager, qe as TickAggregator, Ze as UndoRedoManager, re as VN_COLORS, et as VolumeRenderer, Ot as WaterfallChart, nt as Watermark, ie as computePriceLimits, ae as createVNTheme, oe as formatNumber, se as formatVND, ce as formatVolumeLoc, le as getCurrentSession, ue as getLocale, fe as registerLocale, pe as setLocale, b as t, mt as toHeikinAshi, gt as toKagi, vt as toLineBreak, bt as toPointAndFigure, St as toRenko };
|
|
1105
1201
|
|
|
1106
1202
|
//# sourceMappingURL=index.js.map
|