@tradecanvas/chart 0.1.3 → 0.2.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 CHANGED
@@ -1,5 +1,5 @@
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";
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, renderHeatmap as ut, renderSparkline as dt, toHeikinAshi as ft, toHeikinAshi as pt, toKagi as mt, toKagi as ht, toLineBreak as gt, toLineBreak as _t, toPointAndFigure as vt, toPointAndFigure as yt, toRenko as bt, toRenko as G } from "@tradecanvas/core";
3
3
  //#region src/DataManager.ts
4
4
  function K(e) {
5
5
  if (!e || typeof e.time != "number") return !1;
@@ -35,7 +35,7 @@ var J = class {
35
35
  this.data[this.data.length - 1] = t;
36
36
  }
37
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)));
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] = de(this.data[this.data.length - 1], e)));
39
39
  }
40
40
  getLength() {
41
41
  return this.data.length;
@@ -96,7 +96,7 @@ var J = class {
96
96
  x: i,
97
97
  y: o,
98
98
  width: Math.max(0, this.containerWidth - i - a - h),
99
- height: Math.max(0, this.containerHeight - o - s - _)
99
+ height: Math.max(0, this.containerHeight - o - s - v)
100
100
  }, l = [], u = [], d = 0;
101
101
  for (let t of e) l.push({
102
102
  config: t,
@@ -104,7 +104,7 @@ var J = class {
104
104
  x: d,
105
105
  y: 0,
106
106
  width: t.size,
107
- height: this.containerHeight - _
107
+ height: this.containerHeight - v
108
108
  }
109
109
  }), u.push({
110
110
  panelId: t.id,
@@ -161,7 +161,7 @@ var J = class {
161
161
  x: d,
162
162
  y: 0,
163
163
  width: e.size,
164
- height: this.containerHeight - _
164
+ height: this.containerHeight - v
165
165
  }
166
166
  }), u.push({
167
167
  panelId: e.id,
@@ -189,7 +189,7 @@ var J = class {
189
189
  registerIndicator(e) {
190
190
  this.indicatorEngine.register(e);
191
191
  }
192
- }, pt = class {
192
+ }, xt = class {
193
193
  static version = "0.3.0";
194
194
  engine;
195
195
  viewport;
@@ -270,19 +270,19 @@ var J = class {
270
270
  logScale: n.logScale ?? !0,
271
271
  timeframes: n.timeframes ?? [],
272
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(() => {
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 Te(), W(this.indicatorEngine), this.drawingManager = new Se(), st(this.drawingManager), this.drawingRenderer = new Ce(this.drawingManager), this.drawingManager.setRequestRender(() => {
274
274
  this.syncRenderContext(), this.engine.requestRender(u.Overlay), this.scheduleAutoSave();
275
275
  }), this.drawingManager.setEventCallback((e, t) => {
276
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) => {
277
+ }), this.undoRedoManager = new Qe(), 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 Ye(), this.tradingRenderer = new Xe(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(u.Overlay)), this.tradingManager.setEventCallback((e, t) => {
278
278
  this.eventBus.emit(e, t);
279
- }), this.engine = new Ie(e);
279
+ }), this.engine = new Re(e);
280
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) => {
281
+ this.viewport = new $e(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
282
  if (e.width <= 0 || e.height <= 0) return;
283
283
  let t = this.viewport.isAtEnd();
284
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) => {
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) => {
286
286
  if (e !== null && t) {
287
287
  let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
288
288
  this.chartLegend.setHoverBar(r ?? null), r && this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize()), this.eventBus.emit("crosshairMove", {
@@ -291,12 +291,12 @@ var J = class {
291
291
  barIndex: e
292
292
  });
293
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({
294
+ }), this.chartLegend = new P(), this.chartLegend.setChartType(t.chartType), this.watermark = new rt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new tt(), this.barCountdown = new D(), this.sessionBreaks = new We(), this.compareRenderer = new R(), t.sessionBreaks ? this.sessionBreaks.setConfig({
295
295
  visible: t.sessionBreaks.visible ?? !0,
296
296
  color: t.sessionBreaks.color,
297
297
  lineStyle: t.sessionBreaks.lineStyle,
298
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({
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({
300
300
  scrollBars: (e) => {
301
301
  let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
302
302
  this.viewport.scrollBy(e * t), this.updateViewportAndRender();
@@ -312,16 +312,16 @@ var J = class {
312
312
  this.viewport.scrollToEnd(), this.updateViewportAndRender();
313
313
  },
314
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) => {
315
+ }), this.currentPriceLine = new ve(), this.alertManager = new S(), this.alertManager.setRequestRender(() => this.engine.requestRender(u.Overlay)), this.alertManager.on("triggered", (e) => {
316
316
  this.eventBus.emit("dataUpdate", {
317
317
  alert: "triggered",
318
318
  alertId: e.id,
319
319
  price: e.price,
320
320
  message: e.message
321
321
  });
322
- }), this.replayManager = new ze(), this.interactionManager = new De(e), this.features.panning && this.interactionManager.setPanHandler(new Ne((e) => {
322
+ }), this.replayManager = new Ve(), this.interactionManager = new ke(e), this.features.panning && this.interactionManager.setPanHandler(new Fe((e) => {
323
323
  this.viewport.scrollBy(e), this.updateViewportAndRender();
324
- })), this.features.zooming && this.interactionManager.setZoomHandler(new nt((e, t) => {
324
+ })), this.features.zooming && this.interactionManager.setZoomHandler(new it((e, t) => {
325
325
  this.viewport.zoom(e, t), this.updateViewportAndRender();
326
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
327
  this.engine.requestRender(u.Overlay), this.layoutManager.getPanels().length > 0 && this.engine.requestRender(u.UI);
@@ -431,21 +431,21 @@ var J = class {
431
431
  exportVisibleData(e = "csv", t) {
432
432
  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);
433
433
  if (e === "json") {
434
- let e = V.toJSON(o);
435
- V.download(e, t ?? "chart-data.json", "application/json");
434
+ let e = B.toJSON(o);
435
+ B.download(e, t ?? "chart-data.json", "application/json");
436
436
  } else {
437
- let e = V.toCSV(o);
438
- V.download(e, t ?? "chart-data.csv", "text/csv");
437
+ let e = B.toCSV(o);
438
+ B.download(e, t ?? "chart-data.csv", "text/csv");
439
439
  }
440
440
  }
441
441
  exportAllData(e = "csv", t) {
442
442
  let n = this.dataManager.getData();
443
443
  if (e === "json") {
444
- let e = V.toJSON(n);
445
- V.download(e, t ?? "chart-data.json", "application/json");
444
+ let e = B.toJSON(n);
445
+ B.download(e, t ?? "chart-data.json", "application/json");
446
446
  } else {
447
- let e = V.toCSV(n);
448
- V.download(e, t ?? "chart-data.csv", "text/csv");
447
+ let e = B.toCSV(n);
448
+ B.download(e, t ?? "chart-data.csv", "text/csv");
449
449
  }
450
450
  }
451
451
  setAutoSave(e, t = 5e3) {
@@ -498,7 +498,7 @@ var J = class {
498
498
  this.features.trading && this.tradingManager.setConfig(e);
499
499
  }
500
500
  async connect(e) {
501
- this.disconnectStream(), this.streamManager = new We(), this.streamManager.on("snapshot", (e) => {
501
+ this.disconnectStream(), this.streamManager = new Ke(), this.streamManager.on("snapshot", (e) => {
502
502
  this.setData(e);
503
503
  }), this.streamManager.on("barClose", (e) => {
504
504
  this.dataManager.appendBar(e), this.crosshairHandler.setData(this.dataManager.getData()), this.autoScrollOnNewBar && this.viewport.scrollToEnd(), this.indicatorEngine.recalculateAll(this.dataManager.getData()), this.updateViewportAndRender();
@@ -759,7 +759,7 @@ var J = class {
759
759
  this.loadState(I.serialize(e));
760
760
  }
761
761
  setLocale(e) {
762
- b(e), this.engine.requestRender();
762
+ me(e), this.engine.requestRender();
763
763
  }
764
764
  setMarket(e) {
765
765
  if (this.marketConfig = e, e.colorScheme) {
@@ -780,7 +780,7 @@ var J = class {
780
780
  return this.marketConfig;
781
781
  }
782
782
  setPriceLimits(e) {
783
- this.marketConfig && (v(e, this.marketConfig) && (this.marketConfig.priceLimits = {
783
+ this.marketConfig && (y(e, this.marketConfig) && (this.marketConfig.priceLimits = {
784
784
  ...this.marketConfig.priceLimits,
785
785
  referencePrice: e
786
786
  }), this.engine.requestRender());
@@ -807,15 +807,15 @@ var J = class {
807
807
  switch (e) {
808
808
  case "candlestick": return new M();
809
809
  case "heikinAshi": return new M();
810
- case "line": return new je();
811
- case "area": return new E();
812
- case "bar": return new k();
813
- case "hollowCandle": return new Te();
810
+ case "line": return new Ne();
811
+ case "area": return new T();
812
+ case "bar": return new O();
813
+ case "hollowCandle": return new De();
814
814
  case "baseline": return new A();
815
- case "renko": return new Le();
815
+ case "renko": return new ze();
816
816
  case "lineBreak": return new M();
817
- case "kagi": return new Oe();
818
- case "pointAndFigure": return new Pe();
817
+ case "kagi": return new Ae();
818
+ case "pointAndFigure": return new Ie();
819
819
  default: return new M();
820
820
  }
821
821
  }
@@ -826,23 +826,23 @@ var J = class {
826
826
  let t;
827
827
  switch (this.options.chartType) {
828
828
  case "heikinAshi":
829
- t = at(e);
829
+ t = pt(e);
830
830
  break;
831
831
  case "renko":
832
- t = ft(e, {
832
+ t = G(e, {
833
833
  brickSize: 0,
834
834
  useATR: !0,
835
835
  atrPeriod: 14
836
836
  });
837
837
  break;
838
838
  case "lineBreak":
839
- t = lt(e, 3);
839
+ t = _t(e, 3);
840
840
  break;
841
841
  case "kagi":
842
- t = st(e, 4);
842
+ t = ht(e, 4);
843
843
  break;
844
844
  case "pointAndFigure":
845
- t = ut(e, e.reduce((e, t) => e + t.close, 0) / e.length * .01, 3);
845
+ t = yt(e, e.reduce((e, t) => e + t.close, 0) / e.length * .01, 3);
846
846
  break;
847
847
  default: t = e;
848
848
  }
@@ -960,7 +960,7 @@ var J = class {
960
960
  }
961
961
  buildPriceLimits() {
962
962
  if (!this.marketConfig?.priceLimits?.enabled || !this.marketConfig.priceLimits.referencePrice) return null;
963
- let e = v(this.marketConfig.priceLimits.referencePrice, this.marketConfig);
963
+ let e = y(this.marketConfig.priceLimits.referencePrice, this.marketConfig);
964
964
  return e ? {
965
965
  ...e,
966
966
  colors: this.marketConfig.colorScheme ? {
@@ -970,8 +970,137 @@ var J = class {
970
970
  } : void 0
971
971
  } : null;
972
972
  }
973
+ }, St = class extends k {
974
+ options;
975
+ constructor(e, t) {
976
+ super(e, t.theme), this.options = t, this.requestRender();
977
+ }
978
+ renderChart(e, t, n, r) {
979
+ dt(e, t, n, this.options, r);
980
+ }
981
+ update(e) {
982
+ this.options = {
983
+ ...this.options,
984
+ data: e
985
+ }, this.requestRender();
986
+ }
987
+ setOptions(e) {
988
+ this.options = {
989
+ ...this.options,
990
+ ...e
991
+ }, this.requestRender();
992
+ }
993
+ }, Ct = class extends k {
994
+ options;
995
+ crosshair = null;
996
+ constructor(e, t) {
997
+ super(e, t.theme), this.options = t, t.crosshair !== !1 && (this.crosshair = new V(this.canvas, () => this.requestRender())), this.requestRender();
998
+ }
999
+ renderChart(e, t, n, r) {
1000
+ let i = this.crosshair?.getPosition() ?? null;
1001
+ ct(e, t, n, this.options, r, i);
1002
+ }
1003
+ update(e) {
1004
+ this.options = {
1005
+ ...this.options,
1006
+ data: e
1007
+ }, this.requestRender();
1008
+ }
1009
+ setOptions(e) {
1010
+ this.options = {
1011
+ ...this.options,
1012
+ ...e
1013
+ }, this.requestRender();
1014
+ }
1015
+ destroy() {
1016
+ this.crosshair?.destroy(), super.destroy();
1017
+ }
1018
+ }, wt = class extends k {
1019
+ options;
1020
+ crosshair = null;
1021
+ constructor(e, t) {
1022
+ super(e, t.theme), this.options = t, t.crosshair !== !1 && (this.crosshair = new V(this.canvas, () => this.requestRender())), this.requestRender();
1023
+ }
1024
+ renderChart(e, t, n, r) {
1025
+ let i = this.crosshair?.getPosition() ?? null;
1026
+ lt(e, t, n, this.options, r, i);
1027
+ }
1028
+ update(e, t) {
1029
+ this.options = {
1030
+ ...this.options,
1031
+ data: e
1032
+ }, t !== void 0 && (this.options = {
1033
+ ...this.options,
1034
+ benchmark: t
1035
+ }), this.requestRender();
1036
+ }
1037
+ setOptions(e) {
1038
+ this.options = {
1039
+ ...this.options,
1040
+ ...e
1041
+ }, this.requestRender();
1042
+ }
1043
+ destroy() {
1044
+ this.crosshair?.destroy(), super.destroy();
1045
+ }
1046
+ }, Tt = class extends k {
1047
+ options;
1048
+ crosshair = null;
1049
+ cachedRects = [];
1050
+ currentData = [];
1051
+ lastLayoutWidth = 0;
1052
+ lastLayoutHeight = 0;
1053
+ handleClick = null;
1054
+ constructor(e, t) {
1055
+ super(e, t.theme), this.options = t, this.currentData = t.data ?? [], t.crosshair !== !1 && (this.crosshair = new V(this.canvas, () => this.requestRender())), t.onCellClick && (this.handleClick = (e) => {
1056
+ let t = this.canvas.getBoundingClientRect(), n = e.clientX - t.left, r = e.clientY - t.top;
1057
+ this.onCanvasClick(n, r);
1058
+ }, this.canvas.addEventListener("click", this.handleClick)), this.recomputeLayout(), this.requestRender();
1059
+ }
1060
+ recomputeLayout() {
1061
+ let e = {
1062
+ x: 0,
1063
+ y: 0,
1064
+ width: this.width,
1065
+ height: this.height
1066
+ }, t = this.options.cellPadding ?? 2;
1067
+ this.lastLayoutWidth = this.width, this.lastLayoutHeight = this.height, this.options.weighted ? this.cachedRects = at(this.currentData.map((e) => ({
1068
+ id: e.id,
1069
+ weight: e.weight ?? (Math.abs(e.value) || 1)
1070
+ })), e, t) : this.cachedRects = ot(this.currentData.map((e) => ({ id: e.id })), e, t);
1071
+ }
1072
+ onCanvasClick(e, t) {
1073
+ if (this.options.onCellClick) for (let n of this.cachedRects) {
1074
+ let r = n.rect;
1075
+ if (e >= r.x && e <= r.x + r.width && t >= r.y && t <= r.y + r.height) {
1076
+ let e = this.currentData.find((e) => e.id === n.id);
1077
+ e && this.options.onCellClick(e);
1078
+ return;
1079
+ }
1080
+ }
1081
+ }
1082
+ renderChart(e, t, n, r) {
1083
+ (t !== this.lastLayoutWidth || n !== this.lastLayoutHeight) && this.recomputeLayout();
1084
+ let i = this.crosshair?.getPosition() ?? null;
1085
+ ut(e, t, n, this.currentData, this.cachedRects, this.options, r, i);
1086
+ }
1087
+ update(e) {
1088
+ this.currentData = e, this.options = {
1089
+ ...this.options,
1090
+ data: e
1091
+ }, this.recomputeLayout(), this.requestRender();
1092
+ }
1093
+ setOptions(e) {
1094
+ this.options = {
1095
+ ...this.options,
1096
+ ...e
1097
+ }, e.data && (this.currentData = e.data), this.recomputeLayout(), this.requestRender();
1098
+ }
1099
+ destroy() {
1100
+ this.crosshair?.destroy(), this.handleClick && this.canvas.removeEventListener("click", this.handleClick), super.destroy();
1101
+ }
973
1102
  };
974
1103
  //#endregion
975
- 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 };
1104
+ export { x as AlertManager, C as Animator, E as BarCountdown, j as BinanceAdapter, xt 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, J as DataManager, Ct as DepthChart, xe as DrawingBase, we as Easing, wt as EquityCurveChart, Tt as HeatmapChart, Oe as IndicatorBase, je 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, Pe as MockAdapter, $ as PluginManager, Be as ReplayManager, He as Screenshot, Ue as SessionBreaks, St as SparklineChart, Ge as StreamManager, g as TIMEFRAMES_CRYPTO, _ as TIMEFRAMES_FOREX, ne as TIMEFRAMES_STOCK, Y as ThemeManager, qe as TickAggregator, Ze as UndoRedoManager, re as VN_COLORS, et as VolumeRenderer, 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, ft as toHeikinAshi, mt as toKagi, gt as toLineBreak, vt as toPointAndFigure, bt as toRenko };
976
1105
 
977
1106
  //# sourceMappingURL=index.js.map