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 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: "#e2e8f0",
28
- opacity: 0.9,
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: "#94a3b8",
35
- textColor: "#94a3b8",
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: "#94a3b8",
51
- opacity: 0.2,
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: "#f59e0b",
61
- labelBackgroundColor: "#f59e0b",
62
- labelTextColor: "#0f172a",
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: "#f59e0b",
72
- labelBackgroundColor: "#f59e0b",
73
- labelTextColor: "#0f172a",
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: "#ffffff",
101
- axisColor: "#94a3b8",
100
+ backgroundColor: "#101114",
101
+ axisColor: "#7f8289",
102
102
  axis: DEFAULT_AXIS_OPTIONS,
103
- upColor: "#16a34a",
104
- downColor: "#dc2626",
105
- gridColor: "#e2e8f0",
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: "dashed",
122
+ style: "dotted",
122
123
  thickness: 1,
123
- color: "#22c55e",
124
- labelBackgroundColor: "#22c55e",
124
+ color: "#38bdf8",
125
+ labelBackgroundColor: "#38bdf8",
125
126
  labelTextColor: "#0b1220",
126
- labelBorderRadius: 6
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
- if (price >= 1e3) {
270
- return price.toFixed(0);
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 = mergedLine.color ?? (mergedLine.side === "buy" ? mergedOptions.upColor : mergedLine.side === "sell" ? mergedOptions.downColor : "#f59e0b");
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
@@ -4,6 +4,7 @@ interface ChartOptions {
4
4
  backgroundColor?: string;
5
5
  axisColor?: string;
6
6
  axis?: AxisOptions;
7
+ priceDecimals?: number;
7
8
  upColor?: string;
8
9
  downColor?: string;
9
10
  gridColor?: string;
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ interface ChartOptions {
4
4
  backgroundColor?: string;
5
5
  axisColor?: string;
6
6
  axis?: AxisOptions;
7
+ priceDecimals?: number;
7
8
  upColor?: string;
8
9
  downColor?: string;
9
10
  gridColor?: string;
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  // src/index.ts
2
2
  var DEFAULT_GRID_OPTIONS = {
3
- color: "#e2e8f0",
4
- opacity: 0.9,
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: "#94a3b8",
11
- textColor: "#94a3b8",
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: "#94a3b8",
27
- opacity: 0.2,
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: "#f59e0b",
37
- labelBackgroundColor: "#f59e0b",
38
- labelTextColor: "#0f172a",
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: "#f59e0b",
48
- labelBackgroundColor: "#f59e0b",
49
- labelTextColor: "#0f172a",
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: "#ffffff",
77
- axisColor: "#94a3b8",
76
+ backgroundColor: "#101114",
77
+ axisColor: "#7f8289",
78
78
  axis: DEFAULT_AXIS_OPTIONS,
79
- upColor: "#16a34a",
80
- downColor: "#dc2626",
81
- gridColor: "#e2e8f0",
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: "dashed",
98
+ style: "dotted",
98
99
  thickness: 1,
99
- color: "#22c55e",
100
- labelBackgroundColor: "#22c55e",
100
+ color: "#38bdf8",
101
+ labelBackgroundColor: "#38bdf8",
101
102
  labelTextColor: "#0b1220",
102
- labelBorderRadius: 6
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
- if (price >= 1e3) {
246
- return price.toFixed(0);
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 = mergedLine.color ?? (mergedLine.side === "buy" ? mergedOptions.upColor : mergedLine.side === "sell" ? mergedOptions.downColor : "#f59e0b");
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`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperprop-charting-library",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Lightweight TypeScript charting core",
5
5
  "type": "module",
6
6
  "main": "./dist/hyperprop-charting-library.cjs",