hyperprop-charting-library 0.1.157 → 0.1.158

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.
@@ -5439,6 +5439,32 @@ function createChart(element, options = {}) {
5439
5439
  ctx.fill();
5440
5440
  ctx.restore();
5441
5441
  };
5442
+ const drawTrashGlyph = (x, y, size, color) => {
5443
+ const w = size * 0.8;
5444
+ const h = size * 0.9;
5445
+ ctx.save();
5446
+ ctx.strokeStyle = color;
5447
+ ctx.lineWidth = 1.2;
5448
+ ctx.lineCap = "round";
5449
+ ctx.lineJoin = "round";
5450
+ ctx.beginPath();
5451
+ ctx.moveTo(x - w / 2, y - h * 0.28);
5452
+ ctx.lineTo(x + w / 2, y - h * 0.28);
5453
+ ctx.moveTo(x - w * 0.22, y - h * 0.28);
5454
+ ctx.lineTo(x - w * 0.22, y - h * 0.46);
5455
+ ctx.lineTo(x + w * 0.22, y - h * 0.46);
5456
+ ctx.lineTo(x + w * 0.22, y - h * 0.28);
5457
+ ctx.moveTo(x - w * 0.36, y - h * 0.28);
5458
+ ctx.lineTo(x - w * 0.28, y + h * 0.48);
5459
+ ctx.lineTo(x + w * 0.28, y + h * 0.48);
5460
+ ctx.lineTo(x + w * 0.36, y - h * 0.28);
5461
+ ctx.moveTo(x - w * 0.1, y - h * 0.08);
5462
+ ctx.lineTo(x - w * 0.1, y + h * 0.3);
5463
+ ctx.moveTo(x + w * 0.1, y - h * 0.08);
5464
+ ctx.lineTo(x + w * 0.1, y + h * 0.3);
5465
+ ctx.stroke();
5466
+ ctx.restore();
5467
+ };
5442
5468
  const drawAlertLine = (alert, yFromPrice, chartLeft, chartTop, chartRight, chartBottom) => {
5443
5469
  const lineY = getLineY(alert.price, yFromPrice, chartTop, chartBottom, false);
5444
5470
  if (lineY === null) return;
@@ -5457,13 +5483,11 @@ function createChart(element, options = {}) {
5457
5483
  ctx.restore();
5458
5484
  const fontSize = Math.max(8, axis.fontSize);
5459
5485
  ctx.font = `${fontSize}px ${mergedOptions.fontFamily}`;
5460
- const text = alert.label ? `${formatPrice(alert.price)} ${alert.label}` : formatPrice(alert.price);
5461
5486
  const paddingX = 6;
5462
5487
  const bellWidth = fontSize + 2;
5463
5488
  const labelHeight = 20;
5464
5489
  const hovered = hoveredAlertId === alert.id;
5465
- const removeWidth = hovered ? labelHeight : 0;
5466
- const contentWidth = Math.ceil(measureTextWidth(text)) + bellWidth + paddingX * 3 + removeWidth;
5490
+ const contentWidth = bellWidth + paddingX * 2;
5467
5491
  const labelWidth = getRightAxisLabelWidth(chartRight, contentWidth);
5468
5492
  const labelX = getRightAxisLabelX(chartRight);
5469
5493
  const labelY = placeRightAxisLabel(lineY - labelHeight / 2, labelHeight, chartTop, chartBottom - labelHeight);
@@ -5473,29 +5497,26 @@ function createChart(element, options = {}) {
5473
5497
  fillRoundedRect(Math.round(labelX), Math.round(labelY), labelWidth, labelHeight, 3);
5474
5498
  const inkColor = labelTextColorOn(color, "#101114");
5475
5499
  drawBellGlyph(labelX + paddingX + bellWidth / 2, labelY + labelHeight / 2, fontSize, inkColor);
5476
- drawText(text, labelX + paddingX * 2 + bellWidth, labelY + labelHeight / 2, "left", "middle", inkColor);
5500
+ ctx.restore();
5477
5501
  if (hovered) {
5478
- const removeX = labelX + labelWidth - removeWidth;
5479
- ctx.strokeStyle = inkColor;
5480
- ctx.lineWidth = 1.4;
5481
- const inset = 6;
5482
- ctx.beginPath();
5483
- ctx.moveTo(removeX + inset, labelY + inset);
5484
- ctx.lineTo(removeX + removeWidth - inset, labelY + labelHeight - inset);
5485
- ctx.moveTo(removeX + removeWidth - inset, labelY + inset);
5486
- ctx.lineTo(removeX + inset, labelY + labelHeight - inset);
5487
- ctx.stroke();
5502
+ const buttonSize = labelHeight;
5503
+ const buttonX = chartLeft + 10;
5504
+ const buttonY = lineY - buttonSize / 2;
5505
+ ctx.save();
5506
+ ctx.fillStyle = color;
5507
+ fillRoundedRect(Math.round(buttonX), Math.round(buttonY), buttonSize, buttonSize, 3);
5508
+ drawTrashGlyph(buttonX + buttonSize / 2, lineY, fontSize, inkColor);
5509
+ ctx.restore();
5488
5510
  alertRegions.push({
5489
5511
  id: alert.id,
5490
- x: removeX,
5491
- y: labelY,
5492
- width: removeWidth,
5493
- height: labelHeight,
5512
+ x: buttonX,
5513
+ y: buttonY,
5514
+ width: buttonSize,
5515
+ height: buttonSize,
5494
5516
  part: "remove"
5495
5517
  });
5496
5518
  }
5497
- ctx.restore();
5498
- alertRegions.push({ id: alert.id, x: labelX, y: labelY, width: labelWidth - removeWidth, height: labelHeight, part: "line" });
5519
+ alertRegions.push({ id: alert.id, x: labelX, y: labelY, width: labelWidth, height: labelHeight, part: "line" });
5499
5520
  alertRegions.push({ id: alert.id, x: chartLeft, y: lineY - 5, width: chartRight - chartLeft, height: 10, part: "line" });
5500
5521
  };
5501
5522
  const drawOrderLine = (line, yFromPrice, chartLeft, chartTop, chartRight, chartBottom) => {
@@ -5400,6 +5400,32 @@ function createChart(element, options = {}) {
5400
5400
  ctx.fill();
5401
5401
  ctx.restore();
5402
5402
  };
5403
+ const drawTrashGlyph = (x, y, size, color) => {
5404
+ const w = size * 0.8;
5405
+ const h = size * 0.9;
5406
+ ctx.save();
5407
+ ctx.strokeStyle = color;
5408
+ ctx.lineWidth = 1.2;
5409
+ ctx.lineCap = "round";
5410
+ ctx.lineJoin = "round";
5411
+ ctx.beginPath();
5412
+ ctx.moveTo(x - w / 2, y - h * 0.28);
5413
+ ctx.lineTo(x + w / 2, y - h * 0.28);
5414
+ ctx.moveTo(x - w * 0.22, y - h * 0.28);
5415
+ ctx.lineTo(x - w * 0.22, y - h * 0.46);
5416
+ ctx.lineTo(x + w * 0.22, y - h * 0.46);
5417
+ ctx.lineTo(x + w * 0.22, y - h * 0.28);
5418
+ ctx.moveTo(x - w * 0.36, y - h * 0.28);
5419
+ ctx.lineTo(x - w * 0.28, y + h * 0.48);
5420
+ ctx.lineTo(x + w * 0.28, y + h * 0.48);
5421
+ ctx.lineTo(x + w * 0.36, y - h * 0.28);
5422
+ ctx.moveTo(x - w * 0.1, y - h * 0.08);
5423
+ ctx.lineTo(x - w * 0.1, y + h * 0.3);
5424
+ ctx.moveTo(x + w * 0.1, y - h * 0.08);
5425
+ ctx.lineTo(x + w * 0.1, y + h * 0.3);
5426
+ ctx.stroke();
5427
+ ctx.restore();
5428
+ };
5403
5429
  const drawAlertLine = (alert, yFromPrice, chartLeft, chartTop, chartRight, chartBottom) => {
5404
5430
  const lineY = getLineY(alert.price, yFromPrice, chartTop, chartBottom, false);
5405
5431
  if (lineY === null) return;
@@ -5418,13 +5444,11 @@ function createChart(element, options = {}) {
5418
5444
  ctx.restore();
5419
5445
  const fontSize = Math.max(8, axis.fontSize);
5420
5446
  ctx.font = `${fontSize}px ${mergedOptions.fontFamily}`;
5421
- const text = alert.label ? `${formatPrice(alert.price)} ${alert.label}` : formatPrice(alert.price);
5422
5447
  const paddingX = 6;
5423
5448
  const bellWidth = fontSize + 2;
5424
5449
  const labelHeight = 20;
5425
5450
  const hovered = hoveredAlertId === alert.id;
5426
- const removeWidth = hovered ? labelHeight : 0;
5427
- const contentWidth = Math.ceil(measureTextWidth(text)) + bellWidth + paddingX * 3 + removeWidth;
5451
+ const contentWidth = bellWidth + paddingX * 2;
5428
5452
  const labelWidth = getRightAxisLabelWidth(chartRight, contentWidth);
5429
5453
  const labelX = getRightAxisLabelX(chartRight);
5430
5454
  const labelY = placeRightAxisLabel(lineY - labelHeight / 2, labelHeight, chartTop, chartBottom - labelHeight);
@@ -5434,29 +5458,26 @@ function createChart(element, options = {}) {
5434
5458
  fillRoundedRect(Math.round(labelX), Math.round(labelY), labelWidth, labelHeight, 3);
5435
5459
  const inkColor = labelTextColorOn(color, "#101114");
5436
5460
  drawBellGlyph(labelX + paddingX + bellWidth / 2, labelY + labelHeight / 2, fontSize, inkColor);
5437
- drawText(text, labelX + paddingX * 2 + bellWidth, labelY + labelHeight / 2, "left", "middle", inkColor);
5461
+ ctx.restore();
5438
5462
  if (hovered) {
5439
- const removeX = labelX + labelWidth - removeWidth;
5440
- ctx.strokeStyle = inkColor;
5441
- ctx.lineWidth = 1.4;
5442
- const inset = 6;
5443
- ctx.beginPath();
5444
- ctx.moveTo(removeX + inset, labelY + inset);
5445
- ctx.lineTo(removeX + removeWidth - inset, labelY + labelHeight - inset);
5446
- ctx.moveTo(removeX + removeWidth - inset, labelY + inset);
5447
- ctx.lineTo(removeX + inset, labelY + labelHeight - inset);
5448
- ctx.stroke();
5463
+ const buttonSize = labelHeight;
5464
+ const buttonX = chartLeft + 10;
5465
+ const buttonY = lineY - buttonSize / 2;
5466
+ ctx.save();
5467
+ ctx.fillStyle = color;
5468
+ fillRoundedRect(Math.round(buttonX), Math.round(buttonY), buttonSize, buttonSize, 3);
5469
+ drawTrashGlyph(buttonX + buttonSize / 2, lineY, fontSize, inkColor);
5470
+ ctx.restore();
5449
5471
  alertRegions.push({
5450
5472
  id: alert.id,
5451
- x: removeX,
5452
- y: labelY,
5453
- width: removeWidth,
5454
- height: labelHeight,
5473
+ x: buttonX,
5474
+ y: buttonY,
5475
+ width: buttonSize,
5476
+ height: buttonSize,
5455
5477
  part: "remove"
5456
5478
  });
5457
5479
  }
5458
- ctx.restore();
5459
- alertRegions.push({ id: alert.id, x: labelX, y: labelY, width: labelWidth - removeWidth, height: labelHeight, part: "line" });
5480
+ alertRegions.push({ id: alert.id, x: labelX, y: labelY, width: labelWidth, height: labelHeight, part: "line" });
5460
5481
  alertRegions.push({ id: alert.id, x: chartLeft, y: lineY - 5, width: chartRight - chartLeft, height: 10, part: "line" });
5461
5482
  };
5462
5483
  const drawOrderLine = (line, yFromPrice, chartLeft, chartTop, chartRight, chartBottom) => {
package/dist/index.cjs CHANGED
@@ -5439,6 +5439,32 @@ function createChart(element, options = {}) {
5439
5439
  ctx.fill();
5440
5440
  ctx.restore();
5441
5441
  };
5442
+ const drawTrashGlyph = (x, y, size, color) => {
5443
+ const w = size * 0.8;
5444
+ const h = size * 0.9;
5445
+ ctx.save();
5446
+ ctx.strokeStyle = color;
5447
+ ctx.lineWidth = 1.2;
5448
+ ctx.lineCap = "round";
5449
+ ctx.lineJoin = "round";
5450
+ ctx.beginPath();
5451
+ ctx.moveTo(x - w / 2, y - h * 0.28);
5452
+ ctx.lineTo(x + w / 2, y - h * 0.28);
5453
+ ctx.moveTo(x - w * 0.22, y - h * 0.28);
5454
+ ctx.lineTo(x - w * 0.22, y - h * 0.46);
5455
+ ctx.lineTo(x + w * 0.22, y - h * 0.46);
5456
+ ctx.lineTo(x + w * 0.22, y - h * 0.28);
5457
+ ctx.moveTo(x - w * 0.36, y - h * 0.28);
5458
+ ctx.lineTo(x - w * 0.28, y + h * 0.48);
5459
+ ctx.lineTo(x + w * 0.28, y + h * 0.48);
5460
+ ctx.lineTo(x + w * 0.36, y - h * 0.28);
5461
+ ctx.moveTo(x - w * 0.1, y - h * 0.08);
5462
+ ctx.lineTo(x - w * 0.1, y + h * 0.3);
5463
+ ctx.moveTo(x + w * 0.1, y - h * 0.08);
5464
+ ctx.lineTo(x + w * 0.1, y + h * 0.3);
5465
+ ctx.stroke();
5466
+ ctx.restore();
5467
+ };
5442
5468
  const drawAlertLine = (alert, yFromPrice, chartLeft, chartTop, chartRight, chartBottom) => {
5443
5469
  const lineY = getLineY(alert.price, yFromPrice, chartTop, chartBottom, false);
5444
5470
  if (lineY === null) return;
@@ -5457,13 +5483,11 @@ function createChart(element, options = {}) {
5457
5483
  ctx.restore();
5458
5484
  const fontSize = Math.max(8, axis.fontSize);
5459
5485
  ctx.font = `${fontSize}px ${mergedOptions.fontFamily}`;
5460
- const text = alert.label ? `${formatPrice(alert.price)} ${alert.label}` : formatPrice(alert.price);
5461
5486
  const paddingX = 6;
5462
5487
  const bellWidth = fontSize + 2;
5463
5488
  const labelHeight = 20;
5464
5489
  const hovered = hoveredAlertId === alert.id;
5465
- const removeWidth = hovered ? labelHeight : 0;
5466
- const contentWidth = Math.ceil(measureTextWidth(text)) + bellWidth + paddingX * 3 + removeWidth;
5490
+ const contentWidth = bellWidth + paddingX * 2;
5467
5491
  const labelWidth = getRightAxisLabelWidth(chartRight, contentWidth);
5468
5492
  const labelX = getRightAxisLabelX(chartRight);
5469
5493
  const labelY = placeRightAxisLabel(lineY - labelHeight / 2, labelHeight, chartTop, chartBottom - labelHeight);
@@ -5473,29 +5497,26 @@ function createChart(element, options = {}) {
5473
5497
  fillRoundedRect(Math.round(labelX), Math.round(labelY), labelWidth, labelHeight, 3);
5474
5498
  const inkColor = labelTextColorOn(color, "#101114");
5475
5499
  drawBellGlyph(labelX + paddingX + bellWidth / 2, labelY + labelHeight / 2, fontSize, inkColor);
5476
- drawText(text, labelX + paddingX * 2 + bellWidth, labelY + labelHeight / 2, "left", "middle", inkColor);
5500
+ ctx.restore();
5477
5501
  if (hovered) {
5478
- const removeX = labelX + labelWidth - removeWidth;
5479
- ctx.strokeStyle = inkColor;
5480
- ctx.lineWidth = 1.4;
5481
- const inset = 6;
5482
- ctx.beginPath();
5483
- ctx.moveTo(removeX + inset, labelY + inset);
5484
- ctx.lineTo(removeX + removeWidth - inset, labelY + labelHeight - inset);
5485
- ctx.moveTo(removeX + removeWidth - inset, labelY + inset);
5486
- ctx.lineTo(removeX + inset, labelY + labelHeight - inset);
5487
- ctx.stroke();
5502
+ const buttonSize = labelHeight;
5503
+ const buttonX = chartLeft + 10;
5504
+ const buttonY = lineY - buttonSize / 2;
5505
+ ctx.save();
5506
+ ctx.fillStyle = color;
5507
+ fillRoundedRect(Math.round(buttonX), Math.round(buttonY), buttonSize, buttonSize, 3);
5508
+ drawTrashGlyph(buttonX + buttonSize / 2, lineY, fontSize, inkColor);
5509
+ ctx.restore();
5488
5510
  alertRegions.push({
5489
5511
  id: alert.id,
5490
- x: removeX,
5491
- y: labelY,
5492
- width: removeWidth,
5493
- height: labelHeight,
5512
+ x: buttonX,
5513
+ y: buttonY,
5514
+ width: buttonSize,
5515
+ height: buttonSize,
5494
5516
  part: "remove"
5495
5517
  });
5496
5518
  }
5497
- ctx.restore();
5498
- alertRegions.push({ id: alert.id, x: labelX, y: labelY, width: labelWidth - removeWidth, height: labelHeight, part: "line" });
5519
+ alertRegions.push({ id: alert.id, x: labelX, y: labelY, width: labelWidth, height: labelHeight, part: "line" });
5499
5520
  alertRegions.push({ id: alert.id, x: chartLeft, y: lineY - 5, width: chartRight - chartLeft, height: 10, part: "line" });
5500
5521
  };
5501
5522
  const drawOrderLine = (line, yFromPrice, chartLeft, chartTop, chartRight, chartBottom) => {
package/dist/index.js CHANGED
@@ -5400,6 +5400,32 @@ function createChart(element, options = {}) {
5400
5400
  ctx.fill();
5401
5401
  ctx.restore();
5402
5402
  };
5403
+ const drawTrashGlyph = (x, y, size, color) => {
5404
+ const w = size * 0.8;
5405
+ const h = size * 0.9;
5406
+ ctx.save();
5407
+ ctx.strokeStyle = color;
5408
+ ctx.lineWidth = 1.2;
5409
+ ctx.lineCap = "round";
5410
+ ctx.lineJoin = "round";
5411
+ ctx.beginPath();
5412
+ ctx.moveTo(x - w / 2, y - h * 0.28);
5413
+ ctx.lineTo(x + w / 2, y - h * 0.28);
5414
+ ctx.moveTo(x - w * 0.22, y - h * 0.28);
5415
+ ctx.lineTo(x - w * 0.22, y - h * 0.46);
5416
+ ctx.lineTo(x + w * 0.22, y - h * 0.46);
5417
+ ctx.lineTo(x + w * 0.22, y - h * 0.28);
5418
+ ctx.moveTo(x - w * 0.36, y - h * 0.28);
5419
+ ctx.lineTo(x - w * 0.28, y + h * 0.48);
5420
+ ctx.lineTo(x + w * 0.28, y + h * 0.48);
5421
+ ctx.lineTo(x + w * 0.36, y - h * 0.28);
5422
+ ctx.moveTo(x - w * 0.1, y - h * 0.08);
5423
+ ctx.lineTo(x - w * 0.1, y + h * 0.3);
5424
+ ctx.moveTo(x + w * 0.1, y - h * 0.08);
5425
+ ctx.lineTo(x + w * 0.1, y + h * 0.3);
5426
+ ctx.stroke();
5427
+ ctx.restore();
5428
+ };
5403
5429
  const drawAlertLine = (alert, yFromPrice, chartLeft, chartTop, chartRight, chartBottom) => {
5404
5430
  const lineY = getLineY(alert.price, yFromPrice, chartTop, chartBottom, false);
5405
5431
  if (lineY === null) return;
@@ -5418,13 +5444,11 @@ function createChart(element, options = {}) {
5418
5444
  ctx.restore();
5419
5445
  const fontSize = Math.max(8, axis.fontSize);
5420
5446
  ctx.font = `${fontSize}px ${mergedOptions.fontFamily}`;
5421
- const text = alert.label ? `${formatPrice(alert.price)} ${alert.label}` : formatPrice(alert.price);
5422
5447
  const paddingX = 6;
5423
5448
  const bellWidth = fontSize + 2;
5424
5449
  const labelHeight = 20;
5425
5450
  const hovered = hoveredAlertId === alert.id;
5426
- const removeWidth = hovered ? labelHeight : 0;
5427
- const contentWidth = Math.ceil(measureTextWidth(text)) + bellWidth + paddingX * 3 + removeWidth;
5451
+ const contentWidth = bellWidth + paddingX * 2;
5428
5452
  const labelWidth = getRightAxisLabelWidth(chartRight, contentWidth);
5429
5453
  const labelX = getRightAxisLabelX(chartRight);
5430
5454
  const labelY = placeRightAxisLabel(lineY - labelHeight / 2, labelHeight, chartTop, chartBottom - labelHeight);
@@ -5434,29 +5458,26 @@ function createChart(element, options = {}) {
5434
5458
  fillRoundedRect(Math.round(labelX), Math.round(labelY), labelWidth, labelHeight, 3);
5435
5459
  const inkColor = labelTextColorOn(color, "#101114");
5436
5460
  drawBellGlyph(labelX + paddingX + bellWidth / 2, labelY + labelHeight / 2, fontSize, inkColor);
5437
- drawText(text, labelX + paddingX * 2 + bellWidth, labelY + labelHeight / 2, "left", "middle", inkColor);
5461
+ ctx.restore();
5438
5462
  if (hovered) {
5439
- const removeX = labelX + labelWidth - removeWidth;
5440
- ctx.strokeStyle = inkColor;
5441
- ctx.lineWidth = 1.4;
5442
- const inset = 6;
5443
- ctx.beginPath();
5444
- ctx.moveTo(removeX + inset, labelY + inset);
5445
- ctx.lineTo(removeX + removeWidth - inset, labelY + labelHeight - inset);
5446
- ctx.moveTo(removeX + removeWidth - inset, labelY + inset);
5447
- ctx.lineTo(removeX + inset, labelY + labelHeight - inset);
5448
- ctx.stroke();
5463
+ const buttonSize = labelHeight;
5464
+ const buttonX = chartLeft + 10;
5465
+ const buttonY = lineY - buttonSize / 2;
5466
+ ctx.save();
5467
+ ctx.fillStyle = color;
5468
+ fillRoundedRect(Math.round(buttonX), Math.round(buttonY), buttonSize, buttonSize, 3);
5469
+ drawTrashGlyph(buttonX + buttonSize / 2, lineY, fontSize, inkColor);
5470
+ ctx.restore();
5449
5471
  alertRegions.push({
5450
5472
  id: alert.id,
5451
- x: removeX,
5452
- y: labelY,
5453
- width: removeWidth,
5454
- height: labelHeight,
5473
+ x: buttonX,
5474
+ y: buttonY,
5475
+ width: buttonSize,
5476
+ height: buttonSize,
5455
5477
  part: "remove"
5456
5478
  });
5457
5479
  }
5458
- ctx.restore();
5459
- alertRegions.push({ id: alert.id, x: labelX, y: labelY, width: labelWidth - removeWidth, height: labelHeight, part: "line" });
5480
+ alertRegions.push({ id: alert.id, x: labelX, y: labelY, width: labelWidth, height: labelHeight, part: "line" });
5460
5481
  alertRegions.push({ id: alert.id, x: chartLeft, y: lineY - 5, width: chartRight - chartLeft, height: 10, part: "line" });
5461
5482
  };
5462
5483
  const drawOrderLine = (line, yFromPrice, chartLeft, chartTop, chartRight, chartBottom) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperprop-charting-library",
3
- "version": "0.1.157",
3
+ "version": "0.1.158",
4
4
  "description": "Lightweight TypeScript charting core",
5
5
  "type": "module",
6
6
  "main": "./dist/hyperprop-charting-library.cjs",