hyperprop-charting-library 0.1.61 → 0.1.62
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 -19
- package/dist/hyperprop-charting-library.js +19 -19
- package/dist/index.cjs +19 -19
- package/dist/index.js +19 -19
- package/package.json +1 -1
|
@@ -2023,16 +2023,17 @@ function createChart(element, options = {}) {
|
|
|
2023
2023
|
return chartBottom - (price - yMin) / yRange * chartHeight;
|
|
2024
2024
|
};
|
|
2025
2025
|
const xFromDrawingPoint = (point) => chartLeft + (point.index + 0.5 - xStart) / xSpan * chartWidth;
|
|
2026
|
-
const
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2026
|
+
const FIB_RATIOS = [0, 0.236, 0.382, 0.5, 0.618, 0.786, 1, 1.618];
|
|
2027
|
+
const hexToRgba = (hex, alpha) => {
|
|
2028
|
+
const cleaned = hex.replace("#", "");
|
|
2029
|
+
if (cleaned.length !== 6) {
|
|
2030
|
+
return `rgba(0,0,0,${alpha})`;
|
|
2031
|
+
}
|
|
2032
|
+
const r = parseInt(cleaned.slice(0, 2), 16);
|
|
2033
|
+
const g = parseInt(cleaned.slice(2, 4), 16);
|
|
2034
|
+
const b = parseInt(cleaned.slice(4, 6), 16);
|
|
2035
|
+
return `rgba(${r},${g},${b},${alpha})`;
|
|
2036
|
+
};
|
|
2036
2037
|
const drawDrawingHandle = (x, y, color) => {
|
|
2037
2038
|
ctx.save();
|
|
2038
2039
|
ctx.setLineDash([]);
|
|
@@ -2119,28 +2120,27 @@ function createChart(element, options = {}) {
|
|
|
2119
2120
|
const secondY = yFromPrice(second.price);
|
|
2120
2121
|
const lineLeft = chartLeft;
|
|
2121
2122
|
const lineRight = chartRight;
|
|
2122
|
-
const levelLines =
|
|
2123
|
-
const price = first.price + (second.price - first.price) * (1 -
|
|
2124
|
-
return {
|
|
2123
|
+
const levelLines = FIB_RATIOS.map((ratio) => {
|
|
2124
|
+
const price = first.price + (second.price - first.price) * (1 - ratio);
|
|
2125
|
+
return { ratio, price, y: yFromPrice(price) };
|
|
2125
2126
|
});
|
|
2127
|
+
const bandColor = hexToRgba(drawing.color, 0.1);
|
|
2126
2128
|
for (let index = 0; index < levelLines.length - 1; index += 1) {
|
|
2127
2129
|
const top = levelLines[index];
|
|
2128
2130
|
const bottom = levelLines[index + 1];
|
|
2129
|
-
const fillColor = bottom.band ?? top.band;
|
|
2130
|
-
if (!fillColor) continue;
|
|
2131
2131
|
const bandTop = Math.min(top.y, bottom.y);
|
|
2132
2132
|
const bandBottom = Math.max(top.y, bottom.y);
|
|
2133
2133
|
ctx.save();
|
|
2134
|
-
ctx.fillStyle =
|
|
2134
|
+
ctx.fillStyle = bandColor;
|
|
2135
2135
|
ctx.globalAlpha = draft ? 0.5 : 1;
|
|
2136
2136
|
ctx.fillRect(lineLeft, bandTop, lineRight - lineLeft, bandBottom - bandTop);
|
|
2137
2137
|
ctx.restore();
|
|
2138
2138
|
}
|
|
2139
2139
|
ctx.save();
|
|
2140
2140
|
ctx.lineWidth = drawing.width;
|
|
2141
|
+
ctx.strokeStyle = drawing.color;
|
|
2141
2142
|
applyDashPattern(drawing.style, dashPatterns.dotted, dashPatterns.dashed);
|
|
2142
2143
|
for (const level of levelLines) {
|
|
2143
|
-
ctx.strokeStyle = level.color;
|
|
2144
2144
|
ctx.beginPath();
|
|
2145
2145
|
ctx.moveTo(crisp(lineLeft), crisp(level.y));
|
|
2146
2146
|
ctx.lineTo(crisp(lineRight), crisp(level.y));
|
|
@@ -2148,7 +2148,7 @@ function createChart(element, options = {}) {
|
|
|
2148
2148
|
}
|
|
2149
2149
|
ctx.restore();
|
|
2150
2150
|
ctx.save();
|
|
2151
|
-
ctx.strokeStyle =
|
|
2151
|
+
ctx.strokeStyle = hexToRgba(drawing.color, 0.5);
|
|
2152
2152
|
ctx.setLineDash([4, 4]);
|
|
2153
2153
|
ctx.lineWidth = 1;
|
|
2154
2154
|
ctx.beginPath();
|
|
@@ -2168,7 +2168,7 @@ function createChart(element, options = {}) {
|
|
|
2168
2168
|
const bgY = level.y - 9;
|
|
2169
2169
|
ctx.fillStyle = mergedOptions.backgroundColor;
|
|
2170
2170
|
fillRoundedRect(bgX, bgY, textWidth + padding * 2, 16, 3);
|
|
2171
|
-
ctx.fillStyle =
|
|
2171
|
+
ctx.fillStyle = drawing.color;
|
|
2172
2172
|
ctx.textAlign = "left";
|
|
2173
2173
|
ctx.textBaseline = "middle";
|
|
2174
2174
|
ctx.fillText(labelText, bgX + padding, bgY + 8);
|
|
@@ -1999,16 +1999,17 @@ function createChart(element, options = {}) {
|
|
|
1999
1999
|
return chartBottom - (price - yMin) / yRange * chartHeight;
|
|
2000
2000
|
};
|
|
2001
2001
|
const xFromDrawingPoint = (point) => chartLeft + (point.index + 0.5 - xStart) / xSpan * chartWidth;
|
|
2002
|
-
const
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2002
|
+
const FIB_RATIOS = [0, 0.236, 0.382, 0.5, 0.618, 0.786, 1, 1.618];
|
|
2003
|
+
const hexToRgba = (hex, alpha) => {
|
|
2004
|
+
const cleaned = hex.replace("#", "");
|
|
2005
|
+
if (cleaned.length !== 6) {
|
|
2006
|
+
return `rgba(0,0,0,${alpha})`;
|
|
2007
|
+
}
|
|
2008
|
+
const r = parseInt(cleaned.slice(0, 2), 16);
|
|
2009
|
+
const g = parseInt(cleaned.slice(2, 4), 16);
|
|
2010
|
+
const b = parseInt(cleaned.slice(4, 6), 16);
|
|
2011
|
+
return `rgba(${r},${g},${b},${alpha})`;
|
|
2012
|
+
};
|
|
2012
2013
|
const drawDrawingHandle = (x, y, color) => {
|
|
2013
2014
|
ctx.save();
|
|
2014
2015
|
ctx.setLineDash([]);
|
|
@@ -2095,28 +2096,27 @@ function createChart(element, options = {}) {
|
|
|
2095
2096
|
const secondY = yFromPrice(second.price);
|
|
2096
2097
|
const lineLeft = chartLeft;
|
|
2097
2098
|
const lineRight = chartRight;
|
|
2098
|
-
const levelLines =
|
|
2099
|
-
const price = first.price + (second.price - first.price) * (1 -
|
|
2100
|
-
return {
|
|
2099
|
+
const levelLines = FIB_RATIOS.map((ratio) => {
|
|
2100
|
+
const price = first.price + (second.price - first.price) * (1 - ratio);
|
|
2101
|
+
return { ratio, price, y: yFromPrice(price) };
|
|
2101
2102
|
});
|
|
2103
|
+
const bandColor = hexToRgba(drawing.color, 0.1);
|
|
2102
2104
|
for (let index = 0; index < levelLines.length - 1; index += 1) {
|
|
2103
2105
|
const top = levelLines[index];
|
|
2104
2106
|
const bottom = levelLines[index + 1];
|
|
2105
|
-
const fillColor = bottom.band ?? top.band;
|
|
2106
|
-
if (!fillColor) continue;
|
|
2107
2107
|
const bandTop = Math.min(top.y, bottom.y);
|
|
2108
2108
|
const bandBottom = Math.max(top.y, bottom.y);
|
|
2109
2109
|
ctx.save();
|
|
2110
|
-
ctx.fillStyle =
|
|
2110
|
+
ctx.fillStyle = bandColor;
|
|
2111
2111
|
ctx.globalAlpha = draft ? 0.5 : 1;
|
|
2112
2112
|
ctx.fillRect(lineLeft, bandTop, lineRight - lineLeft, bandBottom - bandTop);
|
|
2113
2113
|
ctx.restore();
|
|
2114
2114
|
}
|
|
2115
2115
|
ctx.save();
|
|
2116
2116
|
ctx.lineWidth = drawing.width;
|
|
2117
|
+
ctx.strokeStyle = drawing.color;
|
|
2117
2118
|
applyDashPattern(drawing.style, dashPatterns.dotted, dashPatterns.dashed);
|
|
2118
2119
|
for (const level of levelLines) {
|
|
2119
|
-
ctx.strokeStyle = level.color;
|
|
2120
2120
|
ctx.beginPath();
|
|
2121
2121
|
ctx.moveTo(crisp(lineLeft), crisp(level.y));
|
|
2122
2122
|
ctx.lineTo(crisp(lineRight), crisp(level.y));
|
|
@@ -2124,7 +2124,7 @@ function createChart(element, options = {}) {
|
|
|
2124
2124
|
}
|
|
2125
2125
|
ctx.restore();
|
|
2126
2126
|
ctx.save();
|
|
2127
|
-
ctx.strokeStyle =
|
|
2127
|
+
ctx.strokeStyle = hexToRgba(drawing.color, 0.5);
|
|
2128
2128
|
ctx.setLineDash([4, 4]);
|
|
2129
2129
|
ctx.lineWidth = 1;
|
|
2130
2130
|
ctx.beginPath();
|
|
@@ -2144,7 +2144,7 @@ function createChart(element, options = {}) {
|
|
|
2144
2144
|
const bgY = level.y - 9;
|
|
2145
2145
|
ctx.fillStyle = mergedOptions.backgroundColor;
|
|
2146
2146
|
fillRoundedRect(bgX, bgY, textWidth + padding * 2, 16, 3);
|
|
2147
|
-
ctx.fillStyle =
|
|
2147
|
+
ctx.fillStyle = drawing.color;
|
|
2148
2148
|
ctx.textAlign = "left";
|
|
2149
2149
|
ctx.textBaseline = "middle";
|
|
2150
2150
|
ctx.fillText(labelText, bgX + padding, bgY + 8);
|
package/dist/index.cjs
CHANGED
|
@@ -2023,16 +2023,17 @@ function createChart(element, options = {}) {
|
|
|
2023
2023
|
return chartBottom - (price - yMin) / yRange * chartHeight;
|
|
2024
2024
|
};
|
|
2025
2025
|
const xFromDrawingPoint = (point) => chartLeft + (point.index + 0.5 - xStart) / xSpan * chartWidth;
|
|
2026
|
-
const
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2026
|
+
const FIB_RATIOS = [0, 0.236, 0.382, 0.5, 0.618, 0.786, 1, 1.618];
|
|
2027
|
+
const hexToRgba = (hex, alpha) => {
|
|
2028
|
+
const cleaned = hex.replace("#", "");
|
|
2029
|
+
if (cleaned.length !== 6) {
|
|
2030
|
+
return `rgba(0,0,0,${alpha})`;
|
|
2031
|
+
}
|
|
2032
|
+
const r = parseInt(cleaned.slice(0, 2), 16);
|
|
2033
|
+
const g = parseInt(cleaned.slice(2, 4), 16);
|
|
2034
|
+
const b = parseInt(cleaned.slice(4, 6), 16);
|
|
2035
|
+
return `rgba(${r},${g},${b},${alpha})`;
|
|
2036
|
+
};
|
|
2036
2037
|
const drawDrawingHandle = (x, y, color) => {
|
|
2037
2038
|
ctx.save();
|
|
2038
2039
|
ctx.setLineDash([]);
|
|
@@ -2119,28 +2120,27 @@ function createChart(element, options = {}) {
|
|
|
2119
2120
|
const secondY = yFromPrice(second.price);
|
|
2120
2121
|
const lineLeft = chartLeft;
|
|
2121
2122
|
const lineRight = chartRight;
|
|
2122
|
-
const levelLines =
|
|
2123
|
-
const price = first.price + (second.price - first.price) * (1 -
|
|
2124
|
-
return {
|
|
2123
|
+
const levelLines = FIB_RATIOS.map((ratio) => {
|
|
2124
|
+
const price = first.price + (second.price - first.price) * (1 - ratio);
|
|
2125
|
+
return { ratio, price, y: yFromPrice(price) };
|
|
2125
2126
|
});
|
|
2127
|
+
const bandColor = hexToRgba(drawing.color, 0.1);
|
|
2126
2128
|
for (let index = 0; index < levelLines.length - 1; index += 1) {
|
|
2127
2129
|
const top = levelLines[index];
|
|
2128
2130
|
const bottom = levelLines[index + 1];
|
|
2129
|
-
const fillColor = bottom.band ?? top.band;
|
|
2130
|
-
if (!fillColor) continue;
|
|
2131
2131
|
const bandTop = Math.min(top.y, bottom.y);
|
|
2132
2132
|
const bandBottom = Math.max(top.y, bottom.y);
|
|
2133
2133
|
ctx.save();
|
|
2134
|
-
ctx.fillStyle =
|
|
2134
|
+
ctx.fillStyle = bandColor;
|
|
2135
2135
|
ctx.globalAlpha = draft ? 0.5 : 1;
|
|
2136
2136
|
ctx.fillRect(lineLeft, bandTop, lineRight - lineLeft, bandBottom - bandTop);
|
|
2137
2137
|
ctx.restore();
|
|
2138
2138
|
}
|
|
2139
2139
|
ctx.save();
|
|
2140
2140
|
ctx.lineWidth = drawing.width;
|
|
2141
|
+
ctx.strokeStyle = drawing.color;
|
|
2141
2142
|
applyDashPattern(drawing.style, dashPatterns.dotted, dashPatterns.dashed);
|
|
2142
2143
|
for (const level of levelLines) {
|
|
2143
|
-
ctx.strokeStyle = level.color;
|
|
2144
2144
|
ctx.beginPath();
|
|
2145
2145
|
ctx.moveTo(crisp(lineLeft), crisp(level.y));
|
|
2146
2146
|
ctx.lineTo(crisp(lineRight), crisp(level.y));
|
|
@@ -2148,7 +2148,7 @@ function createChart(element, options = {}) {
|
|
|
2148
2148
|
}
|
|
2149
2149
|
ctx.restore();
|
|
2150
2150
|
ctx.save();
|
|
2151
|
-
ctx.strokeStyle =
|
|
2151
|
+
ctx.strokeStyle = hexToRgba(drawing.color, 0.5);
|
|
2152
2152
|
ctx.setLineDash([4, 4]);
|
|
2153
2153
|
ctx.lineWidth = 1;
|
|
2154
2154
|
ctx.beginPath();
|
|
@@ -2168,7 +2168,7 @@ function createChart(element, options = {}) {
|
|
|
2168
2168
|
const bgY = level.y - 9;
|
|
2169
2169
|
ctx.fillStyle = mergedOptions.backgroundColor;
|
|
2170
2170
|
fillRoundedRect(bgX, bgY, textWidth + padding * 2, 16, 3);
|
|
2171
|
-
ctx.fillStyle =
|
|
2171
|
+
ctx.fillStyle = drawing.color;
|
|
2172
2172
|
ctx.textAlign = "left";
|
|
2173
2173
|
ctx.textBaseline = "middle";
|
|
2174
2174
|
ctx.fillText(labelText, bgX + padding, bgY + 8);
|
package/dist/index.js
CHANGED
|
@@ -1999,16 +1999,17 @@ function createChart(element, options = {}) {
|
|
|
1999
1999
|
return chartBottom - (price - yMin) / yRange * chartHeight;
|
|
2000
2000
|
};
|
|
2001
2001
|
const xFromDrawingPoint = (point) => chartLeft + (point.index + 0.5 - xStart) / xSpan * chartWidth;
|
|
2002
|
-
const
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2002
|
+
const FIB_RATIOS = [0, 0.236, 0.382, 0.5, 0.618, 0.786, 1, 1.618];
|
|
2003
|
+
const hexToRgba = (hex, alpha) => {
|
|
2004
|
+
const cleaned = hex.replace("#", "");
|
|
2005
|
+
if (cleaned.length !== 6) {
|
|
2006
|
+
return `rgba(0,0,0,${alpha})`;
|
|
2007
|
+
}
|
|
2008
|
+
const r = parseInt(cleaned.slice(0, 2), 16);
|
|
2009
|
+
const g = parseInt(cleaned.slice(2, 4), 16);
|
|
2010
|
+
const b = parseInt(cleaned.slice(4, 6), 16);
|
|
2011
|
+
return `rgba(${r},${g},${b},${alpha})`;
|
|
2012
|
+
};
|
|
2012
2013
|
const drawDrawingHandle = (x, y, color) => {
|
|
2013
2014
|
ctx.save();
|
|
2014
2015
|
ctx.setLineDash([]);
|
|
@@ -2095,28 +2096,27 @@ function createChart(element, options = {}) {
|
|
|
2095
2096
|
const secondY = yFromPrice(second.price);
|
|
2096
2097
|
const lineLeft = chartLeft;
|
|
2097
2098
|
const lineRight = chartRight;
|
|
2098
|
-
const levelLines =
|
|
2099
|
-
const price = first.price + (second.price - first.price) * (1 -
|
|
2100
|
-
return {
|
|
2099
|
+
const levelLines = FIB_RATIOS.map((ratio) => {
|
|
2100
|
+
const price = first.price + (second.price - first.price) * (1 - ratio);
|
|
2101
|
+
return { ratio, price, y: yFromPrice(price) };
|
|
2101
2102
|
});
|
|
2103
|
+
const bandColor = hexToRgba(drawing.color, 0.1);
|
|
2102
2104
|
for (let index = 0; index < levelLines.length - 1; index += 1) {
|
|
2103
2105
|
const top = levelLines[index];
|
|
2104
2106
|
const bottom = levelLines[index + 1];
|
|
2105
|
-
const fillColor = bottom.band ?? top.band;
|
|
2106
|
-
if (!fillColor) continue;
|
|
2107
2107
|
const bandTop = Math.min(top.y, bottom.y);
|
|
2108
2108
|
const bandBottom = Math.max(top.y, bottom.y);
|
|
2109
2109
|
ctx.save();
|
|
2110
|
-
ctx.fillStyle =
|
|
2110
|
+
ctx.fillStyle = bandColor;
|
|
2111
2111
|
ctx.globalAlpha = draft ? 0.5 : 1;
|
|
2112
2112
|
ctx.fillRect(lineLeft, bandTop, lineRight - lineLeft, bandBottom - bandTop);
|
|
2113
2113
|
ctx.restore();
|
|
2114
2114
|
}
|
|
2115
2115
|
ctx.save();
|
|
2116
2116
|
ctx.lineWidth = drawing.width;
|
|
2117
|
+
ctx.strokeStyle = drawing.color;
|
|
2117
2118
|
applyDashPattern(drawing.style, dashPatterns.dotted, dashPatterns.dashed);
|
|
2118
2119
|
for (const level of levelLines) {
|
|
2119
|
-
ctx.strokeStyle = level.color;
|
|
2120
2120
|
ctx.beginPath();
|
|
2121
2121
|
ctx.moveTo(crisp(lineLeft), crisp(level.y));
|
|
2122
2122
|
ctx.lineTo(crisp(lineRight), crisp(level.y));
|
|
@@ -2124,7 +2124,7 @@ function createChart(element, options = {}) {
|
|
|
2124
2124
|
}
|
|
2125
2125
|
ctx.restore();
|
|
2126
2126
|
ctx.save();
|
|
2127
|
-
ctx.strokeStyle =
|
|
2127
|
+
ctx.strokeStyle = hexToRgba(drawing.color, 0.5);
|
|
2128
2128
|
ctx.setLineDash([4, 4]);
|
|
2129
2129
|
ctx.lineWidth = 1;
|
|
2130
2130
|
ctx.beginPath();
|
|
@@ -2144,7 +2144,7 @@ function createChart(element, options = {}) {
|
|
|
2144
2144
|
const bgY = level.y - 9;
|
|
2145
2145
|
ctx.fillStyle = mergedOptions.backgroundColor;
|
|
2146
2146
|
fillRoundedRect(bgX, bgY, textWidth + padding * 2, 16, 3);
|
|
2147
|
-
ctx.fillStyle =
|
|
2147
|
+
ctx.fillStyle = drawing.color;
|
|
2148
2148
|
ctx.textAlign = "left";
|
|
2149
2149
|
ctx.textBaseline = "middle";
|
|
2150
2150
|
ctx.fillText(labelText, bgX + padding, bgY + 8);
|