hyperprop-charting-library 0.1.3 → 0.1.5
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 +26 -30
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +26 -30
- package/docs/API.md +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -24,15 +24,15 @@ __export(index_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(index_exports);
|
|
26
26
|
var DEFAULT_GRID_OPTIONS = {
|
|
27
|
-
color: "#
|
|
28
|
-
opacity: 0.
|
|
27
|
+
color: "#2b2f38",
|
|
28
|
+
opacity: 0.38,
|
|
29
29
|
horizontalLines: true,
|
|
30
30
|
verticalLines: true,
|
|
31
31
|
horizontalTickCount: 5
|
|
32
32
|
};
|
|
33
33
|
var DEFAULT_AXIS_OPTIONS = {
|
|
34
|
-
lineColor: "#
|
|
35
|
-
textColor: "#
|
|
34
|
+
lineColor: "#3b3f47",
|
|
35
|
+
textColor: "#a9adb6",
|
|
36
36
|
fontSize: 12,
|
|
37
37
|
lineWidth: 1
|
|
38
38
|
};
|
|
@@ -47,8 +47,8 @@ var DEFAULT_CROSSHAIR_OPTIONS = {
|
|
|
47
47
|
var DEFAULT_WATERMARK_OPTIONS = {
|
|
48
48
|
visible: false,
|
|
49
49
|
text: "",
|
|
50
|
-
color: "#
|
|
51
|
-
opacity: 0.
|
|
50
|
+
color: "#81858d",
|
|
51
|
+
opacity: 0.14,
|
|
52
52
|
fontSize: 92,
|
|
53
53
|
fontWeight: 700,
|
|
54
54
|
thickness: 0
|
|
@@ -57,9 +57,9 @@ var DEFAULT_PRICE_LINE_OPTIONS = {
|
|
|
57
57
|
visible: true,
|
|
58
58
|
style: "solid",
|
|
59
59
|
thickness: 1,
|
|
60
|
-
color: "#
|
|
61
|
-
labelBackgroundColor: "#
|
|
62
|
-
labelTextColor: "#
|
|
60
|
+
color: "#38bdf8",
|
|
61
|
+
labelBackgroundColor: "#0b1220",
|
|
62
|
+
labelTextColor: "#60a5fa",
|
|
63
63
|
labelBorderRadius: 3,
|
|
64
64
|
showLabel: true
|
|
65
65
|
};
|
|
@@ -68,9 +68,9 @@ var DEFAULT_ORDER_LINE_OPTIONS = {
|
|
|
68
68
|
behavior: "static",
|
|
69
69
|
style: "solid",
|
|
70
70
|
thickness: 1,
|
|
71
|
-
color: "
|
|
72
|
-
labelBackgroundColor: "#
|
|
73
|
-
labelTextColor: "#
|
|
71
|
+
color: "rgba(59,130,246,0.8)",
|
|
72
|
+
labelBackgroundColor: "#0b1220",
|
|
73
|
+
labelTextColor: "#60a5fa",
|
|
74
74
|
labelBorderRadius: 3,
|
|
75
75
|
showCloseButton: true,
|
|
76
76
|
widgetPosition: "left",
|
|
@@ -97,12 +97,13 @@ var DEFAULT_ORDER_LINE_OPTIONS = {
|
|
|
97
97
|
var DEFAULT_OPTIONS = {
|
|
98
98
|
width: 720,
|
|
99
99
|
height: 360,
|
|
100
|
-
backgroundColor: "#
|
|
101
|
-
axisColor: "#
|
|
100
|
+
backgroundColor: "#101114",
|
|
101
|
+
axisColor: "#7f8289",
|
|
102
102
|
axis: DEFAULT_AXIS_OPTIONS,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
priceDecimals: 2,
|
|
104
|
+
upColor: "#2fb171",
|
|
105
|
+
downColor: "#d35a5a",
|
|
106
|
+
gridColor: "#252932",
|
|
106
107
|
fontFamily: "Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif",
|
|
107
108
|
candleBodyWidthRatio: 0.7,
|
|
108
109
|
candleMinWidth: 0.5,
|
|
@@ -118,12 +119,12 @@ var DEFAULT_OPTIONS = {
|
|
|
118
119
|
orderLines: [],
|
|
119
120
|
tickerLine: {
|
|
120
121
|
visible: true,
|
|
121
|
-
style: "
|
|
122
|
+
style: "dotted",
|
|
122
123
|
thickness: 1,
|
|
123
|
-
color: "#
|
|
124
|
-
labelBackgroundColor: "#
|
|
124
|
+
color: "#38bdf8",
|
|
125
|
+
labelBackgroundColor: "#38bdf8",
|
|
125
126
|
labelTextColor: "#0b1220",
|
|
126
|
-
labelBorderRadius:
|
|
127
|
+
labelBorderRadius: 3
|
|
127
128
|
}
|
|
128
129
|
};
|
|
129
130
|
function createChart(element, options = {}) {
|
|
@@ -266,13 +267,8 @@ function createChart(element, options = {}) {
|
|
|
266
267
|
return { min: nextMin, max: nextMax };
|
|
267
268
|
};
|
|
268
269
|
const formatPrice = (price) => {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
if (price >= 100) {
|
|
273
|
-
return price.toFixed(1);
|
|
274
|
-
}
|
|
275
|
-
return price.toFixed(2);
|
|
270
|
+
const decimals = clamp(Math.round(mergedOptions.priceDecimals), 0, 8);
|
|
271
|
+
return price.toFixed(decimals);
|
|
276
272
|
};
|
|
277
273
|
const parseData = (nextData) => {
|
|
278
274
|
return nextData.map((point) => ({
|
|
@@ -389,7 +385,7 @@ function createChart(element, options = {}) {
|
|
|
389
385
|
return;
|
|
390
386
|
}
|
|
391
387
|
const lineY = clamp(yFromPrice(renderPrice), chartTop + 1, chartBottom - 1);
|
|
392
|
-
const color =
|
|
388
|
+
const color = line.color ?? (mergedLine.type === "takeProfit" ? "rgba(45,212,191,0.86)" : mergedLine.type === "stop" ? "rgba(245,158,11,0.86)" : "rgba(59,130,246,0.8)");
|
|
393
389
|
if (Number.isFinite(mergedLine.fillToPrice)) {
|
|
394
390
|
const fillY = clamp(yFromPrice(mergedLine.fillToPrice), chartTop + 1, chartBottom - 1);
|
|
395
391
|
const topY = Math.min(lineY, fillY);
|
|
@@ -500,7 +496,7 @@ function createChart(element, options = {}) {
|
|
|
500
496
|
const borderRadius = Math.max(0, mergedLine.labelBorderRadius);
|
|
501
497
|
const widgetBackground = mergedOptions.backgroundColor;
|
|
502
498
|
const widgetBorder = color;
|
|
503
|
-
const textColor = mergedLine.labelTextColor;
|
|
499
|
+
const textColor = line.labelTextColor ?? (mergedLine.type === "takeProfit" ? "#5eead4" : mergedLine.type === "stop" ? "#fbbf24" : mergedLine.labelTextColor);
|
|
504
500
|
const mainWidgetX = leftWidgetX + actionButtonsTotalWidth + actionButtonsGap;
|
|
505
501
|
ctx.fillStyle = widgetBackground;
|
|
506
502
|
fillRoundedRect(Math.round(mainWidgetX), Math.round(labelY), mainWidgetWidth, labelHeight, borderRadius);
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
var DEFAULT_GRID_OPTIONS = {
|
|
3
|
-
color: "#
|
|
4
|
-
opacity: 0.
|
|
3
|
+
color: "#2b2f38",
|
|
4
|
+
opacity: 0.38,
|
|
5
5
|
horizontalLines: true,
|
|
6
6
|
verticalLines: true,
|
|
7
7
|
horizontalTickCount: 5
|
|
8
8
|
};
|
|
9
9
|
var DEFAULT_AXIS_OPTIONS = {
|
|
10
|
-
lineColor: "#
|
|
11
|
-
textColor: "#
|
|
10
|
+
lineColor: "#3b3f47",
|
|
11
|
+
textColor: "#a9adb6",
|
|
12
12
|
fontSize: 12,
|
|
13
13
|
lineWidth: 1
|
|
14
14
|
};
|
|
@@ -23,8 +23,8 @@ var DEFAULT_CROSSHAIR_OPTIONS = {
|
|
|
23
23
|
var DEFAULT_WATERMARK_OPTIONS = {
|
|
24
24
|
visible: false,
|
|
25
25
|
text: "",
|
|
26
|
-
color: "#
|
|
27
|
-
opacity: 0.
|
|
26
|
+
color: "#81858d",
|
|
27
|
+
opacity: 0.14,
|
|
28
28
|
fontSize: 92,
|
|
29
29
|
fontWeight: 700,
|
|
30
30
|
thickness: 0
|
|
@@ -33,9 +33,9 @@ var DEFAULT_PRICE_LINE_OPTIONS = {
|
|
|
33
33
|
visible: true,
|
|
34
34
|
style: "solid",
|
|
35
35
|
thickness: 1,
|
|
36
|
-
color: "#
|
|
37
|
-
labelBackgroundColor: "#
|
|
38
|
-
labelTextColor: "#
|
|
36
|
+
color: "#38bdf8",
|
|
37
|
+
labelBackgroundColor: "#0b1220",
|
|
38
|
+
labelTextColor: "#60a5fa",
|
|
39
39
|
labelBorderRadius: 3,
|
|
40
40
|
showLabel: true
|
|
41
41
|
};
|
|
@@ -44,9 +44,9 @@ var DEFAULT_ORDER_LINE_OPTIONS = {
|
|
|
44
44
|
behavior: "static",
|
|
45
45
|
style: "solid",
|
|
46
46
|
thickness: 1,
|
|
47
|
-
color: "
|
|
48
|
-
labelBackgroundColor: "#
|
|
49
|
-
labelTextColor: "#
|
|
47
|
+
color: "rgba(59,130,246,0.8)",
|
|
48
|
+
labelBackgroundColor: "#0b1220",
|
|
49
|
+
labelTextColor: "#60a5fa",
|
|
50
50
|
labelBorderRadius: 3,
|
|
51
51
|
showCloseButton: true,
|
|
52
52
|
widgetPosition: "left",
|
|
@@ -73,12 +73,13 @@ var DEFAULT_ORDER_LINE_OPTIONS = {
|
|
|
73
73
|
var DEFAULT_OPTIONS = {
|
|
74
74
|
width: 720,
|
|
75
75
|
height: 360,
|
|
76
|
-
backgroundColor: "#
|
|
77
|
-
axisColor: "#
|
|
76
|
+
backgroundColor: "#101114",
|
|
77
|
+
axisColor: "#7f8289",
|
|
78
78
|
axis: DEFAULT_AXIS_OPTIONS,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
priceDecimals: 2,
|
|
80
|
+
upColor: "#2fb171",
|
|
81
|
+
downColor: "#d35a5a",
|
|
82
|
+
gridColor: "#252932",
|
|
82
83
|
fontFamily: "Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif",
|
|
83
84
|
candleBodyWidthRatio: 0.7,
|
|
84
85
|
candleMinWidth: 0.5,
|
|
@@ -94,12 +95,12 @@ var DEFAULT_OPTIONS = {
|
|
|
94
95
|
orderLines: [],
|
|
95
96
|
tickerLine: {
|
|
96
97
|
visible: true,
|
|
97
|
-
style: "
|
|
98
|
+
style: "dotted",
|
|
98
99
|
thickness: 1,
|
|
99
|
-
color: "#
|
|
100
|
-
labelBackgroundColor: "#
|
|
100
|
+
color: "#38bdf8",
|
|
101
|
+
labelBackgroundColor: "#38bdf8",
|
|
101
102
|
labelTextColor: "#0b1220",
|
|
102
|
-
labelBorderRadius:
|
|
103
|
+
labelBorderRadius: 3
|
|
103
104
|
}
|
|
104
105
|
};
|
|
105
106
|
function createChart(element, options = {}) {
|
|
@@ -242,13 +243,8 @@ function createChart(element, options = {}) {
|
|
|
242
243
|
return { min: nextMin, max: nextMax };
|
|
243
244
|
};
|
|
244
245
|
const formatPrice = (price) => {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
if (price >= 100) {
|
|
249
|
-
return price.toFixed(1);
|
|
250
|
-
}
|
|
251
|
-
return price.toFixed(2);
|
|
246
|
+
const decimals = clamp(Math.round(mergedOptions.priceDecimals), 0, 8);
|
|
247
|
+
return price.toFixed(decimals);
|
|
252
248
|
};
|
|
253
249
|
const parseData = (nextData) => {
|
|
254
250
|
return nextData.map((point) => ({
|
|
@@ -365,7 +361,7 @@ function createChart(element, options = {}) {
|
|
|
365
361
|
return;
|
|
366
362
|
}
|
|
367
363
|
const lineY = clamp(yFromPrice(renderPrice), chartTop + 1, chartBottom - 1);
|
|
368
|
-
const color =
|
|
364
|
+
const color = line.color ?? (mergedLine.type === "takeProfit" ? "rgba(45,212,191,0.86)" : mergedLine.type === "stop" ? "rgba(245,158,11,0.86)" : "rgba(59,130,246,0.8)");
|
|
369
365
|
if (Number.isFinite(mergedLine.fillToPrice)) {
|
|
370
366
|
const fillY = clamp(yFromPrice(mergedLine.fillToPrice), chartTop + 1, chartBottom - 1);
|
|
371
367
|
const topY = Math.min(lineY, fillY);
|
|
@@ -476,7 +472,7 @@ function createChart(element, options = {}) {
|
|
|
476
472
|
const borderRadius = Math.max(0, mergedLine.labelBorderRadius);
|
|
477
473
|
const widgetBackground = mergedOptions.backgroundColor;
|
|
478
474
|
const widgetBorder = color;
|
|
479
|
-
const textColor = mergedLine.labelTextColor;
|
|
475
|
+
const textColor = line.labelTextColor ?? (mergedLine.type === "takeProfit" ? "#5eead4" : mergedLine.type === "stop" ? "#fbbf24" : mergedLine.labelTextColor);
|
|
480
476
|
const mainWidgetX = leftWidgetX + actionButtonsTotalWidth + actionButtonsGap;
|
|
481
477
|
ctx.fillStyle = widgetBackground;
|
|
482
478
|
fillRoundedRect(Math.round(mainWidgetX), Math.round(labelY), mainWidgetWidth, labelHeight, borderRadius);
|
package/docs/API.md
CHANGED
|
@@ -32,6 +32,7 @@ Top-level options:
|
|
|
32
32
|
- `backgroundColor` (default `#ffffff`)
|
|
33
33
|
- `axisColor` (legacy shorthand for axis line/text color)
|
|
34
34
|
- `axis?: AxisOptions`
|
|
35
|
+
- `priceDecimals` (default `2`, used for axis/ticker/line price labels)
|
|
35
36
|
- `upColor` (default `#16a34a`)
|
|
36
37
|
- `downColor` (default `#dc2626`)
|
|
37
38
|
- `gridColor` (default `#e2e8f0`)
|