acttrader-charts 1.3.0-beta.21 → 1.3.0-beta.23

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.cjs CHANGED
@@ -21333,13 +21333,15 @@ var OrderLineTimeDragHandler = class _OrderLineTimeDragHandler {
21333
21333
  // src/core/priceReveal.ts
21334
21334
  var MIN_FACTOR = 0.1;
21335
21335
  var MAX_FACTOR = 10;
21336
- function revealPriceRange(displayed, prices, plotHeightPx, padPx = 24) {
21337
- const pts = prices.filter((p) => Number.isFinite(p));
21336
+ function revealPriceRange(displayed, prices, plotHeightPx, padPx = 24, maxSpan) {
21337
+ const pts = prices.filter((p) => Number.isFinite(p) && p > 0);
21338
21338
  const span = displayed.max - displayed.min;
21339
21339
  if (pts.length === 0 || !(span > 0) || !(plotHeightPx > 0)) return null;
21340
21340
  const lo = Math.min(...pts);
21341
21341
  const hi = Math.max(...pts);
21342
- if (lo >= displayed.min && hi <= displayed.max) return null;
21342
+ const needLo = lo < displayed.min;
21343
+ const needHi = hi > displayed.max;
21344
+ if (!needLo && !needHi) return null;
21343
21345
  let min = displayed.min;
21344
21346
  let max = displayed.max;
21345
21347
  for (let pass = 0; pass < 2; pass++) {
@@ -21347,6 +21349,20 @@ function revealPriceRange(displayed, prices, plotHeightPx, padPx = 24) {
21347
21349
  min = Math.min(displayed.min, lo - pad);
21348
21350
  max = Math.max(displayed.max, hi + pad);
21349
21351
  }
21352
+ if (maxSpan !== void 0 && max - min > maxSpan) {
21353
+ if (!(maxSpan > span)) return null;
21354
+ if (needLo && !needHi) {
21355
+ max = displayed.max;
21356
+ min = max - maxSpan;
21357
+ } else if (needHi && !needLo) {
21358
+ min = displayed.min;
21359
+ max = min + maxSpan;
21360
+ } else {
21361
+ const mid = (displayed.min + displayed.max) / 2;
21362
+ min = mid - maxSpan / 2;
21363
+ max = mid + maxSpan / 2;
21364
+ }
21365
+ }
21350
21366
  return { min, max };
21351
21367
  }
21352
21368
  function scaleAndPanFor(base, target) {
@@ -27260,7 +27276,7 @@ var _ChartEngine = class _ChartEngine {
27260
27276
  this.wrapper.appendChild(this.bottomBar.el);
27261
27277
  }
27262
27278
  container.appendChild(this.wrapper);
27263
- if (this.themeOverrides) {
27279
+ if (this.themeOverrides || Object.keys(this.settingsCanvasColors).length > 0) {
27264
27280
  this.theme = this.buildTheme(this.themeName);
27265
27281
  this.chromeTheme = this.buildChromeTheme(this.themeName);
27266
27282
  this.applyThemeToComponents();
@@ -32321,7 +32337,8 @@ var _ChartEngine = class _ChartEngine {
32321
32337
  if (this.dataStore.length === 0 || this._lastInCompareMode) return;
32322
32338
  const { priceH } = this.getChartLayout();
32323
32339
  const displayed = this._displayedPriceRange ?? this.getScaledPriceRange(this.viewport);
32324
- const target = revealPriceRange(displayed, prices, priceH);
32340
+ const base = this._lockedAutoFitBase ?? displayed;
32341
+ const target = revealPriceRange(displayed, prices, priceH, 24, (base.max - base.min) * MAX_FACTOR);
32325
32342
  if (!target) return;
32326
32343
  if (this.scrollAnimId !== null) {
32327
32344
  cancelAnimationFrame(this.scrollAnimId);