hyperprop-charting-library 0.1.124 → 0.1.125
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/hyperprop-charting-library.cjs +19 -5
- package/dist/hyperprop-charting-library.js +19 -5
- package/dist/index.cjs +19 -5
- package/dist/index.js +19 -5
- package/package.json +1 -1
|
@@ -303,6 +303,16 @@ var getIndicatorSourceValue = (point, source) => {
|
|
|
303
303
|
var clampIndicatorLength = (value, fallback) => {
|
|
304
304
|
return Math.max(1, Math.round(Number(value) || fallback));
|
|
305
305
|
};
|
|
306
|
+
var isFullyWhiteColor = (value) => {
|
|
307
|
+
if (!value) return false;
|
|
308
|
+
const normalized = value.trim().toLowerCase();
|
|
309
|
+
if (normalized === "white" || normalized === "#fff" || normalized === "#ffffff") return true;
|
|
310
|
+
const rgb = /^rgba?\(\s*255\s*,\s*255\s*,\s*255\s*(?:,\s*[\d.]+\s*)?\)$/.exec(normalized);
|
|
311
|
+
return rgb !== null;
|
|
312
|
+
};
|
|
313
|
+
var labelTextColorOn = (background, textColor) => {
|
|
314
|
+
return isFullyWhiteColor(background) ? "#000000" : textColor;
|
|
315
|
+
};
|
|
306
316
|
var computeSmaSeries = (data, length, source) => {
|
|
307
317
|
const result = new Array(data.length).fill(null);
|
|
308
318
|
let sum = 0;
|
|
@@ -1983,7 +1993,7 @@ function createChart(element, options = {}) {
|
|
|
1983
1993
|
labelY + labelHeight / 2,
|
|
1984
1994
|
"left",
|
|
1985
1995
|
"middle",
|
|
1986
|
-
mergedLine.labelTextColor
|
|
1996
|
+
labelTextColorOn(mergedLine.labelBackgroundColor, mergedLine.labelTextColor)
|
|
1987
1997
|
);
|
|
1988
1998
|
};
|
|
1989
1999
|
const drawOrderLine = (line, yFromPrice, chartLeft, chartTop, chartRight, chartBottom) => {
|
|
@@ -2123,7 +2133,10 @@ function createChart(element, options = {}) {
|
|
|
2123
2133
|
const borderRadius = Math.max(0, mergedLine.labelBorderRadius);
|
|
2124
2134
|
const widgetBackground = mergedOptions.backgroundColor;
|
|
2125
2135
|
const widgetBorder = color;
|
|
2126
|
-
const textColor =
|
|
2136
|
+
const textColor = labelTextColorOn(
|
|
2137
|
+
widgetBackground,
|
|
2138
|
+
line.labelTextColor ?? (mergedLine.type === "takeProfit" ? "#5eead4" : mergedLine.type === "stop" ? "#fbbf24" : mergedLine.labelTextColor)
|
|
2139
|
+
);
|
|
2127
2140
|
const mainWidgetX = leftWidgetX + actionButtonsTotalWidth + actionButtonsGap;
|
|
2128
2141
|
ctx.fillStyle = widgetBackground;
|
|
2129
2142
|
fillRoundedRect(Math.round(mainWidgetX), Math.round(widgetY), mainWidgetWidth, labelHeight, borderRadius);
|
|
@@ -3875,7 +3888,8 @@ function createChart(element, options = {}) {
|
|
|
3875
3888
|
fillRoundedRect(Math.round(labelX), Math.round(label.y), label.width, label.height, labelRadius);
|
|
3876
3889
|
const hasSubtexts = label.subtexts.length > 0;
|
|
3877
3890
|
const primaryY = hasSubtexts ? label.y + baseLabelHeight / 2 - 1 : label.y + label.height / 2;
|
|
3878
|
-
|
|
3891
|
+
const effectiveTextColor = labelTextColorOn(label.backgroundColor, label.textColor);
|
|
3892
|
+
drawText(label.text, labelX + labelPaddingX, primaryY, "left", "middle", effectiveTextColor);
|
|
3879
3893
|
if (hasSubtexts) {
|
|
3880
3894
|
const baseFont = ctx.font;
|
|
3881
3895
|
ctx.font = `${label.subtextFontSize}px ${mergedOptions.fontFamily}`;
|
|
@@ -3886,7 +3900,7 @@ function createChart(element, options = {}) {
|
|
|
3886
3900
|
label.y + baseLabelHeight + index * (label.subtextFontSize + 5) + label.subtextFontSize / 2,
|
|
3887
3901
|
"left",
|
|
3888
3902
|
"middle",
|
|
3889
|
-
label.subtextColor ?? label.textColor
|
|
3903
|
+
labelTextColorOn(label.backgroundColor, label.subtextColor ?? label.textColor)
|
|
3890
3904
|
);
|
|
3891
3905
|
});
|
|
3892
3906
|
ctx.font = baseFont;
|
|
@@ -4043,7 +4057,7 @@ function createChart(element, options = {}) {
|
|
|
4043
4057
|
const labelHeight = 20;
|
|
4044
4058
|
const labelRadius = Math.max(0, crosshair.labelBorderRadius);
|
|
4045
4059
|
const labelBackground = crosshair.labelBackgroundColor;
|
|
4046
|
-
const labelTextColor = crosshair.labelTextColor;
|
|
4060
|
+
const labelTextColor = labelTextColorOn(labelBackground, crosshair.labelTextColor);
|
|
4047
4061
|
const labelBorderColor = crosshair.labelBorderColor;
|
|
4048
4062
|
const labelBorderWidth = Math.max(0, crosshair.labelBorderWidth);
|
|
4049
4063
|
const labelBorderStyle = crosshair.labelBorderStyle;
|
|
@@ -277,6 +277,16 @@ var getIndicatorSourceValue = (point, source) => {
|
|
|
277
277
|
var clampIndicatorLength = (value, fallback) => {
|
|
278
278
|
return Math.max(1, Math.round(Number(value) || fallback));
|
|
279
279
|
};
|
|
280
|
+
var isFullyWhiteColor = (value) => {
|
|
281
|
+
if (!value) return false;
|
|
282
|
+
const normalized = value.trim().toLowerCase();
|
|
283
|
+
if (normalized === "white" || normalized === "#fff" || normalized === "#ffffff") return true;
|
|
284
|
+
const rgb = /^rgba?\(\s*255\s*,\s*255\s*,\s*255\s*(?:,\s*[\d.]+\s*)?\)$/.exec(normalized);
|
|
285
|
+
return rgb !== null;
|
|
286
|
+
};
|
|
287
|
+
var labelTextColorOn = (background, textColor) => {
|
|
288
|
+
return isFullyWhiteColor(background) ? "#000000" : textColor;
|
|
289
|
+
};
|
|
280
290
|
var computeSmaSeries = (data, length, source) => {
|
|
281
291
|
const result = new Array(data.length).fill(null);
|
|
282
292
|
let sum = 0;
|
|
@@ -1957,7 +1967,7 @@ function createChart(element, options = {}) {
|
|
|
1957
1967
|
labelY + labelHeight / 2,
|
|
1958
1968
|
"left",
|
|
1959
1969
|
"middle",
|
|
1960
|
-
mergedLine.labelTextColor
|
|
1970
|
+
labelTextColorOn(mergedLine.labelBackgroundColor, mergedLine.labelTextColor)
|
|
1961
1971
|
);
|
|
1962
1972
|
};
|
|
1963
1973
|
const drawOrderLine = (line, yFromPrice, chartLeft, chartTop, chartRight, chartBottom) => {
|
|
@@ -2097,7 +2107,10 @@ function createChart(element, options = {}) {
|
|
|
2097
2107
|
const borderRadius = Math.max(0, mergedLine.labelBorderRadius);
|
|
2098
2108
|
const widgetBackground = mergedOptions.backgroundColor;
|
|
2099
2109
|
const widgetBorder = color;
|
|
2100
|
-
const textColor =
|
|
2110
|
+
const textColor = labelTextColorOn(
|
|
2111
|
+
widgetBackground,
|
|
2112
|
+
line.labelTextColor ?? (mergedLine.type === "takeProfit" ? "#5eead4" : mergedLine.type === "stop" ? "#fbbf24" : mergedLine.labelTextColor)
|
|
2113
|
+
);
|
|
2101
2114
|
const mainWidgetX = leftWidgetX + actionButtonsTotalWidth + actionButtonsGap;
|
|
2102
2115
|
ctx.fillStyle = widgetBackground;
|
|
2103
2116
|
fillRoundedRect(Math.round(mainWidgetX), Math.round(widgetY), mainWidgetWidth, labelHeight, borderRadius);
|
|
@@ -3849,7 +3862,8 @@ function createChart(element, options = {}) {
|
|
|
3849
3862
|
fillRoundedRect(Math.round(labelX), Math.round(label.y), label.width, label.height, labelRadius);
|
|
3850
3863
|
const hasSubtexts = label.subtexts.length > 0;
|
|
3851
3864
|
const primaryY = hasSubtexts ? label.y + baseLabelHeight / 2 - 1 : label.y + label.height / 2;
|
|
3852
|
-
|
|
3865
|
+
const effectiveTextColor = labelTextColorOn(label.backgroundColor, label.textColor);
|
|
3866
|
+
drawText(label.text, labelX + labelPaddingX, primaryY, "left", "middle", effectiveTextColor);
|
|
3853
3867
|
if (hasSubtexts) {
|
|
3854
3868
|
const baseFont = ctx.font;
|
|
3855
3869
|
ctx.font = `${label.subtextFontSize}px ${mergedOptions.fontFamily}`;
|
|
@@ -3860,7 +3874,7 @@ function createChart(element, options = {}) {
|
|
|
3860
3874
|
label.y + baseLabelHeight + index * (label.subtextFontSize + 5) + label.subtextFontSize / 2,
|
|
3861
3875
|
"left",
|
|
3862
3876
|
"middle",
|
|
3863
|
-
label.subtextColor ?? label.textColor
|
|
3877
|
+
labelTextColorOn(label.backgroundColor, label.subtextColor ?? label.textColor)
|
|
3864
3878
|
);
|
|
3865
3879
|
});
|
|
3866
3880
|
ctx.font = baseFont;
|
|
@@ -4017,7 +4031,7 @@ function createChart(element, options = {}) {
|
|
|
4017
4031
|
const labelHeight = 20;
|
|
4018
4032
|
const labelRadius = Math.max(0, crosshair.labelBorderRadius);
|
|
4019
4033
|
const labelBackground = crosshair.labelBackgroundColor;
|
|
4020
|
-
const labelTextColor = crosshair.labelTextColor;
|
|
4034
|
+
const labelTextColor = labelTextColorOn(labelBackground, crosshair.labelTextColor);
|
|
4021
4035
|
const labelBorderColor = crosshair.labelBorderColor;
|
|
4022
4036
|
const labelBorderWidth = Math.max(0, crosshair.labelBorderWidth);
|
|
4023
4037
|
const labelBorderStyle = crosshair.labelBorderStyle;
|
package/dist/index.cjs
CHANGED
|
@@ -303,6 +303,16 @@ var getIndicatorSourceValue = (point, source) => {
|
|
|
303
303
|
var clampIndicatorLength = (value, fallback) => {
|
|
304
304
|
return Math.max(1, Math.round(Number(value) || fallback));
|
|
305
305
|
};
|
|
306
|
+
var isFullyWhiteColor = (value) => {
|
|
307
|
+
if (!value) return false;
|
|
308
|
+
const normalized = value.trim().toLowerCase();
|
|
309
|
+
if (normalized === "white" || normalized === "#fff" || normalized === "#ffffff") return true;
|
|
310
|
+
const rgb = /^rgba?\(\s*255\s*,\s*255\s*,\s*255\s*(?:,\s*[\d.]+\s*)?\)$/.exec(normalized);
|
|
311
|
+
return rgb !== null;
|
|
312
|
+
};
|
|
313
|
+
var labelTextColorOn = (background, textColor) => {
|
|
314
|
+
return isFullyWhiteColor(background) ? "#000000" : textColor;
|
|
315
|
+
};
|
|
306
316
|
var computeSmaSeries = (data, length, source) => {
|
|
307
317
|
const result = new Array(data.length).fill(null);
|
|
308
318
|
let sum = 0;
|
|
@@ -1983,7 +1993,7 @@ function createChart(element, options = {}) {
|
|
|
1983
1993
|
labelY + labelHeight / 2,
|
|
1984
1994
|
"left",
|
|
1985
1995
|
"middle",
|
|
1986
|
-
mergedLine.labelTextColor
|
|
1996
|
+
labelTextColorOn(mergedLine.labelBackgroundColor, mergedLine.labelTextColor)
|
|
1987
1997
|
);
|
|
1988
1998
|
};
|
|
1989
1999
|
const drawOrderLine = (line, yFromPrice, chartLeft, chartTop, chartRight, chartBottom) => {
|
|
@@ -2123,7 +2133,10 @@ function createChart(element, options = {}) {
|
|
|
2123
2133
|
const borderRadius = Math.max(0, mergedLine.labelBorderRadius);
|
|
2124
2134
|
const widgetBackground = mergedOptions.backgroundColor;
|
|
2125
2135
|
const widgetBorder = color;
|
|
2126
|
-
const textColor =
|
|
2136
|
+
const textColor = labelTextColorOn(
|
|
2137
|
+
widgetBackground,
|
|
2138
|
+
line.labelTextColor ?? (mergedLine.type === "takeProfit" ? "#5eead4" : mergedLine.type === "stop" ? "#fbbf24" : mergedLine.labelTextColor)
|
|
2139
|
+
);
|
|
2127
2140
|
const mainWidgetX = leftWidgetX + actionButtonsTotalWidth + actionButtonsGap;
|
|
2128
2141
|
ctx.fillStyle = widgetBackground;
|
|
2129
2142
|
fillRoundedRect(Math.round(mainWidgetX), Math.round(widgetY), mainWidgetWidth, labelHeight, borderRadius);
|
|
@@ -3875,7 +3888,8 @@ function createChart(element, options = {}) {
|
|
|
3875
3888
|
fillRoundedRect(Math.round(labelX), Math.round(label.y), label.width, label.height, labelRadius);
|
|
3876
3889
|
const hasSubtexts = label.subtexts.length > 0;
|
|
3877
3890
|
const primaryY = hasSubtexts ? label.y + baseLabelHeight / 2 - 1 : label.y + label.height / 2;
|
|
3878
|
-
|
|
3891
|
+
const effectiveTextColor = labelTextColorOn(label.backgroundColor, label.textColor);
|
|
3892
|
+
drawText(label.text, labelX + labelPaddingX, primaryY, "left", "middle", effectiveTextColor);
|
|
3879
3893
|
if (hasSubtexts) {
|
|
3880
3894
|
const baseFont = ctx.font;
|
|
3881
3895
|
ctx.font = `${label.subtextFontSize}px ${mergedOptions.fontFamily}`;
|
|
@@ -3886,7 +3900,7 @@ function createChart(element, options = {}) {
|
|
|
3886
3900
|
label.y + baseLabelHeight + index * (label.subtextFontSize + 5) + label.subtextFontSize / 2,
|
|
3887
3901
|
"left",
|
|
3888
3902
|
"middle",
|
|
3889
|
-
label.subtextColor ?? label.textColor
|
|
3903
|
+
labelTextColorOn(label.backgroundColor, label.subtextColor ?? label.textColor)
|
|
3890
3904
|
);
|
|
3891
3905
|
});
|
|
3892
3906
|
ctx.font = baseFont;
|
|
@@ -4043,7 +4057,7 @@ function createChart(element, options = {}) {
|
|
|
4043
4057
|
const labelHeight = 20;
|
|
4044
4058
|
const labelRadius = Math.max(0, crosshair.labelBorderRadius);
|
|
4045
4059
|
const labelBackground = crosshair.labelBackgroundColor;
|
|
4046
|
-
const labelTextColor = crosshair.labelTextColor;
|
|
4060
|
+
const labelTextColor = labelTextColorOn(labelBackground, crosshair.labelTextColor);
|
|
4047
4061
|
const labelBorderColor = crosshair.labelBorderColor;
|
|
4048
4062
|
const labelBorderWidth = Math.max(0, crosshair.labelBorderWidth);
|
|
4049
4063
|
const labelBorderStyle = crosshair.labelBorderStyle;
|
package/dist/index.js
CHANGED
|
@@ -277,6 +277,16 @@ var getIndicatorSourceValue = (point, source) => {
|
|
|
277
277
|
var clampIndicatorLength = (value, fallback) => {
|
|
278
278
|
return Math.max(1, Math.round(Number(value) || fallback));
|
|
279
279
|
};
|
|
280
|
+
var isFullyWhiteColor = (value) => {
|
|
281
|
+
if (!value) return false;
|
|
282
|
+
const normalized = value.trim().toLowerCase();
|
|
283
|
+
if (normalized === "white" || normalized === "#fff" || normalized === "#ffffff") return true;
|
|
284
|
+
const rgb = /^rgba?\(\s*255\s*,\s*255\s*,\s*255\s*(?:,\s*[\d.]+\s*)?\)$/.exec(normalized);
|
|
285
|
+
return rgb !== null;
|
|
286
|
+
};
|
|
287
|
+
var labelTextColorOn = (background, textColor) => {
|
|
288
|
+
return isFullyWhiteColor(background) ? "#000000" : textColor;
|
|
289
|
+
};
|
|
280
290
|
var computeSmaSeries = (data, length, source) => {
|
|
281
291
|
const result = new Array(data.length).fill(null);
|
|
282
292
|
let sum = 0;
|
|
@@ -1957,7 +1967,7 @@ function createChart(element, options = {}) {
|
|
|
1957
1967
|
labelY + labelHeight / 2,
|
|
1958
1968
|
"left",
|
|
1959
1969
|
"middle",
|
|
1960
|
-
mergedLine.labelTextColor
|
|
1970
|
+
labelTextColorOn(mergedLine.labelBackgroundColor, mergedLine.labelTextColor)
|
|
1961
1971
|
);
|
|
1962
1972
|
};
|
|
1963
1973
|
const drawOrderLine = (line, yFromPrice, chartLeft, chartTop, chartRight, chartBottom) => {
|
|
@@ -2097,7 +2107,10 @@ function createChart(element, options = {}) {
|
|
|
2097
2107
|
const borderRadius = Math.max(0, mergedLine.labelBorderRadius);
|
|
2098
2108
|
const widgetBackground = mergedOptions.backgroundColor;
|
|
2099
2109
|
const widgetBorder = color;
|
|
2100
|
-
const textColor =
|
|
2110
|
+
const textColor = labelTextColorOn(
|
|
2111
|
+
widgetBackground,
|
|
2112
|
+
line.labelTextColor ?? (mergedLine.type === "takeProfit" ? "#5eead4" : mergedLine.type === "stop" ? "#fbbf24" : mergedLine.labelTextColor)
|
|
2113
|
+
);
|
|
2101
2114
|
const mainWidgetX = leftWidgetX + actionButtonsTotalWidth + actionButtonsGap;
|
|
2102
2115
|
ctx.fillStyle = widgetBackground;
|
|
2103
2116
|
fillRoundedRect(Math.round(mainWidgetX), Math.round(widgetY), mainWidgetWidth, labelHeight, borderRadius);
|
|
@@ -3849,7 +3862,8 @@ function createChart(element, options = {}) {
|
|
|
3849
3862
|
fillRoundedRect(Math.round(labelX), Math.round(label.y), label.width, label.height, labelRadius);
|
|
3850
3863
|
const hasSubtexts = label.subtexts.length > 0;
|
|
3851
3864
|
const primaryY = hasSubtexts ? label.y + baseLabelHeight / 2 - 1 : label.y + label.height / 2;
|
|
3852
|
-
|
|
3865
|
+
const effectiveTextColor = labelTextColorOn(label.backgroundColor, label.textColor);
|
|
3866
|
+
drawText(label.text, labelX + labelPaddingX, primaryY, "left", "middle", effectiveTextColor);
|
|
3853
3867
|
if (hasSubtexts) {
|
|
3854
3868
|
const baseFont = ctx.font;
|
|
3855
3869
|
ctx.font = `${label.subtextFontSize}px ${mergedOptions.fontFamily}`;
|
|
@@ -3860,7 +3874,7 @@ function createChart(element, options = {}) {
|
|
|
3860
3874
|
label.y + baseLabelHeight + index * (label.subtextFontSize + 5) + label.subtextFontSize / 2,
|
|
3861
3875
|
"left",
|
|
3862
3876
|
"middle",
|
|
3863
|
-
label.subtextColor ?? label.textColor
|
|
3877
|
+
labelTextColorOn(label.backgroundColor, label.subtextColor ?? label.textColor)
|
|
3864
3878
|
);
|
|
3865
3879
|
});
|
|
3866
3880
|
ctx.font = baseFont;
|
|
@@ -4017,7 +4031,7 @@ function createChart(element, options = {}) {
|
|
|
4017
4031
|
const labelHeight = 20;
|
|
4018
4032
|
const labelRadius = Math.max(0, crosshair.labelBorderRadius);
|
|
4019
4033
|
const labelBackground = crosshair.labelBackgroundColor;
|
|
4020
|
-
const labelTextColor = crosshair.labelTextColor;
|
|
4034
|
+
const labelTextColor = labelTextColorOn(labelBackground, crosshair.labelTextColor);
|
|
4021
4035
|
const labelBorderColor = crosshair.labelBorderColor;
|
|
4022
4036
|
const labelBorderWidth = Math.max(0, crosshair.labelBorderWidth);
|
|
4023
4037
|
const labelBorderStyle = crosshair.labelBorderStyle;
|