@tradecanvas/chart 1.16.0 → 1.17.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.
@@ -724,14 +724,14 @@ var z = 200, B = 80, V = (e) => e.position === "top" || e.position === "bottom",
724
724
  }
725
725
  }, un = 14, dn = 14, fn = 22, pn = 4;
726
726
  function mn(e) {
727
- let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: l } = e, d = s(t, n), f = e.tagPrecision ?? d, p = r === null ? [t, n] : [
727
+ let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: l } = e, d = e.tagPrecision ?? s(t, n), f = d, p = r === null ? [t, n] : [
728
728
  t,
729
729
  n,
730
730
  r
731
731
  ], m = a;
732
732
  for (let t of p) {
733
733
  if (!Number.isFinite(t)) continue;
734
- let n = e.format ? e.format(t) : u(t, d, i), r = e.format ? n : u(t, f, i);
734
+ let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : u(t, d, i), r = e.format ? n : u(t, f, i);
735
735
  m = Math.max(m, l(n, `500 ${c}px ${o}`) + un, l(r, `bold 11px ${o}`) + dn, l(r, `600 ${c}px ${o}`) + fn);
736
736
  }
737
737
  return m <= a ? a : Math.ceil(m / pn) * pn;
@@ -888,7 +888,7 @@ function kn(e) {
888
888
  if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
889
889
  }
890
890
  var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
891
- static version = "1.16.0";
891
+ static version = "1.17.0";
892
892
  engine;
893
893
  viewport;
894
894
  dataManager;
@@ -2345,7 +2345,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
2345
2345
  this.eventBus.emit("dataUpdate", { connection: e });
2346
2346
  }), this.streamManager.on("error", (e) => {
2347
2347
  this.eventBus.emit("dataUpdate", { error: e.message });
2348
- }), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
2348
+ }), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
2349
2349
  let t = this.streamManager;
2350
2350
  if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
2351
2351
  let n = ae(e.timeframe);
@@ -2668,7 +2668,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
2668
2668
  this.symbolInfo = e ? {
2669
2669
  ...e,
2670
2670
  sessions: e.sessions?.map((e) => ({ ...e }))
2671
- } : null, this.marketConfig?.pricePrecision === void 0 && this.applyPricePrecision(this.symbolInfo?.pricePrecision ?? null);
2671
+ } : null, this.priceAxis.setPriceTick(this.symbolInfo?.minTick ?? null), this.marketConfig?.pricePrecision === void 0 && this.applyPricePrecision(this.symbolInfo?.pricePrecision ?? null);
2672
2672
  let t = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
2673
2673
  let t = x(e.start), n = x(e.end);
2674
2674
  return t === null || n === null ? [] : [{
@@ -2686,11 +2686,23 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
2686
2686
  getSymbolInfo() {
2687
2687
  return this.symbolInfo;
2688
2688
  }
2689
+ applyFeedSymbolInfo(e) {
2690
+ if (!e || typeof e != "object") return;
2691
+ let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
2692
+ if (!n(e.symbol)) return;
2693
+ let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = {
2694
+ ...r,
2695
+ ...e,
2696
+ symbol: e.symbol || r?.symbol || t
2697
+ };
2698
+ r && JSON.stringify(i) === JSON.stringify(r) || (this.symbolInfoSeq++, this.setSymbolInfo(i));
2699
+ }
2689
2700
  resolveStreamSymbol(e, t) {
2701
+ this.symbolInfo && this.symbolInfo.symbol !== t && this.setSymbolInfo(null);
2690
2702
  let n = e.resolveSymbol?.bind(e);
2691
2703
  if (!n) return;
2692
2704
  let r = ++this.symbolInfoSeq;
2693
- this.symbolInfo && this.symbolInfo.symbol !== t && this.setSymbolInfo(null), Promise.resolve().then(() => n(t)).then((e) => {
2705
+ Promise.resolve().then(() => n(t)).then((e) => {
2694
2706
  e && r === this.symbolInfoSeq && this.currentSymbol === t && this.setSymbolInfo(e);
2695
2707
  }, (e) => {
2696
2708
  r === this.symbolInfoSeq && console.warn(`No symbol info for "${t}":`, e);
@@ -3295,7 +3307,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
3295
3307
  e.pricePrecision !== void 0 && this.applyPricePrecision(e.pricePrecision), this.updateViewportAndRender();
3296
3308
  }
3297
3309
  applyPricePrecision(e) {
3298
- this.marketPricePrecision = e, this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ?? An), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
3310
+ this.marketPricePrecision = e, this.priceAxis.setPricePrecision(e), this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ?? An), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
3299
3311
  }
3300
3312
  getMarket() {
3301
3313
  return this.marketConfig;
@@ -3410,6 +3422,7 @@ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
3410
3422
  tagPrecision: this.marketPricePrecision,
3411
3423
  locale: this.numberLocale,
3412
3424
  format: this.priceFormatter,
3425
+ scaleLabel: (e) => this.priceAxis.labelText(e, this.viewport.getState()),
3413
3426
  fontFamily: t.font.family,
3414
3427
  fontSizeSmall: t.font.sizeSmall,
3415
3428
  measure: (e, t) => this.measureText(e, t)
@@ -4186,4 +4199,4 @@ var br = class {
4186
4199
  //#endregion
4187
4200
  export { Yt as C, F as S, H as _, hr as a, on as b, Fn as c, xn as d, W as f, vn as g, _n as h, gr as i, On as l, bn as m, _r as n, fr as o, yn as p, $ as r, rr as s, br as t, Sn as u, ln as v, I as x, L as y };
4188
4201
 
4189
- //# sourceMappingURL=LayoutSession-DdX4GEPK.js.map
4202
+ //# sourceMappingURL=LayoutSession-DW5fcwzw.js.map