hyperprop-charting-library 0.1.77 → 0.1.79

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.
@@ -2429,6 +2429,20 @@ function createChart(element, options = {}) {
2429
2429
  ctx.fillStyle = lossFill;
2430
2430
  ctx.fillRect(boxX0, Math.min(entryY, stopY), boxW, Math.abs(stopY - entryY));
2431
2431
  ctx.restore();
2432
+ if (data.length > 0) {
2433
+ const nowX = xFromDrawingPoint({ index: data.length - 1, price: 0 });
2434
+ const darkRight = clamp(nowX, boxX0, boxX1);
2435
+ if (darkRight - boxX0 > 0.5) {
2436
+ const darkW = darkRight - boxX0;
2437
+ ctx.save();
2438
+ ctx.globalAlpha = draft ? 0.5 : 1;
2439
+ ctx.fillStyle = hexToRgba(profitColor, 0.18);
2440
+ ctx.fillRect(boxX0, Math.min(entryY, targetY), darkW, Math.abs(targetY - entryY));
2441
+ ctx.fillStyle = hexToRgba(lossColor, 0.18);
2442
+ ctx.fillRect(boxX0, Math.min(entryY, stopY), darkW, Math.abs(stopY - entryY));
2443
+ ctx.restore();
2444
+ }
2445
+ }
2432
2446
  if (isSelected) {
2433
2447
  ctx.save();
2434
2448
  ctx.setLineDash([]);
@@ -2698,6 +2712,23 @@ function createChart(element, options = {}) {
2698
2712
  }
2699
2713
  }
2700
2714
  ctx.restore();
2715
+ const positionAxisGutter = Math.max(0, width - chartRight);
2716
+ if (positionAxisGutter > 0) {
2717
+ for (const positionDrawing of [...drawings, ...draftDrawing ? [draftDrawing] : []]) {
2718
+ if (!positionDrawing.visible) continue;
2719
+ if (positionDrawing.type !== "long-position" && positionDrawing.type !== "short-position") continue;
2720
+ const targetPoint = positionDrawing.points[1];
2721
+ const stopPoint = positionDrawing.points[2];
2722
+ if (!targetPoint || !stopPoint) continue;
2723
+ const bandTop = clamp(Math.min(yFromPrice(targetPoint.price), yFromPrice(stopPoint.price)), chartTop, chartBottom);
2724
+ const bandBottom = clamp(Math.max(yFromPrice(targetPoint.price), yFromPrice(stopPoint.price)), chartTop, chartBottom);
2725
+ if (bandBottom - bandTop < 1) continue;
2726
+ ctx.save();
2727
+ ctx.fillStyle = "rgba(148,163,184,0.18)";
2728
+ ctx.fillRect(chartRight, bandTop, positionAxisGutter, bandBottom - bandTop);
2729
+ ctx.restore();
2730
+ }
2731
+ }
2701
2732
  if (activeSeparateIndicators.length > 0) {
2702
2733
  const xFromIndex = (index) => chartLeft + (index + 0.5 - xStart) / xSpan * chartWidth;
2703
2734
  let paneTopCursor = chartBottom + paneGap;
@@ -2403,6 +2403,20 @@ function createChart(element, options = {}) {
2403
2403
  ctx.fillStyle = lossFill;
2404
2404
  ctx.fillRect(boxX0, Math.min(entryY, stopY), boxW, Math.abs(stopY - entryY));
2405
2405
  ctx.restore();
2406
+ if (data.length > 0) {
2407
+ const nowX = xFromDrawingPoint({ index: data.length - 1, price: 0 });
2408
+ const darkRight = clamp(nowX, boxX0, boxX1);
2409
+ if (darkRight - boxX0 > 0.5) {
2410
+ const darkW = darkRight - boxX0;
2411
+ ctx.save();
2412
+ ctx.globalAlpha = draft ? 0.5 : 1;
2413
+ ctx.fillStyle = hexToRgba(profitColor, 0.18);
2414
+ ctx.fillRect(boxX0, Math.min(entryY, targetY), darkW, Math.abs(targetY - entryY));
2415
+ ctx.fillStyle = hexToRgba(lossColor, 0.18);
2416
+ ctx.fillRect(boxX0, Math.min(entryY, stopY), darkW, Math.abs(stopY - entryY));
2417
+ ctx.restore();
2418
+ }
2419
+ }
2406
2420
  if (isSelected) {
2407
2421
  ctx.save();
2408
2422
  ctx.setLineDash([]);
@@ -2672,6 +2686,23 @@ function createChart(element, options = {}) {
2672
2686
  }
2673
2687
  }
2674
2688
  ctx.restore();
2689
+ const positionAxisGutter = Math.max(0, width - chartRight);
2690
+ if (positionAxisGutter > 0) {
2691
+ for (const positionDrawing of [...drawings, ...draftDrawing ? [draftDrawing] : []]) {
2692
+ if (!positionDrawing.visible) continue;
2693
+ if (positionDrawing.type !== "long-position" && positionDrawing.type !== "short-position") continue;
2694
+ const targetPoint = positionDrawing.points[1];
2695
+ const stopPoint = positionDrawing.points[2];
2696
+ if (!targetPoint || !stopPoint) continue;
2697
+ const bandTop = clamp(Math.min(yFromPrice(targetPoint.price), yFromPrice(stopPoint.price)), chartTop, chartBottom);
2698
+ const bandBottom = clamp(Math.max(yFromPrice(targetPoint.price), yFromPrice(stopPoint.price)), chartTop, chartBottom);
2699
+ if (bandBottom - bandTop < 1) continue;
2700
+ ctx.save();
2701
+ ctx.fillStyle = "rgba(148,163,184,0.18)";
2702
+ ctx.fillRect(chartRight, bandTop, positionAxisGutter, bandBottom - bandTop);
2703
+ ctx.restore();
2704
+ }
2705
+ }
2675
2706
  if (activeSeparateIndicators.length > 0) {
2676
2707
  const xFromIndex = (index) => chartLeft + (index + 0.5 - xStart) / xSpan * chartWidth;
2677
2708
  let paneTopCursor = chartBottom + paneGap;
package/dist/index.cjs CHANGED
@@ -2429,6 +2429,20 @@ function createChart(element, options = {}) {
2429
2429
  ctx.fillStyle = lossFill;
2430
2430
  ctx.fillRect(boxX0, Math.min(entryY, stopY), boxW, Math.abs(stopY - entryY));
2431
2431
  ctx.restore();
2432
+ if (data.length > 0) {
2433
+ const nowX = xFromDrawingPoint({ index: data.length - 1, price: 0 });
2434
+ const darkRight = clamp(nowX, boxX0, boxX1);
2435
+ if (darkRight - boxX0 > 0.5) {
2436
+ const darkW = darkRight - boxX0;
2437
+ ctx.save();
2438
+ ctx.globalAlpha = draft ? 0.5 : 1;
2439
+ ctx.fillStyle = hexToRgba(profitColor, 0.18);
2440
+ ctx.fillRect(boxX0, Math.min(entryY, targetY), darkW, Math.abs(targetY - entryY));
2441
+ ctx.fillStyle = hexToRgba(lossColor, 0.18);
2442
+ ctx.fillRect(boxX0, Math.min(entryY, stopY), darkW, Math.abs(stopY - entryY));
2443
+ ctx.restore();
2444
+ }
2445
+ }
2432
2446
  if (isSelected) {
2433
2447
  ctx.save();
2434
2448
  ctx.setLineDash([]);
@@ -2698,6 +2712,23 @@ function createChart(element, options = {}) {
2698
2712
  }
2699
2713
  }
2700
2714
  ctx.restore();
2715
+ const positionAxisGutter = Math.max(0, width - chartRight);
2716
+ if (positionAxisGutter > 0) {
2717
+ for (const positionDrawing of [...drawings, ...draftDrawing ? [draftDrawing] : []]) {
2718
+ if (!positionDrawing.visible) continue;
2719
+ if (positionDrawing.type !== "long-position" && positionDrawing.type !== "short-position") continue;
2720
+ const targetPoint = positionDrawing.points[1];
2721
+ const stopPoint = positionDrawing.points[2];
2722
+ if (!targetPoint || !stopPoint) continue;
2723
+ const bandTop = clamp(Math.min(yFromPrice(targetPoint.price), yFromPrice(stopPoint.price)), chartTop, chartBottom);
2724
+ const bandBottom = clamp(Math.max(yFromPrice(targetPoint.price), yFromPrice(stopPoint.price)), chartTop, chartBottom);
2725
+ if (bandBottom - bandTop < 1) continue;
2726
+ ctx.save();
2727
+ ctx.fillStyle = "rgba(148,163,184,0.18)";
2728
+ ctx.fillRect(chartRight, bandTop, positionAxisGutter, bandBottom - bandTop);
2729
+ ctx.restore();
2730
+ }
2731
+ }
2701
2732
  if (activeSeparateIndicators.length > 0) {
2702
2733
  const xFromIndex = (index) => chartLeft + (index + 0.5 - xStart) / xSpan * chartWidth;
2703
2734
  let paneTopCursor = chartBottom + paneGap;
package/dist/index.js CHANGED
@@ -2403,6 +2403,20 @@ function createChart(element, options = {}) {
2403
2403
  ctx.fillStyle = lossFill;
2404
2404
  ctx.fillRect(boxX0, Math.min(entryY, stopY), boxW, Math.abs(stopY - entryY));
2405
2405
  ctx.restore();
2406
+ if (data.length > 0) {
2407
+ const nowX = xFromDrawingPoint({ index: data.length - 1, price: 0 });
2408
+ const darkRight = clamp(nowX, boxX0, boxX1);
2409
+ if (darkRight - boxX0 > 0.5) {
2410
+ const darkW = darkRight - boxX0;
2411
+ ctx.save();
2412
+ ctx.globalAlpha = draft ? 0.5 : 1;
2413
+ ctx.fillStyle = hexToRgba(profitColor, 0.18);
2414
+ ctx.fillRect(boxX0, Math.min(entryY, targetY), darkW, Math.abs(targetY - entryY));
2415
+ ctx.fillStyle = hexToRgba(lossColor, 0.18);
2416
+ ctx.fillRect(boxX0, Math.min(entryY, stopY), darkW, Math.abs(stopY - entryY));
2417
+ ctx.restore();
2418
+ }
2419
+ }
2406
2420
  if (isSelected) {
2407
2421
  ctx.save();
2408
2422
  ctx.setLineDash([]);
@@ -2672,6 +2686,23 @@ function createChart(element, options = {}) {
2672
2686
  }
2673
2687
  }
2674
2688
  ctx.restore();
2689
+ const positionAxisGutter = Math.max(0, width - chartRight);
2690
+ if (positionAxisGutter > 0) {
2691
+ for (const positionDrawing of [...drawings, ...draftDrawing ? [draftDrawing] : []]) {
2692
+ if (!positionDrawing.visible) continue;
2693
+ if (positionDrawing.type !== "long-position" && positionDrawing.type !== "short-position") continue;
2694
+ const targetPoint = positionDrawing.points[1];
2695
+ const stopPoint = positionDrawing.points[2];
2696
+ if (!targetPoint || !stopPoint) continue;
2697
+ const bandTop = clamp(Math.min(yFromPrice(targetPoint.price), yFromPrice(stopPoint.price)), chartTop, chartBottom);
2698
+ const bandBottom = clamp(Math.max(yFromPrice(targetPoint.price), yFromPrice(stopPoint.price)), chartTop, chartBottom);
2699
+ if (bandBottom - bandTop < 1) continue;
2700
+ ctx.save();
2701
+ ctx.fillStyle = "rgba(148,163,184,0.18)";
2702
+ ctx.fillRect(chartRight, bandTop, positionAxisGutter, bandBottom - bandTop);
2703
+ ctx.restore();
2704
+ }
2705
+ }
2675
2706
  if (activeSeparateIndicators.length > 0) {
2676
2707
  const xFromIndex = (index) => chartLeft + (index + 0.5 - xStart) / xSpan * chartWidth;
2677
2708
  let paneTopCursor = chartBottom + paneGap;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperprop-charting-library",
3
- "version": "0.1.77",
3
+ "version": "0.1.79",
4
4
  "description": "Lightweight TypeScript charting core",
5
5
  "type": "module",
6
6
  "main": "./dist/hyperprop-charting-library.cjs",