hyperprop-charting-library 0.1.110 → 0.1.112

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.
@@ -1650,23 +1650,26 @@ function createChart(element, options = {}) {
1650
1650
  if (!mergedLine.visible || !Number.isFinite(renderPrice)) {
1651
1651
  return;
1652
1652
  }
1653
+ const rawLineY = yFromPrice(renderPrice);
1653
1654
  const lineY = getLineY(renderPrice, yFromPrice, chartTop, chartBottom, mergedLine.pinOutOfRange);
1655
+ if (Number.isFinite(mergedLine.fillToPrice) && Number.isFinite(rawLineY)) {
1656
+ const fillY = getLineY(mergedLine.fillToPrice, yFromPrice, chartTop, chartBottom, true);
1657
+ if (fillY !== null) {
1658
+ const zoneY = clamp(rawLineY, chartTop + 1, chartBottom - 1);
1659
+ const topY = Math.min(zoneY, fillY);
1660
+ const heightY = Math.abs(zoneY - fillY);
1661
+ if (heightY >= 1) {
1662
+ ctx.save();
1663
+ ctx.fillStyle = mergedLine.fillColor ?? "rgba(37,99,235,0.18)";
1664
+ ctx.fillRect(Math.round(chartLeft), Math.round(topY), Math.max(1, Math.round(chartRight - chartLeft)), Math.round(heightY));
1665
+ ctx.restore();
1666
+ }
1667
+ }
1668
+ }
1654
1669
  if (lineY === null) {
1655
1670
  return;
1656
1671
  }
1657
1672
  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)");
1658
- if (Number.isFinite(mergedLine.fillToPrice)) {
1659
- const fillY = getLineY(mergedLine.fillToPrice, yFromPrice, chartTop, chartBottom, true);
1660
- if (fillY === null) {
1661
- return;
1662
- }
1663
- const topY = Math.min(lineY, fillY);
1664
- const heightY = Math.max(1, Math.abs(lineY - fillY));
1665
- ctx.save();
1666
- ctx.fillStyle = mergedLine.fillColor ?? "rgba(37,99,235,0.18)";
1667
- ctx.fillRect(Math.round(chartLeft), Math.round(topY), Math.max(1, Math.round(chartRight - chartLeft)), Math.round(heightY));
1668
- ctx.restore();
1669
- }
1670
1673
  ctx.save();
1671
1674
  ctx.strokeStyle = color;
1672
1675
  ctx.lineWidth = Math.max(1, mergedLine.thickness);
@@ -4617,52 +4620,55 @@ function createChart(element, options = {}) {
4617
4620
  return;
4618
4621
  }
4619
4622
  }
4620
- const crosshairButtonRegion = getCrosshairPriceActionRegion(point.x, point.y);
4621
- if (crosshairButtonRegion) {
4622
- crosshairPriceActionHandler?.({
4623
- x: point.x,
4624
- y: point.y,
4625
- price: crosshairButtonRegion.price
4626
- });
4627
- return;
4628
- }
4629
- const orderRegion = getOrderActionRegion(point.x, point.y);
4630
- if (orderRegion) {
4631
- if (orderRegion.draggable) {
4632
- activePointerId = event.pointerId;
4633
- const startPrice = roundToPricePrecision(orderRegion.line.price);
4634
- actionDragState = {
4623
+ const drawingToolCapturesPointer = activeDrawingTool !== null || draftDrawing !== null;
4624
+ if (!drawingToolCapturesPointer) {
4625
+ const crosshairButtonRegion = getCrosshairPriceActionRegion(point.x, point.y);
4626
+ if (crosshairButtonRegion) {
4627
+ crosshairPriceActionHandler?.({
4628
+ x: point.x,
4629
+ y: point.y,
4630
+ price: crosshairButtonRegion.price
4631
+ });
4632
+ return;
4633
+ }
4634
+ const orderRegion = getOrderActionRegion(point.x, point.y);
4635
+ if (orderRegion) {
4636
+ if (orderRegion.draggable) {
4637
+ activePointerId = event.pointerId;
4638
+ const startPrice = roundToPricePrecision(orderRegion.line.price);
4639
+ actionDragState = {
4640
+ orderId: orderRegion.orderId,
4641
+ action: orderRegion.action,
4642
+ startPrice,
4643
+ lastPrice: startPrice,
4644
+ moved: false
4645
+ };
4646
+ canvas.setPointerCapture(event.pointerId);
4647
+ canvas.style.cursor = "ns-resize";
4648
+ setCrosshairPoint(null);
4649
+ return;
4650
+ }
4651
+ setCrosshairPoint(null);
4652
+ orderActionHandler?.({
4635
4653
  orderId: orderRegion.orderId,
4636
4654
  action: orderRegion.action,
4637
- startPrice,
4638
- lastPrice: startPrice,
4639
- moved: false
4655
+ line: orderRegion.line
4656
+ });
4657
+ return;
4658
+ }
4659
+ const orderDragRegion = getOrderDragRegion(point.x, point.y);
4660
+ if (orderDragRegion) {
4661
+ activePointerId = event.pointerId;
4662
+ orderDragState = {
4663
+ orderId: orderDragRegion.orderId,
4664
+ startPrice: orderDragRegion.price,
4665
+ lastPrice: orderDragRegion.price
4640
4666
  };
4641
4667
  canvas.setPointerCapture(event.pointerId);
4642
4668
  canvas.style.cursor = "ns-resize";
4643
4669
  setCrosshairPoint(null);
4644
4670
  return;
4645
4671
  }
4646
- setCrosshairPoint(null);
4647
- orderActionHandler?.({
4648
- orderId: orderRegion.orderId,
4649
- action: orderRegion.action,
4650
- line: orderRegion.line
4651
- });
4652
- return;
4653
- }
4654
- const orderDragRegion = getOrderDragRegion(point.x, point.y);
4655
- if (orderDragRegion) {
4656
- activePointerId = event.pointerId;
4657
- orderDragState = {
4658
- orderId: orderDragRegion.orderId,
4659
- startPrice: orderDragRegion.price,
4660
- lastPrice: orderDragRegion.price
4661
- };
4662
- canvas.setPointerCapture(event.pointerId);
4663
- canvas.style.cursor = "ns-resize";
4664
- setCrosshairPoint(null);
4665
- return;
4666
4672
  }
4667
4673
  const region = getHitRegion(point.x, point.y);
4668
4674
  if (region === "outside") {
@@ -4839,23 +4845,26 @@ function createChart(element, options = {}) {
4839
4845
  return;
4840
4846
  }
4841
4847
  if (!isDragging || !dragMode) {
4842
- const crosshairButtonRegion = getCrosshairPriceActionRegion(point.x, point.y);
4843
- if (crosshairButtonRegion) {
4844
- canvas.style.cursor = "pointer";
4845
- setCrosshairPoint(point);
4846
- return;
4847
- }
4848
- const orderRegion = getOrderActionRegion(point.x, point.y);
4849
- if (orderRegion) {
4850
- canvas.style.cursor = orderRegion.draggable ? "ns-resize" : "pointer";
4851
- setCrosshairPoint(null);
4852
- return;
4853
- }
4854
- const orderDragRegion = getOrderDragRegion(point.x, point.y);
4855
- if (orderDragRegion) {
4856
- canvas.style.cursor = "ns-resize";
4857
- setCrosshairPoint(null);
4858
- return;
4848
+ const drawingToolOwnsHover = activeDrawingTool !== null || draftDrawing !== null;
4849
+ if (!drawingToolOwnsHover) {
4850
+ const crosshairButtonRegion = getCrosshairPriceActionRegion(point.x, point.y);
4851
+ if (crosshairButtonRegion) {
4852
+ canvas.style.cursor = "pointer";
4853
+ setCrosshairPoint(point);
4854
+ return;
4855
+ }
4856
+ const orderRegion = getOrderActionRegion(point.x, point.y);
4857
+ if (orderRegion) {
4858
+ canvas.style.cursor = orderRegion.draggable ? "ns-resize" : "pointer";
4859
+ setCrosshairPoint(null);
4860
+ return;
4861
+ }
4862
+ const orderDragRegion = getOrderDragRegion(point.x, point.y);
4863
+ if (orderDragRegion) {
4864
+ canvas.style.cursor = "ns-resize";
4865
+ setCrosshairPoint(null);
4866
+ return;
4867
+ }
4859
4868
  }
4860
4869
  if (!activeDrawingTool && getDrawingHit(point.x, point.y)) {
4861
4870
  const drawingHit = getDrawingHit(point.x, point.y);
@@ -1624,23 +1624,26 @@ function createChart(element, options = {}) {
1624
1624
  if (!mergedLine.visible || !Number.isFinite(renderPrice)) {
1625
1625
  return;
1626
1626
  }
1627
+ const rawLineY = yFromPrice(renderPrice);
1627
1628
  const lineY = getLineY(renderPrice, yFromPrice, chartTop, chartBottom, mergedLine.pinOutOfRange);
1629
+ if (Number.isFinite(mergedLine.fillToPrice) && Number.isFinite(rawLineY)) {
1630
+ const fillY = getLineY(mergedLine.fillToPrice, yFromPrice, chartTop, chartBottom, true);
1631
+ if (fillY !== null) {
1632
+ const zoneY = clamp(rawLineY, chartTop + 1, chartBottom - 1);
1633
+ const topY = Math.min(zoneY, fillY);
1634
+ const heightY = Math.abs(zoneY - fillY);
1635
+ if (heightY >= 1) {
1636
+ ctx.save();
1637
+ ctx.fillStyle = mergedLine.fillColor ?? "rgba(37,99,235,0.18)";
1638
+ ctx.fillRect(Math.round(chartLeft), Math.round(topY), Math.max(1, Math.round(chartRight - chartLeft)), Math.round(heightY));
1639
+ ctx.restore();
1640
+ }
1641
+ }
1642
+ }
1628
1643
  if (lineY === null) {
1629
1644
  return;
1630
1645
  }
1631
1646
  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)");
1632
- if (Number.isFinite(mergedLine.fillToPrice)) {
1633
- const fillY = getLineY(mergedLine.fillToPrice, yFromPrice, chartTop, chartBottom, true);
1634
- if (fillY === null) {
1635
- return;
1636
- }
1637
- const topY = Math.min(lineY, fillY);
1638
- const heightY = Math.max(1, Math.abs(lineY - fillY));
1639
- ctx.save();
1640
- ctx.fillStyle = mergedLine.fillColor ?? "rgba(37,99,235,0.18)";
1641
- ctx.fillRect(Math.round(chartLeft), Math.round(topY), Math.max(1, Math.round(chartRight - chartLeft)), Math.round(heightY));
1642
- ctx.restore();
1643
- }
1644
1647
  ctx.save();
1645
1648
  ctx.strokeStyle = color;
1646
1649
  ctx.lineWidth = Math.max(1, mergedLine.thickness);
@@ -4591,52 +4594,55 @@ function createChart(element, options = {}) {
4591
4594
  return;
4592
4595
  }
4593
4596
  }
4594
- const crosshairButtonRegion = getCrosshairPriceActionRegion(point.x, point.y);
4595
- if (crosshairButtonRegion) {
4596
- crosshairPriceActionHandler?.({
4597
- x: point.x,
4598
- y: point.y,
4599
- price: crosshairButtonRegion.price
4600
- });
4601
- return;
4602
- }
4603
- const orderRegion = getOrderActionRegion(point.x, point.y);
4604
- if (orderRegion) {
4605
- if (orderRegion.draggable) {
4606
- activePointerId = event.pointerId;
4607
- const startPrice = roundToPricePrecision(orderRegion.line.price);
4608
- actionDragState = {
4597
+ const drawingToolCapturesPointer = activeDrawingTool !== null || draftDrawing !== null;
4598
+ if (!drawingToolCapturesPointer) {
4599
+ const crosshairButtonRegion = getCrosshairPriceActionRegion(point.x, point.y);
4600
+ if (crosshairButtonRegion) {
4601
+ crosshairPriceActionHandler?.({
4602
+ x: point.x,
4603
+ y: point.y,
4604
+ price: crosshairButtonRegion.price
4605
+ });
4606
+ return;
4607
+ }
4608
+ const orderRegion = getOrderActionRegion(point.x, point.y);
4609
+ if (orderRegion) {
4610
+ if (orderRegion.draggable) {
4611
+ activePointerId = event.pointerId;
4612
+ const startPrice = roundToPricePrecision(orderRegion.line.price);
4613
+ actionDragState = {
4614
+ orderId: orderRegion.orderId,
4615
+ action: orderRegion.action,
4616
+ startPrice,
4617
+ lastPrice: startPrice,
4618
+ moved: false
4619
+ };
4620
+ canvas.setPointerCapture(event.pointerId);
4621
+ canvas.style.cursor = "ns-resize";
4622
+ setCrosshairPoint(null);
4623
+ return;
4624
+ }
4625
+ setCrosshairPoint(null);
4626
+ orderActionHandler?.({
4609
4627
  orderId: orderRegion.orderId,
4610
4628
  action: orderRegion.action,
4611
- startPrice,
4612
- lastPrice: startPrice,
4613
- moved: false
4629
+ line: orderRegion.line
4630
+ });
4631
+ return;
4632
+ }
4633
+ const orderDragRegion = getOrderDragRegion(point.x, point.y);
4634
+ if (orderDragRegion) {
4635
+ activePointerId = event.pointerId;
4636
+ orderDragState = {
4637
+ orderId: orderDragRegion.orderId,
4638
+ startPrice: orderDragRegion.price,
4639
+ lastPrice: orderDragRegion.price
4614
4640
  };
4615
4641
  canvas.setPointerCapture(event.pointerId);
4616
4642
  canvas.style.cursor = "ns-resize";
4617
4643
  setCrosshairPoint(null);
4618
4644
  return;
4619
4645
  }
4620
- setCrosshairPoint(null);
4621
- orderActionHandler?.({
4622
- orderId: orderRegion.orderId,
4623
- action: orderRegion.action,
4624
- line: orderRegion.line
4625
- });
4626
- return;
4627
- }
4628
- const orderDragRegion = getOrderDragRegion(point.x, point.y);
4629
- if (orderDragRegion) {
4630
- activePointerId = event.pointerId;
4631
- orderDragState = {
4632
- orderId: orderDragRegion.orderId,
4633
- startPrice: orderDragRegion.price,
4634
- lastPrice: orderDragRegion.price
4635
- };
4636
- canvas.setPointerCapture(event.pointerId);
4637
- canvas.style.cursor = "ns-resize";
4638
- setCrosshairPoint(null);
4639
- return;
4640
4646
  }
4641
4647
  const region = getHitRegion(point.x, point.y);
4642
4648
  if (region === "outside") {
@@ -4813,23 +4819,26 @@ function createChart(element, options = {}) {
4813
4819
  return;
4814
4820
  }
4815
4821
  if (!isDragging || !dragMode) {
4816
- const crosshairButtonRegion = getCrosshairPriceActionRegion(point.x, point.y);
4817
- if (crosshairButtonRegion) {
4818
- canvas.style.cursor = "pointer";
4819
- setCrosshairPoint(point);
4820
- return;
4821
- }
4822
- const orderRegion = getOrderActionRegion(point.x, point.y);
4823
- if (orderRegion) {
4824
- canvas.style.cursor = orderRegion.draggable ? "ns-resize" : "pointer";
4825
- setCrosshairPoint(null);
4826
- return;
4827
- }
4828
- const orderDragRegion = getOrderDragRegion(point.x, point.y);
4829
- if (orderDragRegion) {
4830
- canvas.style.cursor = "ns-resize";
4831
- setCrosshairPoint(null);
4832
- return;
4822
+ const drawingToolOwnsHover = activeDrawingTool !== null || draftDrawing !== null;
4823
+ if (!drawingToolOwnsHover) {
4824
+ const crosshairButtonRegion = getCrosshairPriceActionRegion(point.x, point.y);
4825
+ if (crosshairButtonRegion) {
4826
+ canvas.style.cursor = "pointer";
4827
+ setCrosshairPoint(point);
4828
+ return;
4829
+ }
4830
+ const orderRegion = getOrderActionRegion(point.x, point.y);
4831
+ if (orderRegion) {
4832
+ canvas.style.cursor = orderRegion.draggable ? "ns-resize" : "pointer";
4833
+ setCrosshairPoint(null);
4834
+ return;
4835
+ }
4836
+ const orderDragRegion = getOrderDragRegion(point.x, point.y);
4837
+ if (orderDragRegion) {
4838
+ canvas.style.cursor = "ns-resize";
4839
+ setCrosshairPoint(null);
4840
+ return;
4841
+ }
4833
4842
  }
4834
4843
  if (!activeDrawingTool && getDrawingHit(point.x, point.y)) {
4835
4844
  const drawingHit = getDrawingHit(point.x, point.y);
package/dist/index.cjs CHANGED
@@ -1650,23 +1650,26 @@ function createChart(element, options = {}) {
1650
1650
  if (!mergedLine.visible || !Number.isFinite(renderPrice)) {
1651
1651
  return;
1652
1652
  }
1653
+ const rawLineY = yFromPrice(renderPrice);
1653
1654
  const lineY = getLineY(renderPrice, yFromPrice, chartTop, chartBottom, mergedLine.pinOutOfRange);
1655
+ if (Number.isFinite(mergedLine.fillToPrice) && Number.isFinite(rawLineY)) {
1656
+ const fillY = getLineY(mergedLine.fillToPrice, yFromPrice, chartTop, chartBottom, true);
1657
+ if (fillY !== null) {
1658
+ const zoneY = clamp(rawLineY, chartTop + 1, chartBottom - 1);
1659
+ const topY = Math.min(zoneY, fillY);
1660
+ const heightY = Math.abs(zoneY - fillY);
1661
+ if (heightY >= 1) {
1662
+ ctx.save();
1663
+ ctx.fillStyle = mergedLine.fillColor ?? "rgba(37,99,235,0.18)";
1664
+ ctx.fillRect(Math.round(chartLeft), Math.round(topY), Math.max(1, Math.round(chartRight - chartLeft)), Math.round(heightY));
1665
+ ctx.restore();
1666
+ }
1667
+ }
1668
+ }
1654
1669
  if (lineY === null) {
1655
1670
  return;
1656
1671
  }
1657
1672
  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)");
1658
- if (Number.isFinite(mergedLine.fillToPrice)) {
1659
- const fillY = getLineY(mergedLine.fillToPrice, yFromPrice, chartTop, chartBottom, true);
1660
- if (fillY === null) {
1661
- return;
1662
- }
1663
- const topY = Math.min(lineY, fillY);
1664
- const heightY = Math.max(1, Math.abs(lineY - fillY));
1665
- ctx.save();
1666
- ctx.fillStyle = mergedLine.fillColor ?? "rgba(37,99,235,0.18)";
1667
- ctx.fillRect(Math.round(chartLeft), Math.round(topY), Math.max(1, Math.round(chartRight - chartLeft)), Math.round(heightY));
1668
- ctx.restore();
1669
- }
1670
1673
  ctx.save();
1671
1674
  ctx.strokeStyle = color;
1672
1675
  ctx.lineWidth = Math.max(1, mergedLine.thickness);
@@ -4617,52 +4620,55 @@ function createChart(element, options = {}) {
4617
4620
  return;
4618
4621
  }
4619
4622
  }
4620
- const crosshairButtonRegion = getCrosshairPriceActionRegion(point.x, point.y);
4621
- if (crosshairButtonRegion) {
4622
- crosshairPriceActionHandler?.({
4623
- x: point.x,
4624
- y: point.y,
4625
- price: crosshairButtonRegion.price
4626
- });
4627
- return;
4628
- }
4629
- const orderRegion = getOrderActionRegion(point.x, point.y);
4630
- if (orderRegion) {
4631
- if (orderRegion.draggable) {
4632
- activePointerId = event.pointerId;
4633
- const startPrice = roundToPricePrecision(orderRegion.line.price);
4634
- actionDragState = {
4623
+ const drawingToolCapturesPointer = activeDrawingTool !== null || draftDrawing !== null;
4624
+ if (!drawingToolCapturesPointer) {
4625
+ const crosshairButtonRegion = getCrosshairPriceActionRegion(point.x, point.y);
4626
+ if (crosshairButtonRegion) {
4627
+ crosshairPriceActionHandler?.({
4628
+ x: point.x,
4629
+ y: point.y,
4630
+ price: crosshairButtonRegion.price
4631
+ });
4632
+ return;
4633
+ }
4634
+ const orderRegion = getOrderActionRegion(point.x, point.y);
4635
+ if (orderRegion) {
4636
+ if (orderRegion.draggable) {
4637
+ activePointerId = event.pointerId;
4638
+ const startPrice = roundToPricePrecision(orderRegion.line.price);
4639
+ actionDragState = {
4640
+ orderId: orderRegion.orderId,
4641
+ action: orderRegion.action,
4642
+ startPrice,
4643
+ lastPrice: startPrice,
4644
+ moved: false
4645
+ };
4646
+ canvas.setPointerCapture(event.pointerId);
4647
+ canvas.style.cursor = "ns-resize";
4648
+ setCrosshairPoint(null);
4649
+ return;
4650
+ }
4651
+ setCrosshairPoint(null);
4652
+ orderActionHandler?.({
4635
4653
  orderId: orderRegion.orderId,
4636
4654
  action: orderRegion.action,
4637
- startPrice,
4638
- lastPrice: startPrice,
4639
- moved: false
4655
+ line: orderRegion.line
4656
+ });
4657
+ return;
4658
+ }
4659
+ const orderDragRegion = getOrderDragRegion(point.x, point.y);
4660
+ if (orderDragRegion) {
4661
+ activePointerId = event.pointerId;
4662
+ orderDragState = {
4663
+ orderId: orderDragRegion.orderId,
4664
+ startPrice: orderDragRegion.price,
4665
+ lastPrice: orderDragRegion.price
4640
4666
  };
4641
4667
  canvas.setPointerCapture(event.pointerId);
4642
4668
  canvas.style.cursor = "ns-resize";
4643
4669
  setCrosshairPoint(null);
4644
4670
  return;
4645
4671
  }
4646
- setCrosshairPoint(null);
4647
- orderActionHandler?.({
4648
- orderId: orderRegion.orderId,
4649
- action: orderRegion.action,
4650
- line: orderRegion.line
4651
- });
4652
- return;
4653
- }
4654
- const orderDragRegion = getOrderDragRegion(point.x, point.y);
4655
- if (orderDragRegion) {
4656
- activePointerId = event.pointerId;
4657
- orderDragState = {
4658
- orderId: orderDragRegion.orderId,
4659
- startPrice: orderDragRegion.price,
4660
- lastPrice: orderDragRegion.price
4661
- };
4662
- canvas.setPointerCapture(event.pointerId);
4663
- canvas.style.cursor = "ns-resize";
4664
- setCrosshairPoint(null);
4665
- return;
4666
4672
  }
4667
4673
  const region = getHitRegion(point.x, point.y);
4668
4674
  if (region === "outside") {
@@ -4839,23 +4845,26 @@ function createChart(element, options = {}) {
4839
4845
  return;
4840
4846
  }
4841
4847
  if (!isDragging || !dragMode) {
4842
- const crosshairButtonRegion = getCrosshairPriceActionRegion(point.x, point.y);
4843
- if (crosshairButtonRegion) {
4844
- canvas.style.cursor = "pointer";
4845
- setCrosshairPoint(point);
4846
- return;
4847
- }
4848
- const orderRegion = getOrderActionRegion(point.x, point.y);
4849
- if (orderRegion) {
4850
- canvas.style.cursor = orderRegion.draggable ? "ns-resize" : "pointer";
4851
- setCrosshairPoint(null);
4852
- return;
4853
- }
4854
- const orderDragRegion = getOrderDragRegion(point.x, point.y);
4855
- if (orderDragRegion) {
4856
- canvas.style.cursor = "ns-resize";
4857
- setCrosshairPoint(null);
4858
- return;
4848
+ const drawingToolOwnsHover = activeDrawingTool !== null || draftDrawing !== null;
4849
+ if (!drawingToolOwnsHover) {
4850
+ const crosshairButtonRegion = getCrosshairPriceActionRegion(point.x, point.y);
4851
+ if (crosshairButtonRegion) {
4852
+ canvas.style.cursor = "pointer";
4853
+ setCrosshairPoint(point);
4854
+ return;
4855
+ }
4856
+ const orderRegion = getOrderActionRegion(point.x, point.y);
4857
+ if (orderRegion) {
4858
+ canvas.style.cursor = orderRegion.draggable ? "ns-resize" : "pointer";
4859
+ setCrosshairPoint(null);
4860
+ return;
4861
+ }
4862
+ const orderDragRegion = getOrderDragRegion(point.x, point.y);
4863
+ if (orderDragRegion) {
4864
+ canvas.style.cursor = "ns-resize";
4865
+ setCrosshairPoint(null);
4866
+ return;
4867
+ }
4859
4868
  }
4860
4869
  if (!activeDrawingTool && getDrawingHit(point.x, point.y)) {
4861
4870
  const drawingHit = getDrawingHit(point.x, point.y);
package/dist/index.js CHANGED
@@ -1624,23 +1624,26 @@ function createChart(element, options = {}) {
1624
1624
  if (!mergedLine.visible || !Number.isFinite(renderPrice)) {
1625
1625
  return;
1626
1626
  }
1627
+ const rawLineY = yFromPrice(renderPrice);
1627
1628
  const lineY = getLineY(renderPrice, yFromPrice, chartTop, chartBottom, mergedLine.pinOutOfRange);
1629
+ if (Number.isFinite(mergedLine.fillToPrice) && Number.isFinite(rawLineY)) {
1630
+ const fillY = getLineY(mergedLine.fillToPrice, yFromPrice, chartTop, chartBottom, true);
1631
+ if (fillY !== null) {
1632
+ const zoneY = clamp(rawLineY, chartTop + 1, chartBottom - 1);
1633
+ const topY = Math.min(zoneY, fillY);
1634
+ const heightY = Math.abs(zoneY - fillY);
1635
+ if (heightY >= 1) {
1636
+ ctx.save();
1637
+ ctx.fillStyle = mergedLine.fillColor ?? "rgba(37,99,235,0.18)";
1638
+ ctx.fillRect(Math.round(chartLeft), Math.round(topY), Math.max(1, Math.round(chartRight - chartLeft)), Math.round(heightY));
1639
+ ctx.restore();
1640
+ }
1641
+ }
1642
+ }
1628
1643
  if (lineY === null) {
1629
1644
  return;
1630
1645
  }
1631
1646
  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)");
1632
- if (Number.isFinite(mergedLine.fillToPrice)) {
1633
- const fillY = getLineY(mergedLine.fillToPrice, yFromPrice, chartTop, chartBottom, true);
1634
- if (fillY === null) {
1635
- return;
1636
- }
1637
- const topY = Math.min(lineY, fillY);
1638
- const heightY = Math.max(1, Math.abs(lineY - fillY));
1639
- ctx.save();
1640
- ctx.fillStyle = mergedLine.fillColor ?? "rgba(37,99,235,0.18)";
1641
- ctx.fillRect(Math.round(chartLeft), Math.round(topY), Math.max(1, Math.round(chartRight - chartLeft)), Math.round(heightY));
1642
- ctx.restore();
1643
- }
1644
1647
  ctx.save();
1645
1648
  ctx.strokeStyle = color;
1646
1649
  ctx.lineWidth = Math.max(1, mergedLine.thickness);
@@ -4591,52 +4594,55 @@ function createChart(element, options = {}) {
4591
4594
  return;
4592
4595
  }
4593
4596
  }
4594
- const crosshairButtonRegion = getCrosshairPriceActionRegion(point.x, point.y);
4595
- if (crosshairButtonRegion) {
4596
- crosshairPriceActionHandler?.({
4597
- x: point.x,
4598
- y: point.y,
4599
- price: crosshairButtonRegion.price
4600
- });
4601
- return;
4602
- }
4603
- const orderRegion = getOrderActionRegion(point.x, point.y);
4604
- if (orderRegion) {
4605
- if (orderRegion.draggable) {
4606
- activePointerId = event.pointerId;
4607
- const startPrice = roundToPricePrecision(orderRegion.line.price);
4608
- actionDragState = {
4597
+ const drawingToolCapturesPointer = activeDrawingTool !== null || draftDrawing !== null;
4598
+ if (!drawingToolCapturesPointer) {
4599
+ const crosshairButtonRegion = getCrosshairPriceActionRegion(point.x, point.y);
4600
+ if (crosshairButtonRegion) {
4601
+ crosshairPriceActionHandler?.({
4602
+ x: point.x,
4603
+ y: point.y,
4604
+ price: crosshairButtonRegion.price
4605
+ });
4606
+ return;
4607
+ }
4608
+ const orderRegion = getOrderActionRegion(point.x, point.y);
4609
+ if (orderRegion) {
4610
+ if (orderRegion.draggable) {
4611
+ activePointerId = event.pointerId;
4612
+ const startPrice = roundToPricePrecision(orderRegion.line.price);
4613
+ actionDragState = {
4614
+ orderId: orderRegion.orderId,
4615
+ action: orderRegion.action,
4616
+ startPrice,
4617
+ lastPrice: startPrice,
4618
+ moved: false
4619
+ };
4620
+ canvas.setPointerCapture(event.pointerId);
4621
+ canvas.style.cursor = "ns-resize";
4622
+ setCrosshairPoint(null);
4623
+ return;
4624
+ }
4625
+ setCrosshairPoint(null);
4626
+ orderActionHandler?.({
4609
4627
  orderId: orderRegion.orderId,
4610
4628
  action: orderRegion.action,
4611
- startPrice,
4612
- lastPrice: startPrice,
4613
- moved: false
4629
+ line: orderRegion.line
4630
+ });
4631
+ return;
4632
+ }
4633
+ const orderDragRegion = getOrderDragRegion(point.x, point.y);
4634
+ if (orderDragRegion) {
4635
+ activePointerId = event.pointerId;
4636
+ orderDragState = {
4637
+ orderId: orderDragRegion.orderId,
4638
+ startPrice: orderDragRegion.price,
4639
+ lastPrice: orderDragRegion.price
4614
4640
  };
4615
4641
  canvas.setPointerCapture(event.pointerId);
4616
4642
  canvas.style.cursor = "ns-resize";
4617
4643
  setCrosshairPoint(null);
4618
4644
  return;
4619
4645
  }
4620
- setCrosshairPoint(null);
4621
- orderActionHandler?.({
4622
- orderId: orderRegion.orderId,
4623
- action: orderRegion.action,
4624
- line: orderRegion.line
4625
- });
4626
- return;
4627
- }
4628
- const orderDragRegion = getOrderDragRegion(point.x, point.y);
4629
- if (orderDragRegion) {
4630
- activePointerId = event.pointerId;
4631
- orderDragState = {
4632
- orderId: orderDragRegion.orderId,
4633
- startPrice: orderDragRegion.price,
4634
- lastPrice: orderDragRegion.price
4635
- };
4636
- canvas.setPointerCapture(event.pointerId);
4637
- canvas.style.cursor = "ns-resize";
4638
- setCrosshairPoint(null);
4639
- return;
4640
4646
  }
4641
4647
  const region = getHitRegion(point.x, point.y);
4642
4648
  if (region === "outside") {
@@ -4813,23 +4819,26 @@ function createChart(element, options = {}) {
4813
4819
  return;
4814
4820
  }
4815
4821
  if (!isDragging || !dragMode) {
4816
- const crosshairButtonRegion = getCrosshairPriceActionRegion(point.x, point.y);
4817
- if (crosshairButtonRegion) {
4818
- canvas.style.cursor = "pointer";
4819
- setCrosshairPoint(point);
4820
- return;
4821
- }
4822
- const orderRegion = getOrderActionRegion(point.x, point.y);
4823
- if (orderRegion) {
4824
- canvas.style.cursor = orderRegion.draggable ? "ns-resize" : "pointer";
4825
- setCrosshairPoint(null);
4826
- return;
4827
- }
4828
- const orderDragRegion = getOrderDragRegion(point.x, point.y);
4829
- if (orderDragRegion) {
4830
- canvas.style.cursor = "ns-resize";
4831
- setCrosshairPoint(null);
4832
- return;
4822
+ const drawingToolOwnsHover = activeDrawingTool !== null || draftDrawing !== null;
4823
+ if (!drawingToolOwnsHover) {
4824
+ const crosshairButtonRegion = getCrosshairPriceActionRegion(point.x, point.y);
4825
+ if (crosshairButtonRegion) {
4826
+ canvas.style.cursor = "pointer";
4827
+ setCrosshairPoint(point);
4828
+ return;
4829
+ }
4830
+ const orderRegion = getOrderActionRegion(point.x, point.y);
4831
+ if (orderRegion) {
4832
+ canvas.style.cursor = orderRegion.draggable ? "ns-resize" : "pointer";
4833
+ setCrosshairPoint(null);
4834
+ return;
4835
+ }
4836
+ const orderDragRegion = getOrderDragRegion(point.x, point.y);
4837
+ if (orderDragRegion) {
4838
+ canvas.style.cursor = "ns-resize";
4839
+ setCrosshairPoint(null);
4840
+ return;
4841
+ }
4833
4842
  }
4834
4843
  if (!activeDrawingTool && getDrawingHit(point.x, point.y)) {
4835
4844
  const drawingHit = getDrawingHit(point.x, point.y);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperprop-charting-library",
3
- "version": "0.1.110",
3
+ "version": "0.1.112",
4
4
  "description": "Lightweight TypeScript charting core",
5
5
  "type": "module",
6
6
  "main": "./dist/hyperprop-charting-library.cjs",