hyperprop-charting-library 0.1.78 → 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,22 +2429,17 @@ 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
- const livePoint = data[data.length - 1];
2433
- if (livePoint) {
2434
- const tickerOpts2 = mergedOptions.tickerLine ?? DEFAULT_OPTIONS.tickerLine;
2435
- const livePrice = tickerOpts2.smoothing && smoothedTickerPrice !== null ? smoothedTickerPrice : livePoint.c;
2436
- const lo = Math.min(target.price, stop.price);
2437
- const hi = Math.max(target.price, stop.price);
2438
- const clampedLive = Math.min(hi, Math.max(lo, livePrice));
2439
- const dir = target.price - entry.price;
2440
- const moved = clampedLive - entry.price;
2441
- if (dir !== 0 && Math.abs(moved) > 0) {
2442
- const towardTarget = moved * dir > 0;
2443
- const liveY = yFromPrice(clampedLive);
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;
2444
2437
  ctx.save();
2445
2438
  ctx.globalAlpha = draft ? 0.5 : 1;
2446
- ctx.fillStyle = hexToRgba(towardTarget ? profitColor : lossColor, 0.22);
2447
- ctx.fillRect(boxX0, Math.min(entryY, liveY), boxW, Math.abs(liveY - entryY));
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));
2448
2443
  ctx.restore();
2449
2444
  }
2450
2445
  }
@@ -2403,22 +2403,17 @@ 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
- const livePoint = data[data.length - 1];
2407
- if (livePoint) {
2408
- const tickerOpts2 = mergedOptions.tickerLine ?? DEFAULT_OPTIONS.tickerLine;
2409
- const livePrice = tickerOpts2.smoothing && smoothedTickerPrice !== null ? smoothedTickerPrice : livePoint.c;
2410
- const lo = Math.min(target.price, stop.price);
2411
- const hi = Math.max(target.price, stop.price);
2412
- const clampedLive = Math.min(hi, Math.max(lo, livePrice));
2413
- const dir = target.price - entry.price;
2414
- const moved = clampedLive - entry.price;
2415
- if (dir !== 0 && Math.abs(moved) > 0) {
2416
- const towardTarget = moved * dir > 0;
2417
- const liveY = yFromPrice(clampedLive);
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;
2418
2411
  ctx.save();
2419
2412
  ctx.globalAlpha = draft ? 0.5 : 1;
2420
- ctx.fillStyle = hexToRgba(towardTarget ? profitColor : lossColor, 0.22);
2421
- ctx.fillRect(boxX0, Math.min(entryY, liveY), boxW, Math.abs(liveY - entryY));
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));
2422
2417
  ctx.restore();
2423
2418
  }
2424
2419
  }
package/dist/index.cjs CHANGED
@@ -2429,22 +2429,17 @@ 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
- const livePoint = data[data.length - 1];
2433
- if (livePoint) {
2434
- const tickerOpts2 = mergedOptions.tickerLine ?? DEFAULT_OPTIONS.tickerLine;
2435
- const livePrice = tickerOpts2.smoothing && smoothedTickerPrice !== null ? smoothedTickerPrice : livePoint.c;
2436
- const lo = Math.min(target.price, stop.price);
2437
- const hi = Math.max(target.price, stop.price);
2438
- const clampedLive = Math.min(hi, Math.max(lo, livePrice));
2439
- const dir = target.price - entry.price;
2440
- const moved = clampedLive - entry.price;
2441
- if (dir !== 0 && Math.abs(moved) > 0) {
2442
- const towardTarget = moved * dir > 0;
2443
- const liveY = yFromPrice(clampedLive);
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;
2444
2437
  ctx.save();
2445
2438
  ctx.globalAlpha = draft ? 0.5 : 1;
2446
- ctx.fillStyle = hexToRgba(towardTarget ? profitColor : lossColor, 0.22);
2447
- ctx.fillRect(boxX0, Math.min(entryY, liveY), boxW, Math.abs(liveY - entryY));
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));
2448
2443
  ctx.restore();
2449
2444
  }
2450
2445
  }
package/dist/index.js CHANGED
@@ -2403,22 +2403,17 @@ 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
- const livePoint = data[data.length - 1];
2407
- if (livePoint) {
2408
- const tickerOpts2 = mergedOptions.tickerLine ?? DEFAULT_OPTIONS.tickerLine;
2409
- const livePrice = tickerOpts2.smoothing && smoothedTickerPrice !== null ? smoothedTickerPrice : livePoint.c;
2410
- const lo = Math.min(target.price, stop.price);
2411
- const hi = Math.max(target.price, stop.price);
2412
- const clampedLive = Math.min(hi, Math.max(lo, livePrice));
2413
- const dir = target.price - entry.price;
2414
- const moved = clampedLive - entry.price;
2415
- if (dir !== 0 && Math.abs(moved) > 0) {
2416
- const towardTarget = moved * dir > 0;
2417
- const liveY = yFromPrice(clampedLive);
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;
2418
2411
  ctx.save();
2419
2412
  ctx.globalAlpha = draft ? 0.5 : 1;
2420
- ctx.fillStyle = hexToRgba(towardTarget ? profitColor : lossColor, 0.22);
2421
- ctx.fillRect(boxX0, Math.min(entryY, liveY), boxW, Math.abs(liveY - entryY));
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));
2422
2417
  ctx.restore();
2423
2418
  }
2424
2419
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperprop-charting-library",
3
- "version": "0.1.78",
3
+ "version": "0.1.79",
4
4
  "description": "Lightweight TypeScript charting core",
5
5
  "type": "module",
6
6
  "main": "./dist/hyperprop-charting-library.cjs",