hyperprop-charting-library 0.1.15 → 0.1.16

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.
@@ -842,10 +842,18 @@ function createChart(element, options = {}) {
842
842
  const endIndex = Math.min(data.length - 1, Math.ceil(xEnd) - 1);
843
843
  const visibleData = data.slice(startIndex, endIndex + 1);
844
844
  let priceSource = visibleData.length > 0 ? visibleData : data;
845
- if (mergedOptions.autoScaleIgnoreLatestCandle && priceSource.length > 1) {
846
- priceSource = priceSource.slice(0, -1);
847
- if (priceSource.length === 0) {
848
- priceSource = visibleData.length > 0 ? visibleData : data;
845
+ if (mergedOptions.autoScaleIgnoreLatestCandle && data.length > 1) {
846
+ const latestIndex = data.length - 1;
847
+ const filtered = priceSource.filter((_, offset) => startIndex + offset !== latestIndex);
848
+ if (filtered.length > 0) {
849
+ priceSource = filtered;
850
+ } else {
851
+ const fallbackWindow = 120;
852
+ const fallbackStart = Math.max(0, latestIndex - fallbackWindow);
853
+ const fallback = data.slice(fallbackStart, latestIndex);
854
+ if (fallback.length > 0) {
855
+ priceSource = fallback;
856
+ }
849
857
  }
850
858
  }
851
859
  const minPrice = Math.min(...priceSource.map((point) => point.l));
@@ -818,10 +818,18 @@ function createChart(element, options = {}) {
818
818
  const endIndex = Math.min(data.length - 1, Math.ceil(xEnd) - 1);
819
819
  const visibleData = data.slice(startIndex, endIndex + 1);
820
820
  let priceSource = visibleData.length > 0 ? visibleData : data;
821
- if (mergedOptions.autoScaleIgnoreLatestCandle && priceSource.length > 1) {
822
- priceSource = priceSource.slice(0, -1);
823
- if (priceSource.length === 0) {
824
- priceSource = visibleData.length > 0 ? visibleData : data;
821
+ if (mergedOptions.autoScaleIgnoreLatestCandle && data.length > 1) {
822
+ const latestIndex = data.length - 1;
823
+ const filtered = priceSource.filter((_, offset) => startIndex + offset !== latestIndex);
824
+ if (filtered.length > 0) {
825
+ priceSource = filtered;
826
+ } else {
827
+ const fallbackWindow = 120;
828
+ const fallbackStart = Math.max(0, latestIndex - fallbackWindow);
829
+ const fallback = data.slice(fallbackStart, latestIndex);
830
+ if (fallback.length > 0) {
831
+ priceSource = fallback;
832
+ }
825
833
  }
826
834
  }
827
835
  const minPrice = Math.min(...priceSource.map((point) => point.l));
package/dist/index.cjs CHANGED
@@ -842,10 +842,18 @@ function createChart(element, options = {}) {
842
842
  const endIndex = Math.min(data.length - 1, Math.ceil(xEnd) - 1);
843
843
  const visibleData = data.slice(startIndex, endIndex + 1);
844
844
  let priceSource = visibleData.length > 0 ? visibleData : data;
845
- if (mergedOptions.autoScaleIgnoreLatestCandle && priceSource.length > 1) {
846
- priceSource = priceSource.slice(0, -1);
847
- if (priceSource.length === 0) {
848
- priceSource = visibleData.length > 0 ? visibleData : data;
845
+ if (mergedOptions.autoScaleIgnoreLatestCandle && data.length > 1) {
846
+ const latestIndex = data.length - 1;
847
+ const filtered = priceSource.filter((_, offset) => startIndex + offset !== latestIndex);
848
+ if (filtered.length > 0) {
849
+ priceSource = filtered;
850
+ } else {
851
+ const fallbackWindow = 120;
852
+ const fallbackStart = Math.max(0, latestIndex - fallbackWindow);
853
+ const fallback = data.slice(fallbackStart, latestIndex);
854
+ if (fallback.length > 0) {
855
+ priceSource = fallback;
856
+ }
849
857
  }
850
858
  }
851
859
  const minPrice = Math.min(...priceSource.map((point) => point.l));
package/dist/index.js CHANGED
@@ -818,10 +818,18 @@ function createChart(element, options = {}) {
818
818
  const endIndex = Math.min(data.length - 1, Math.ceil(xEnd) - 1);
819
819
  const visibleData = data.slice(startIndex, endIndex + 1);
820
820
  let priceSource = visibleData.length > 0 ? visibleData : data;
821
- if (mergedOptions.autoScaleIgnoreLatestCandle && priceSource.length > 1) {
822
- priceSource = priceSource.slice(0, -1);
823
- if (priceSource.length === 0) {
824
- priceSource = visibleData.length > 0 ? visibleData : data;
821
+ if (mergedOptions.autoScaleIgnoreLatestCandle && data.length > 1) {
822
+ const latestIndex = data.length - 1;
823
+ const filtered = priceSource.filter((_, offset) => startIndex + offset !== latestIndex);
824
+ if (filtered.length > 0) {
825
+ priceSource = filtered;
826
+ } else {
827
+ const fallbackWindow = 120;
828
+ const fallbackStart = Math.max(0, latestIndex - fallbackWindow);
829
+ const fallback = data.slice(fallbackStart, latestIndex);
830
+ if (fallback.length > 0) {
831
+ priceSource = fallback;
832
+ }
825
833
  }
826
834
  }
827
835
  const minPrice = Math.min(...priceSource.map((point) => point.l));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperprop-charting-library",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "Lightweight TypeScript charting core",
5
5
  "type": "module",
6
6
  "main": "./dist/hyperprop-charting-library.cjs",