hyperprop-charting-library 0.1.94 → 0.1.96

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.
@@ -2523,7 +2523,12 @@ function createChart(element, options = {}) {
2523
2523
  const riskAmount = drawing.riskMode === "amount" ? drawing.risk : drawing.accountSize * (drawing.risk / 100);
2524
2524
  const qtyRaw = riskAmount > 0 && stopDist > 0 ? riskAmount / (stopDist * effectivePointValue) : 0;
2525
2525
  const hasMoney = qtyRaw > 0 && Number.isFinite(qtyRaw);
2526
- const qtyText = hasMoney ? qtyRaw.toFixed(Math.max(0, drawing.qtyPrecision)) : "";
2526
+ const qtyDigits = Math.min(Math.max(0, drawing.qtyPrecision), 2);
2527
+ let qtyText = "";
2528
+ if (hasMoney) {
2529
+ qtyText = qtyRaw.toFixed(qtyDigits);
2530
+ if (qtyText.includes(".")) qtyText = qtyText.replace(/\.?0+$/, "");
2531
+ }
2527
2532
  const formatAmount = (value) => {
2528
2533
  const abs = Math.abs(value);
2529
2534
  if (abs >= 1e9) return `${(value / 1e9).toFixed(2)}B`;
@@ -2536,16 +2541,16 @@ function createChart(element, options = {}) {
2536
2541
  const drawPositionPill = (text, leftX2, centerY, bg) => {
2537
2542
  const lines = Array.isArray(text) ? text : [text];
2538
2543
  const prevFont = ctx.font;
2539
- ctx.font = `500 10px ${mergedOptions.fontFamily}`;
2540
- const padding = 5;
2541
- const lineH = 12;
2544
+ ctx.font = `500 11px ${mergedOptions.fontFamily}`;
2545
+ const padding = 6;
2546
+ const lineH = 14;
2542
2547
  const textW = Math.max(...lines.map((line) => ctx.measureText(line).width));
2543
2548
  const pillW = textW + padding * 2;
2544
- const pillH = lines.length === 1 ? 15 : lines.length * lineH + 5;
2549
+ const pillH = lines.length === 1 ? 18 : lines.length * lineH + 6;
2545
2550
  const pillX = leftX2;
2546
2551
  const pillY = centerY - pillH / 2;
2547
2552
  ctx.fillStyle = bg;
2548
- fillRoundedRect(pillX, pillY, pillW, pillH, 3);
2553
+ fillRoundedRect(pillX, pillY, pillW, pillH, 4);
2549
2554
  ctx.fillStyle = labelTextColor;
2550
2555
  ctx.textAlign = "left";
2551
2556
  ctx.textBaseline = "middle";
@@ -2497,7 +2497,12 @@ function createChart(element, options = {}) {
2497
2497
  const riskAmount = drawing.riskMode === "amount" ? drawing.risk : drawing.accountSize * (drawing.risk / 100);
2498
2498
  const qtyRaw = riskAmount > 0 && stopDist > 0 ? riskAmount / (stopDist * effectivePointValue) : 0;
2499
2499
  const hasMoney = qtyRaw > 0 && Number.isFinite(qtyRaw);
2500
- const qtyText = hasMoney ? qtyRaw.toFixed(Math.max(0, drawing.qtyPrecision)) : "";
2500
+ const qtyDigits = Math.min(Math.max(0, drawing.qtyPrecision), 2);
2501
+ let qtyText = "";
2502
+ if (hasMoney) {
2503
+ qtyText = qtyRaw.toFixed(qtyDigits);
2504
+ if (qtyText.includes(".")) qtyText = qtyText.replace(/\.?0+$/, "");
2505
+ }
2501
2506
  const formatAmount = (value) => {
2502
2507
  const abs = Math.abs(value);
2503
2508
  if (abs >= 1e9) return `${(value / 1e9).toFixed(2)}B`;
@@ -2510,16 +2515,16 @@ function createChart(element, options = {}) {
2510
2515
  const drawPositionPill = (text, leftX2, centerY, bg) => {
2511
2516
  const lines = Array.isArray(text) ? text : [text];
2512
2517
  const prevFont = ctx.font;
2513
- ctx.font = `500 10px ${mergedOptions.fontFamily}`;
2514
- const padding = 5;
2515
- const lineH = 12;
2518
+ ctx.font = `500 11px ${mergedOptions.fontFamily}`;
2519
+ const padding = 6;
2520
+ const lineH = 14;
2516
2521
  const textW = Math.max(...lines.map((line) => ctx.measureText(line).width));
2517
2522
  const pillW = textW + padding * 2;
2518
- const pillH = lines.length === 1 ? 15 : lines.length * lineH + 5;
2523
+ const pillH = lines.length === 1 ? 18 : lines.length * lineH + 6;
2519
2524
  const pillX = leftX2;
2520
2525
  const pillY = centerY - pillH / 2;
2521
2526
  ctx.fillStyle = bg;
2522
- fillRoundedRect(pillX, pillY, pillW, pillH, 3);
2527
+ fillRoundedRect(pillX, pillY, pillW, pillH, 4);
2523
2528
  ctx.fillStyle = labelTextColor;
2524
2529
  ctx.textAlign = "left";
2525
2530
  ctx.textBaseline = "middle";
package/dist/index.cjs CHANGED
@@ -2523,7 +2523,12 @@ function createChart(element, options = {}) {
2523
2523
  const riskAmount = drawing.riskMode === "amount" ? drawing.risk : drawing.accountSize * (drawing.risk / 100);
2524
2524
  const qtyRaw = riskAmount > 0 && stopDist > 0 ? riskAmount / (stopDist * effectivePointValue) : 0;
2525
2525
  const hasMoney = qtyRaw > 0 && Number.isFinite(qtyRaw);
2526
- const qtyText = hasMoney ? qtyRaw.toFixed(Math.max(0, drawing.qtyPrecision)) : "";
2526
+ const qtyDigits = Math.min(Math.max(0, drawing.qtyPrecision), 2);
2527
+ let qtyText = "";
2528
+ if (hasMoney) {
2529
+ qtyText = qtyRaw.toFixed(qtyDigits);
2530
+ if (qtyText.includes(".")) qtyText = qtyText.replace(/\.?0+$/, "");
2531
+ }
2527
2532
  const formatAmount = (value) => {
2528
2533
  const abs = Math.abs(value);
2529
2534
  if (abs >= 1e9) return `${(value / 1e9).toFixed(2)}B`;
@@ -2536,16 +2541,16 @@ function createChart(element, options = {}) {
2536
2541
  const drawPositionPill = (text, leftX2, centerY, bg) => {
2537
2542
  const lines = Array.isArray(text) ? text : [text];
2538
2543
  const prevFont = ctx.font;
2539
- ctx.font = `500 10px ${mergedOptions.fontFamily}`;
2540
- const padding = 5;
2541
- const lineH = 12;
2544
+ ctx.font = `500 11px ${mergedOptions.fontFamily}`;
2545
+ const padding = 6;
2546
+ const lineH = 14;
2542
2547
  const textW = Math.max(...lines.map((line) => ctx.measureText(line).width));
2543
2548
  const pillW = textW + padding * 2;
2544
- const pillH = lines.length === 1 ? 15 : lines.length * lineH + 5;
2549
+ const pillH = lines.length === 1 ? 18 : lines.length * lineH + 6;
2545
2550
  const pillX = leftX2;
2546
2551
  const pillY = centerY - pillH / 2;
2547
2552
  ctx.fillStyle = bg;
2548
- fillRoundedRect(pillX, pillY, pillW, pillH, 3);
2553
+ fillRoundedRect(pillX, pillY, pillW, pillH, 4);
2549
2554
  ctx.fillStyle = labelTextColor;
2550
2555
  ctx.textAlign = "left";
2551
2556
  ctx.textBaseline = "middle";
package/dist/index.js CHANGED
@@ -2497,7 +2497,12 @@ function createChart(element, options = {}) {
2497
2497
  const riskAmount = drawing.riskMode === "amount" ? drawing.risk : drawing.accountSize * (drawing.risk / 100);
2498
2498
  const qtyRaw = riskAmount > 0 && stopDist > 0 ? riskAmount / (stopDist * effectivePointValue) : 0;
2499
2499
  const hasMoney = qtyRaw > 0 && Number.isFinite(qtyRaw);
2500
- const qtyText = hasMoney ? qtyRaw.toFixed(Math.max(0, drawing.qtyPrecision)) : "";
2500
+ const qtyDigits = Math.min(Math.max(0, drawing.qtyPrecision), 2);
2501
+ let qtyText = "";
2502
+ if (hasMoney) {
2503
+ qtyText = qtyRaw.toFixed(qtyDigits);
2504
+ if (qtyText.includes(".")) qtyText = qtyText.replace(/\.?0+$/, "");
2505
+ }
2501
2506
  const formatAmount = (value) => {
2502
2507
  const abs = Math.abs(value);
2503
2508
  if (abs >= 1e9) return `${(value / 1e9).toFixed(2)}B`;
@@ -2510,16 +2515,16 @@ function createChart(element, options = {}) {
2510
2515
  const drawPositionPill = (text, leftX2, centerY, bg) => {
2511
2516
  const lines = Array.isArray(text) ? text : [text];
2512
2517
  const prevFont = ctx.font;
2513
- ctx.font = `500 10px ${mergedOptions.fontFamily}`;
2514
- const padding = 5;
2515
- const lineH = 12;
2518
+ ctx.font = `500 11px ${mergedOptions.fontFamily}`;
2519
+ const padding = 6;
2520
+ const lineH = 14;
2516
2521
  const textW = Math.max(...lines.map((line) => ctx.measureText(line).width));
2517
2522
  const pillW = textW + padding * 2;
2518
- const pillH = lines.length === 1 ? 15 : lines.length * lineH + 5;
2523
+ const pillH = lines.length === 1 ? 18 : lines.length * lineH + 6;
2519
2524
  const pillX = leftX2;
2520
2525
  const pillY = centerY - pillH / 2;
2521
2526
  ctx.fillStyle = bg;
2522
- fillRoundedRect(pillX, pillY, pillW, pillH, 3);
2527
+ fillRoundedRect(pillX, pillY, pillW, pillH, 4);
2523
2528
  ctx.fillStyle = labelTextColor;
2524
2529
  ctx.textAlign = "left";
2525
2530
  ctx.textBaseline = "middle";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperprop-charting-library",
3
- "version": "0.1.94",
3
+ "version": "0.1.96",
4
4
  "description": "Lightweight TypeScript charting core",
5
5
  "type": "module",
6
6
  "main": "./dist/hyperprop-charting-library.cjs",