hyperprop-charting-library 0.1.14 → 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.
- package/README.md +3 -1
- package/dist/hyperprop-charting-library.cjs +17 -4
- package/dist/hyperprop-charting-library.d.ts +1 -0
- package/dist/hyperprop-charting-library.js +17 -4
- package/dist/index.cjs +17 -4
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -4
- package/docs/API.md +1 -0
- package/docs/RECIPES.md +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,7 +54,9 @@ If fast ticks make right-side labels jitter, keep width stable:
|
|
|
54
54
|
const chart = createChart(root, {
|
|
55
55
|
priceDecimals: 2,
|
|
56
56
|
stabilizePriceLabels: true,
|
|
57
|
-
priceLabelMinIntegerDigits: 4
|
|
57
|
+
priceLabelMinIntegerDigits: 4,
|
|
58
|
+
// strongest lock (optional):
|
|
59
|
+
// priceLabelWidthTemplate: "88888.88"
|
|
58
60
|
});
|
|
59
61
|
```
|
|
60
62
|
|
|
@@ -128,6 +128,7 @@ var DEFAULT_OPTIONS = {
|
|
|
128
128
|
priceDecimals: 2,
|
|
129
129
|
stabilizePriceLabels: true,
|
|
130
130
|
priceLabelMinIntegerDigits: 3,
|
|
131
|
+
priceLabelWidthTemplate: "",
|
|
131
132
|
initialViewport: "latest",
|
|
132
133
|
initialVisibleBars: 60,
|
|
133
134
|
minVisibleBars: 5,
|
|
@@ -368,6 +369,10 @@ function createChart(element, options = {}) {
|
|
|
368
369
|
return price.toFixed(decimals);
|
|
369
370
|
};
|
|
370
371
|
const getStabilizedPriceTemplate = () => {
|
|
372
|
+
const explicitTemplate = mergedOptions.priceLabelWidthTemplate.trim();
|
|
373
|
+
if (explicitTemplate.length > 0) {
|
|
374
|
+
return explicitTemplate;
|
|
375
|
+
}
|
|
371
376
|
const decimals = clamp(Math.round(mergedOptions.priceDecimals), 0, 8);
|
|
372
377
|
const configuredDigits = Math.max(1, Math.floor(mergedOptions.priceLabelMinIntegerDigits));
|
|
373
378
|
let maxAbsPrice = 0;
|
|
@@ -837,10 +842,18 @@ function createChart(element, options = {}) {
|
|
|
837
842
|
const endIndex = Math.min(data.length - 1, Math.ceil(xEnd) - 1);
|
|
838
843
|
const visibleData = data.slice(startIndex, endIndex + 1);
|
|
839
844
|
let priceSource = visibleData.length > 0 ? visibleData : data;
|
|
840
|
-
if (mergedOptions.autoScaleIgnoreLatestCandle &&
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
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
|
+
}
|
|
844
857
|
}
|
|
845
858
|
}
|
|
846
859
|
const minPrice = Math.min(...priceSource.map((point) => point.l));
|
|
@@ -104,6 +104,7 @@ var DEFAULT_OPTIONS = {
|
|
|
104
104
|
priceDecimals: 2,
|
|
105
105
|
stabilizePriceLabels: true,
|
|
106
106
|
priceLabelMinIntegerDigits: 3,
|
|
107
|
+
priceLabelWidthTemplate: "",
|
|
107
108
|
initialViewport: "latest",
|
|
108
109
|
initialVisibleBars: 60,
|
|
109
110
|
minVisibleBars: 5,
|
|
@@ -344,6 +345,10 @@ function createChart(element, options = {}) {
|
|
|
344
345
|
return price.toFixed(decimals);
|
|
345
346
|
};
|
|
346
347
|
const getStabilizedPriceTemplate = () => {
|
|
348
|
+
const explicitTemplate = mergedOptions.priceLabelWidthTemplate.trim();
|
|
349
|
+
if (explicitTemplate.length > 0) {
|
|
350
|
+
return explicitTemplate;
|
|
351
|
+
}
|
|
347
352
|
const decimals = clamp(Math.round(mergedOptions.priceDecimals), 0, 8);
|
|
348
353
|
const configuredDigits = Math.max(1, Math.floor(mergedOptions.priceLabelMinIntegerDigits));
|
|
349
354
|
let maxAbsPrice = 0;
|
|
@@ -813,10 +818,18 @@ function createChart(element, options = {}) {
|
|
|
813
818
|
const endIndex = Math.min(data.length - 1, Math.ceil(xEnd) - 1);
|
|
814
819
|
const visibleData = data.slice(startIndex, endIndex + 1);
|
|
815
820
|
let priceSource = visibleData.length > 0 ? visibleData : data;
|
|
816
|
-
if (mergedOptions.autoScaleIgnoreLatestCandle &&
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
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
|
+
}
|
|
820
833
|
}
|
|
821
834
|
}
|
|
822
835
|
const minPrice = Math.min(...priceSource.map((point) => point.l));
|
package/dist/index.cjs
CHANGED
|
@@ -128,6 +128,7 @@ var DEFAULT_OPTIONS = {
|
|
|
128
128
|
priceDecimals: 2,
|
|
129
129
|
stabilizePriceLabels: true,
|
|
130
130
|
priceLabelMinIntegerDigits: 3,
|
|
131
|
+
priceLabelWidthTemplate: "",
|
|
131
132
|
initialViewport: "latest",
|
|
132
133
|
initialVisibleBars: 60,
|
|
133
134
|
minVisibleBars: 5,
|
|
@@ -368,6 +369,10 @@ function createChart(element, options = {}) {
|
|
|
368
369
|
return price.toFixed(decimals);
|
|
369
370
|
};
|
|
370
371
|
const getStabilizedPriceTemplate = () => {
|
|
372
|
+
const explicitTemplate = mergedOptions.priceLabelWidthTemplate.trim();
|
|
373
|
+
if (explicitTemplate.length > 0) {
|
|
374
|
+
return explicitTemplate;
|
|
375
|
+
}
|
|
371
376
|
const decimals = clamp(Math.round(mergedOptions.priceDecimals), 0, 8);
|
|
372
377
|
const configuredDigits = Math.max(1, Math.floor(mergedOptions.priceLabelMinIntegerDigits));
|
|
373
378
|
let maxAbsPrice = 0;
|
|
@@ -837,10 +842,18 @@ function createChart(element, options = {}) {
|
|
|
837
842
|
const endIndex = Math.min(data.length - 1, Math.ceil(xEnd) - 1);
|
|
838
843
|
const visibleData = data.slice(startIndex, endIndex + 1);
|
|
839
844
|
let priceSource = visibleData.length > 0 ? visibleData : data;
|
|
840
|
-
if (mergedOptions.autoScaleIgnoreLatestCandle &&
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
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
|
+
}
|
|
844
857
|
}
|
|
845
858
|
}
|
|
846
859
|
const minPrice = Math.min(...priceSource.map((point) => point.l));
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -104,6 +104,7 @@ var DEFAULT_OPTIONS = {
|
|
|
104
104
|
priceDecimals: 2,
|
|
105
105
|
stabilizePriceLabels: true,
|
|
106
106
|
priceLabelMinIntegerDigits: 3,
|
|
107
|
+
priceLabelWidthTemplate: "",
|
|
107
108
|
initialViewport: "latest",
|
|
108
109
|
initialVisibleBars: 60,
|
|
109
110
|
minVisibleBars: 5,
|
|
@@ -344,6 +345,10 @@ function createChart(element, options = {}) {
|
|
|
344
345
|
return price.toFixed(decimals);
|
|
345
346
|
};
|
|
346
347
|
const getStabilizedPriceTemplate = () => {
|
|
348
|
+
const explicitTemplate = mergedOptions.priceLabelWidthTemplate.trim();
|
|
349
|
+
if (explicitTemplate.length > 0) {
|
|
350
|
+
return explicitTemplate;
|
|
351
|
+
}
|
|
347
352
|
const decimals = clamp(Math.round(mergedOptions.priceDecimals), 0, 8);
|
|
348
353
|
const configuredDigits = Math.max(1, Math.floor(mergedOptions.priceLabelMinIntegerDigits));
|
|
349
354
|
let maxAbsPrice = 0;
|
|
@@ -813,10 +818,18 @@ function createChart(element, options = {}) {
|
|
|
813
818
|
const endIndex = Math.min(data.length - 1, Math.ceil(xEnd) - 1);
|
|
814
819
|
const visibleData = data.slice(startIndex, endIndex + 1);
|
|
815
820
|
let priceSource = visibleData.length > 0 ? visibleData : data;
|
|
816
|
-
if (mergedOptions.autoScaleIgnoreLatestCandle &&
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
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
|
+
}
|
|
820
833
|
}
|
|
821
834
|
}
|
|
822
835
|
const minPrice = Math.min(...priceSource.map((point) => point.l));
|
package/docs/API.md
CHANGED
|
@@ -35,6 +35,7 @@ Top-level options:
|
|
|
35
35
|
- `priceDecimals` (default `2`, used for axis/ticker/line price labels)
|
|
36
36
|
- `stabilizePriceLabels` (default `true`, prevents ticker/crosshair/price-tag width jitter)
|
|
37
37
|
- `priceLabelMinIntegerDigits` (default `3`, baseline integer-digit width for stabilized labels)
|
|
38
|
+
- `priceLabelWidthTemplate` (default `""`; when set, forces label width from this template, e.g. `"88888.88"`)
|
|
38
39
|
- `initialViewport` (`"latest"` | `"center"`, default `"latest"`)
|
|
39
40
|
- `initialVisibleBars` (default `60`)
|
|
40
41
|
- `minVisibleBars` (default `5`, lower clamp for x zoom)
|
package/docs/RECIPES.md
CHANGED
|
@@ -57,7 +57,9 @@ const chart = createChart(root, {
|
|
|
57
57
|
const chart = createChart(root, {
|
|
58
58
|
priceDecimals: 2,
|
|
59
59
|
stabilizePriceLabels: true,
|
|
60
|
-
priceLabelMinIntegerDigits: 4
|
|
60
|
+
priceLabelMinIntegerDigits: 4,
|
|
61
|
+
// If you still see any width movement, pin exact width:
|
|
62
|
+
// priceLabelWidthTemplate: "88888.88"
|
|
61
63
|
});
|
|
62
64
|
```
|
|
63
65
|
|