hyperprop-charting-library 0.1.63 → 0.1.64
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.
- package/dist/hyperprop-charting-library.cjs +48 -2
- package/dist/hyperprop-charting-library.js +48 -2
- package/dist/index.cjs +48 -2
- package/dist/index.js +48 -2
- package/package.json +1 -1
|
@@ -1065,6 +1065,10 @@ function createChart(element, options = {}) {
|
|
|
1065
1065
|
}
|
|
1066
1066
|
canvas.style.display = "block";
|
|
1067
1067
|
canvas.style.touchAction = "none";
|
|
1068
|
+
canvas.style.userSelect = "none";
|
|
1069
|
+
canvas.style.setProperty("-webkit-user-select", "none");
|
|
1070
|
+
canvas.style.setProperty("-webkit-touch-callout", "none");
|
|
1071
|
+
canvas.setAttribute("draggable", "false");
|
|
1068
1072
|
element.innerHTML = "";
|
|
1069
1073
|
element.appendChild(canvas);
|
|
1070
1074
|
const margin = { top: 16, right: 72, bottom: 34, left: 12 };
|
|
@@ -3555,6 +3559,9 @@ function createChart(element, options = {}) {
|
|
|
3555
3559
|
draw();
|
|
3556
3560
|
};
|
|
3557
3561
|
const onPointerDown = (event) => {
|
|
3562
|
+
if (event.pointerType === "touch" || event.pointerType === "pen") {
|
|
3563
|
+
event.preventDefault();
|
|
3564
|
+
}
|
|
3558
3565
|
const point = getCanvasPoint(event);
|
|
3559
3566
|
if (event.pointerType === "touch") {
|
|
3560
3567
|
touchPointers.set(event.pointerId, point);
|
|
@@ -3653,12 +3660,29 @@ function createChart(element, options = {}) {
|
|
|
3653
3660
|
isDragging = true;
|
|
3654
3661
|
dragMode = region;
|
|
3655
3662
|
activePointerId = event.pointerId;
|
|
3656
|
-
|
|
3663
|
+
const crosshairDrag = (event.pointerType === "touch" || event.pointerType === "pen") && region === "plot";
|
|
3664
|
+
pointerDownInfo = {
|
|
3665
|
+
pointerId: event.pointerId,
|
|
3666
|
+
pointerType: event.pointerType,
|
|
3667
|
+
x: point.x,
|
|
3668
|
+
y: point.y,
|
|
3669
|
+
region,
|
|
3670
|
+
moved: false,
|
|
3671
|
+
crosshairDrag
|
|
3672
|
+
};
|
|
3657
3673
|
lastPointerX = point.x;
|
|
3658
3674
|
lastPointerY = point.y;
|
|
3659
3675
|
canvas.setPointerCapture(event.pointerId);
|
|
3676
|
+
if (crosshairDrag) {
|
|
3677
|
+
canvas.style.cursor = "crosshair";
|
|
3678
|
+
setCrosshairPoint(point);
|
|
3679
|
+
emitCrosshairMove(point.x, point.y, "plot");
|
|
3680
|
+
}
|
|
3660
3681
|
};
|
|
3661
3682
|
const onPointerMove = (event) => {
|
|
3683
|
+
if (event.pointerType === "touch" || event.pointerType === "pen") {
|
|
3684
|
+
event.preventDefault();
|
|
3685
|
+
}
|
|
3662
3686
|
const point = getCanvasPoint(event);
|
|
3663
3687
|
if (event.pointerType === "touch" && touchPointers.has(event.pointerId)) {
|
|
3664
3688
|
touchPointers.set(event.pointerId, point);
|
|
@@ -3681,6 +3705,16 @@ function createChart(element, options = {}) {
|
|
|
3681
3705
|
pointerDownInfo.moved = true;
|
|
3682
3706
|
}
|
|
3683
3707
|
}
|
|
3708
|
+
if (pointerDownInfo?.crosshairDrag && pointerDownInfo.pointerId === event.pointerId) {
|
|
3709
|
+
if (getHitRegion(point.x, point.y) === "plot") {
|
|
3710
|
+
canvas.style.cursor = "crosshair";
|
|
3711
|
+
setCrosshairPoint(point);
|
|
3712
|
+
emitCrosshairMove(point.x, point.y, "plot");
|
|
3713
|
+
lastPointerX = point.x;
|
|
3714
|
+
lastPointerY = point.y;
|
|
3715
|
+
}
|
|
3716
|
+
return;
|
|
3717
|
+
}
|
|
3684
3718
|
if (drawingDragState) {
|
|
3685
3719
|
if (activePointerId !== null && event.pointerId !== activePointerId) {
|
|
3686
3720
|
return;
|
|
@@ -3894,7 +3928,13 @@ function createChart(element, options = {}) {
|
|
|
3894
3928
|
activePointerId = null;
|
|
3895
3929
|
canvas.style.cursor = "default";
|
|
3896
3930
|
if (event && pointerDownInfo && event.pointerId === pointerDownInfo.pointerId) {
|
|
3897
|
-
if (
|
|
3931
|
+
if (pointerDownInfo.crosshairDrag) {
|
|
3932
|
+
const point = getCanvasPoint(event);
|
|
3933
|
+
if (getHitRegion(point.x, point.y) === "plot") {
|
|
3934
|
+
setCrosshairPoint(point);
|
|
3935
|
+
emitCrosshairMove(point.x, point.y, "plot");
|
|
3936
|
+
}
|
|
3937
|
+
} else if (!pointerDownInfo.moved) {
|
|
3898
3938
|
const clickPrice = pointerDownInfo.region === "plot" ? roundToPricePrecision(priceFromCanvasY(pointerDownInfo.y)) : void 0;
|
|
3899
3939
|
chartClickHandler?.({
|
|
3900
3940
|
x: pointerDownInfo.x,
|
|
@@ -3941,6 +3981,7 @@ function createChart(element, options = {}) {
|
|
|
3941
3981
|
zoomX(factor, point.x);
|
|
3942
3982
|
};
|
|
3943
3983
|
const onDoubleClick = (event) => {
|
|
3984
|
+
event.preventDefault();
|
|
3944
3985
|
if (!doubleClickEnabled) {
|
|
3945
3986
|
return;
|
|
3946
3987
|
}
|
|
@@ -3966,6 +4007,9 @@ function createChart(element, options = {}) {
|
|
|
3966
4007
|
}
|
|
3967
4008
|
resetViewport();
|
|
3968
4009
|
};
|
|
4010
|
+
const onContextMenu = (event) => {
|
|
4011
|
+
event.preventDefault();
|
|
4012
|
+
};
|
|
3969
4013
|
canvas.addEventListener("pointerdown", onPointerDown);
|
|
3970
4014
|
canvas.addEventListener("pointermove", onPointerMove);
|
|
3971
4015
|
canvas.addEventListener("pointerup", endPointerDrag);
|
|
@@ -3973,6 +4017,7 @@ function createChart(element, options = {}) {
|
|
|
3973
4017
|
canvas.addEventListener("pointerleave", endPointerDrag);
|
|
3974
4018
|
canvas.addEventListener("wheel", onWheel, { passive: false });
|
|
3975
4019
|
canvas.addEventListener("dblclick", onDoubleClick);
|
|
4020
|
+
canvas.addEventListener("contextmenu", onContextMenu);
|
|
3976
4021
|
const updateOptions = (nextOptions) => {
|
|
3977
4022
|
const wasTickerSmoothingEnabled = mergedOptions.tickerLine?.smoothing ?? false;
|
|
3978
4023
|
const previousWidth = width;
|
|
@@ -4270,6 +4315,7 @@ function createChart(element, options = {}) {
|
|
|
4270
4315
|
canvas.removeEventListener("pointerleave", endPointerDrag);
|
|
4271
4316
|
canvas.removeEventListener("wheel", onWheel);
|
|
4272
4317
|
canvas.removeEventListener("dblclick", onDoubleClick);
|
|
4318
|
+
canvas.removeEventListener("contextmenu", onContextMenu);
|
|
4273
4319
|
element.innerHTML = "";
|
|
4274
4320
|
};
|
|
4275
4321
|
draw();
|
|
@@ -1041,6 +1041,10 @@ function createChart(element, options = {}) {
|
|
|
1041
1041
|
}
|
|
1042
1042
|
canvas.style.display = "block";
|
|
1043
1043
|
canvas.style.touchAction = "none";
|
|
1044
|
+
canvas.style.userSelect = "none";
|
|
1045
|
+
canvas.style.setProperty("-webkit-user-select", "none");
|
|
1046
|
+
canvas.style.setProperty("-webkit-touch-callout", "none");
|
|
1047
|
+
canvas.setAttribute("draggable", "false");
|
|
1044
1048
|
element.innerHTML = "";
|
|
1045
1049
|
element.appendChild(canvas);
|
|
1046
1050
|
const margin = { top: 16, right: 72, bottom: 34, left: 12 };
|
|
@@ -3531,6 +3535,9 @@ function createChart(element, options = {}) {
|
|
|
3531
3535
|
draw();
|
|
3532
3536
|
};
|
|
3533
3537
|
const onPointerDown = (event) => {
|
|
3538
|
+
if (event.pointerType === "touch" || event.pointerType === "pen") {
|
|
3539
|
+
event.preventDefault();
|
|
3540
|
+
}
|
|
3534
3541
|
const point = getCanvasPoint(event);
|
|
3535
3542
|
if (event.pointerType === "touch") {
|
|
3536
3543
|
touchPointers.set(event.pointerId, point);
|
|
@@ -3629,12 +3636,29 @@ function createChart(element, options = {}) {
|
|
|
3629
3636
|
isDragging = true;
|
|
3630
3637
|
dragMode = region;
|
|
3631
3638
|
activePointerId = event.pointerId;
|
|
3632
|
-
|
|
3639
|
+
const crosshairDrag = (event.pointerType === "touch" || event.pointerType === "pen") && region === "plot";
|
|
3640
|
+
pointerDownInfo = {
|
|
3641
|
+
pointerId: event.pointerId,
|
|
3642
|
+
pointerType: event.pointerType,
|
|
3643
|
+
x: point.x,
|
|
3644
|
+
y: point.y,
|
|
3645
|
+
region,
|
|
3646
|
+
moved: false,
|
|
3647
|
+
crosshairDrag
|
|
3648
|
+
};
|
|
3633
3649
|
lastPointerX = point.x;
|
|
3634
3650
|
lastPointerY = point.y;
|
|
3635
3651
|
canvas.setPointerCapture(event.pointerId);
|
|
3652
|
+
if (crosshairDrag) {
|
|
3653
|
+
canvas.style.cursor = "crosshair";
|
|
3654
|
+
setCrosshairPoint(point);
|
|
3655
|
+
emitCrosshairMove(point.x, point.y, "plot");
|
|
3656
|
+
}
|
|
3636
3657
|
};
|
|
3637
3658
|
const onPointerMove = (event) => {
|
|
3659
|
+
if (event.pointerType === "touch" || event.pointerType === "pen") {
|
|
3660
|
+
event.preventDefault();
|
|
3661
|
+
}
|
|
3638
3662
|
const point = getCanvasPoint(event);
|
|
3639
3663
|
if (event.pointerType === "touch" && touchPointers.has(event.pointerId)) {
|
|
3640
3664
|
touchPointers.set(event.pointerId, point);
|
|
@@ -3657,6 +3681,16 @@ function createChart(element, options = {}) {
|
|
|
3657
3681
|
pointerDownInfo.moved = true;
|
|
3658
3682
|
}
|
|
3659
3683
|
}
|
|
3684
|
+
if (pointerDownInfo?.crosshairDrag && pointerDownInfo.pointerId === event.pointerId) {
|
|
3685
|
+
if (getHitRegion(point.x, point.y) === "plot") {
|
|
3686
|
+
canvas.style.cursor = "crosshair";
|
|
3687
|
+
setCrosshairPoint(point);
|
|
3688
|
+
emitCrosshairMove(point.x, point.y, "plot");
|
|
3689
|
+
lastPointerX = point.x;
|
|
3690
|
+
lastPointerY = point.y;
|
|
3691
|
+
}
|
|
3692
|
+
return;
|
|
3693
|
+
}
|
|
3660
3694
|
if (drawingDragState) {
|
|
3661
3695
|
if (activePointerId !== null && event.pointerId !== activePointerId) {
|
|
3662
3696
|
return;
|
|
@@ -3870,7 +3904,13 @@ function createChart(element, options = {}) {
|
|
|
3870
3904
|
activePointerId = null;
|
|
3871
3905
|
canvas.style.cursor = "default";
|
|
3872
3906
|
if (event && pointerDownInfo && event.pointerId === pointerDownInfo.pointerId) {
|
|
3873
|
-
if (
|
|
3907
|
+
if (pointerDownInfo.crosshairDrag) {
|
|
3908
|
+
const point = getCanvasPoint(event);
|
|
3909
|
+
if (getHitRegion(point.x, point.y) === "plot") {
|
|
3910
|
+
setCrosshairPoint(point);
|
|
3911
|
+
emitCrosshairMove(point.x, point.y, "plot");
|
|
3912
|
+
}
|
|
3913
|
+
} else if (!pointerDownInfo.moved) {
|
|
3874
3914
|
const clickPrice = pointerDownInfo.region === "plot" ? roundToPricePrecision(priceFromCanvasY(pointerDownInfo.y)) : void 0;
|
|
3875
3915
|
chartClickHandler?.({
|
|
3876
3916
|
x: pointerDownInfo.x,
|
|
@@ -3917,6 +3957,7 @@ function createChart(element, options = {}) {
|
|
|
3917
3957
|
zoomX(factor, point.x);
|
|
3918
3958
|
};
|
|
3919
3959
|
const onDoubleClick = (event) => {
|
|
3960
|
+
event.preventDefault();
|
|
3920
3961
|
if (!doubleClickEnabled) {
|
|
3921
3962
|
return;
|
|
3922
3963
|
}
|
|
@@ -3942,6 +3983,9 @@ function createChart(element, options = {}) {
|
|
|
3942
3983
|
}
|
|
3943
3984
|
resetViewport();
|
|
3944
3985
|
};
|
|
3986
|
+
const onContextMenu = (event) => {
|
|
3987
|
+
event.preventDefault();
|
|
3988
|
+
};
|
|
3945
3989
|
canvas.addEventListener("pointerdown", onPointerDown);
|
|
3946
3990
|
canvas.addEventListener("pointermove", onPointerMove);
|
|
3947
3991
|
canvas.addEventListener("pointerup", endPointerDrag);
|
|
@@ -3949,6 +3993,7 @@ function createChart(element, options = {}) {
|
|
|
3949
3993
|
canvas.addEventListener("pointerleave", endPointerDrag);
|
|
3950
3994
|
canvas.addEventListener("wheel", onWheel, { passive: false });
|
|
3951
3995
|
canvas.addEventListener("dblclick", onDoubleClick);
|
|
3996
|
+
canvas.addEventListener("contextmenu", onContextMenu);
|
|
3952
3997
|
const updateOptions = (nextOptions) => {
|
|
3953
3998
|
const wasTickerSmoothingEnabled = mergedOptions.tickerLine?.smoothing ?? false;
|
|
3954
3999
|
const previousWidth = width;
|
|
@@ -4246,6 +4291,7 @@ function createChart(element, options = {}) {
|
|
|
4246
4291
|
canvas.removeEventListener("pointerleave", endPointerDrag);
|
|
4247
4292
|
canvas.removeEventListener("wheel", onWheel);
|
|
4248
4293
|
canvas.removeEventListener("dblclick", onDoubleClick);
|
|
4294
|
+
canvas.removeEventListener("contextmenu", onContextMenu);
|
|
4249
4295
|
element.innerHTML = "";
|
|
4250
4296
|
};
|
|
4251
4297
|
draw();
|
package/dist/index.cjs
CHANGED
|
@@ -1065,6 +1065,10 @@ function createChart(element, options = {}) {
|
|
|
1065
1065
|
}
|
|
1066
1066
|
canvas.style.display = "block";
|
|
1067
1067
|
canvas.style.touchAction = "none";
|
|
1068
|
+
canvas.style.userSelect = "none";
|
|
1069
|
+
canvas.style.setProperty("-webkit-user-select", "none");
|
|
1070
|
+
canvas.style.setProperty("-webkit-touch-callout", "none");
|
|
1071
|
+
canvas.setAttribute("draggable", "false");
|
|
1068
1072
|
element.innerHTML = "";
|
|
1069
1073
|
element.appendChild(canvas);
|
|
1070
1074
|
const margin = { top: 16, right: 72, bottom: 34, left: 12 };
|
|
@@ -3555,6 +3559,9 @@ function createChart(element, options = {}) {
|
|
|
3555
3559
|
draw();
|
|
3556
3560
|
};
|
|
3557
3561
|
const onPointerDown = (event) => {
|
|
3562
|
+
if (event.pointerType === "touch" || event.pointerType === "pen") {
|
|
3563
|
+
event.preventDefault();
|
|
3564
|
+
}
|
|
3558
3565
|
const point = getCanvasPoint(event);
|
|
3559
3566
|
if (event.pointerType === "touch") {
|
|
3560
3567
|
touchPointers.set(event.pointerId, point);
|
|
@@ -3653,12 +3660,29 @@ function createChart(element, options = {}) {
|
|
|
3653
3660
|
isDragging = true;
|
|
3654
3661
|
dragMode = region;
|
|
3655
3662
|
activePointerId = event.pointerId;
|
|
3656
|
-
|
|
3663
|
+
const crosshairDrag = (event.pointerType === "touch" || event.pointerType === "pen") && region === "plot";
|
|
3664
|
+
pointerDownInfo = {
|
|
3665
|
+
pointerId: event.pointerId,
|
|
3666
|
+
pointerType: event.pointerType,
|
|
3667
|
+
x: point.x,
|
|
3668
|
+
y: point.y,
|
|
3669
|
+
region,
|
|
3670
|
+
moved: false,
|
|
3671
|
+
crosshairDrag
|
|
3672
|
+
};
|
|
3657
3673
|
lastPointerX = point.x;
|
|
3658
3674
|
lastPointerY = point.y;
|
|
3659
3675
|
canvas.setPointerCapture(event.pointerId);
|
|
3676
|
+
if (crosshairDrag) {
|
|
3677
|
+
canvas.style.cursor = "crosshair";
|
|
3678
|
+
setCrosshairPoint(point);
|
|
3679
|
+
emitCrosshairMove(point.x, point.y, "plot");
|
|
3680
|
+
}
|
|
3660
3681
|
};
|
|
3661
3682
|
const onPointerMove = (event) => {
|
|
3683
|
+
if (event.pointerType === "touch" || event.pointerType === "pen") {
|
|
3684
|
+
event.preventDefault();
|
|
3685
|
+
}
|
|
3662
3686
|
const point = getCanvasPoint(event);
|
|
3663
3687
|
if (event.pointerType === "touch" && touchPointers.has(event.pointerId)) {
|
|
3664
3688
|
touchPointers.set(event.pointerId, point);
|
|
@@ -3681,6 +3705,16 @@ function createChart(element, options = {}) {
|
|
|
3681
3705
|
pointerDownInfo.moved = true;
|
|
3682
3706
|
}
|
|
3683
3707
|
}
|
|
3708
|
+
if (pointerDownInfo?.crosshairDrag && pointerDownInfo.pointerId === event.pointerId) {
|
|
3709
|
+
if (getHitRegion(point.x, point.y) === "plot") {
|
|
3710
|
+
canvas.style.cursor = "crosshair";
|
|
3711
|
+
setCrosshairPoint(point);
|
|
3712
|
+
emitCrosshairMove(point.x, point.y, "plot");
|
|
3713
|
+
lastPointerX = point.x;
|
|
3714
|
+
lastPointerY = point.y;
|
|
3715
|
+
}
|
|
3716
|
+
return;
|
|
3717
|
+
}
|
|
3684
3718
|
if (drawingDragState) {
|
|
3685
3719
|
if (activePointerId !== null && event.pointerId !== activePointerId) {
|
|
3686
3720
|
return;
|
|
@@ -3894,7 +3928,13 @@ function createChart(element, options = {}) {
|
|
|
3894
3928
|
activePointerId = null;
|
|
3895
3929
|
canvas.style.cursor = "default";
|
|
3896
3930
|
if (event && pointerDownInfo && event.pointerId === pointerDownInfo.pointerId) {
|
|
3897
|
-
if (
|
|
3931
|
+
if (pointerDownInfo.crosshairDrag) {
|
|
3932
|
+
const point = getCanvasPoint(event);
|
|
3933
|
+
if (getHitRegion(point.x, point.y) === "plot") {
|
|
3934
|
+
setCrosshairPoint(point);
|
|
3935
|
+
emitCrosshairMove(point.x, point.y, "plot");
|
|
3936
|
+
}
|
|
3937
|
+
} else if (!pointerDownInfo.moved) {
|
|
3898
3938
|
const clickPrice = pointerDownInfo.region === "plot" ? roundToPricePrecision(priceFromCanvasY(pointerDownInfo.y)) : void 0;
|
|
3899
3939
|
chartClickHandler?.({
|
|
3900
3940
|
x: pointerDownInfo.x,
|
|
@@ -3941,6 +3981,7 @@ function createChart(element, options = {}) {
|
|
|
3941
3981
|
zoomX(factor, point.x);
|
|
3942
3982
|
};
|
|
3943
3983
|
const onDoubleClick = (event) => {
|
|
3984
|
+
event.preventDefault();
|
|
3944
3985
|
if (!doubleClickEnabled) {
|
|
3945
3986
|
return;
|
|
3946
3987
|
}
|
|
@@ -3966,6 +4007,9 @@ function createChart(element, options = {}) {
|
|
|
3966
4007
|
}
|
|
3967
4008
|
resetViewport();
|
|
3968
4009
|
};
|
|
4010
|
+
const onContextMenu = (event) => {
|
|
4011
|
+
event.preventDefault();
|
|
4012
|
+
};
|
|
3969
4013
|
canvas.addEventListener("pointerdown", onPointerDown);
|
|
3970
4014
|
canvas.addEventListener("pointermove", onPointerMove);
|
|
3971
4015
|
canvas.addEventListener("pointerup", endPointerDrag);
|
|
@@ -3973,6 +4017,7 @@ function createChart(element, options = {}) {
|
|
|
3973
4017
|
canvas.addEventListener("pointerleave", endPointerDrag);
|
|
3974
4018
|
canvas.addEventListener("wheel", onWheel, { passive: false });
|
|
3975
4019
|
canvas.addEventListener("dblclick", onDoubleClick);
|
|
4020
|
+
canvas.addEventListener("contextmenu", onContextMenu);
|
|
3976
4021
|
const updateOptions = (nextOptions) => {
|
|
3977
4022
|
const wasTickerSmoothingEnabled = mergedOptions.tickerLine?.smoothing ?? false;
|
|
3978
4023
|
const previousWidth = width;
|
|
@@ -4270,6 +4315,7 @@ function createChart(element, options = {}) {
|
|
|
4270
4315
|
canvas.removeEventListener("pointerleave", endPointerDrag);
|
|
4271
4316
|
canvas.removeEventListener("wheel", onWheel);
|
|
4272
4317
|
canvas.removeEventListener("dblclick", onDoubleClick);
|
|
4318
|
+
canvas.removeEventListener("contextmenu", onContextMenu);
|
|
4273
4319
|
element.innerHTML = "";
|
|
4274
4320
|
};
|
|
4275
4321
|
draw();
|
package/dist/index.js
CHANGED
|
@@ -1041,6 +1041,10 @@ function createChart(element, options = {}) {
|
|
|
1041
1041
|
}
|
|
1042
1042
|
canvas.style.display = "block";
|
|
1043
1043
|
canvas.style.touchAction = "none";
|
|
1044
|
+
canvas.style.userSelect = "none";
|
|
1045
|
+
canvas.style.setProperty("-webkit-user-select", "none");
|
|
1046
|
+
canvas.style.setProperty("-webkit-touch-callout", "none");
|
|
1047
|
+
canvas.setAttribute("draggable", "false");
|
|
1044
1048
|
element.innerHTML = "";
|
|
1045
1049
|
element.appendChild(canvas);
|
|
1046
1050
|
const margin = { top: 16, right: 72, bottom: 34, left: 12 };
|
|
@@ -3531,6 +3535,9 @@ function createChart(element, options = {}) {
|
|
|
3531
3535
|
draw();
|
|
3532
3536
|
};
|
|
3533
3537
|
const onPointerDown = (event) => {
|
|
3538
|
+
if (event.pointerType === "touch" || event.pointerType === "pen") {
|
|
3539
|
+
event.preventDefault();
|
|
3540
|
+
}
|
|
3534
3541
|
const point = getCanvasPoint(event);
|
|
3535
3542
|
if (event.pointerType === "touch") {
|
|
3536
3543
|
touchPointers.set(event.pointerId, point);
|
|
@@ -3629,12 +3636,29 @@ function createChart(element, options = {}) {
|
|
|
3629
3636
|
isDragging = true;
|
|
3630
3637
|
dragMode = region;
|
|
3631
3638
|
activePointerId = event.pointerId;
|
|
3632
|
-
|
|
3639
|
+
const crosshairDrag = (event.pointerType === "touch" || event.pointerType === "pen") && region === "plot";
|
|
3640
|
+
pointerDownInfo = {
|
|
3641
|
+
pointerId: event.pointerId,
|
|
3642
|
+
pointerType: event.pointerType,
|
|
3643
|
+
x: point.x,
|
|
3644
|
+
y: point.y,
|
|
3645
|
+
region,
|
|
3646
|
+
moved: false,
|
|
3647
|
+
crosshairDrag
|
|
3648
|
+
};
|
|
3633
3649
|
lastPointerX = point.x;
|
|
3634
3650
|
lastPointerY = point.y;
|
|
3635
3651
|
canvas.setPointerCapture(event.pointerId);
|
|
3652
|
+
if (crosshairDrag) {
|
|
3653
|
+
canvas.style.cursor = "crosshair";
|
|
3654
|
+
setCrosshairPoint(point);
|
|
3655
|
+
emitCrosshairMove(point.x, point.y, "plot");
|
|
3656
|
+
}
|
|
3636
3657
|
};
|
|
3637
3658
|
const onPointerMove = (event) => {
|
|
3659
|
+
if (event.pointerType === "touch" || event.pointerType === "pen") {
|
|
3660
|
+
event.preventDefault();
|
|
3661
|
+
}
|
|
3638
3662
|
const point = getCanvasPoint(event);
|
|
3639
3663
|
if (event.pointerType === "touch" && touchPointers.has(event.pointerId)) {
|
|
3640
3664
|
touchPointers.set(event.pointerId, point);
|
|
@@ -3657,6 +3681,16 @@ function createChart(element, options = {}) {
|
|
|
3657
3681
|
pointerDownInfo.moved = true;
|
|
3658
3682
|
}
|
|
3659
3683
|
}
|
|
3684
|
+
if (pointerDownInfo?.crosshairDrag && pointerDownInfo.pointerId === event.pointerId) {
|
|
3685
|
+
if (getHitRegion(point.x, point.y) === "plot") {
|
|
3686
|
+
canvas.style.cursor = "crosshair";
|
|
3687
|
+
setCrosshairPoint(point);
|
|
3688
|
+
emitCrosshairMove(point.x, point.y, "plot");
|
|
3689
|
+
lastPointerX = point.x;
|
|
3690
|
+
lastPointerY = point.y;
|
|
3691
|
+
}
|
|
3692
|
+
return;
|
|
3693
|
+
}
|
|
3660
3694
|
if (drawingDragState) {
|
|
3661
3695
|
if (activePointerId !== null && event.pointerId !== activePointerId) {
|
|
3662
3696
|
return;
|
|
@@ -3870,7 +3904,13 @@ function createChart(element, options = {}) {
|
|
|
3870
3904
|
activePointerId = null;
|
|
3871
3905
|
canvas.style.cursor = "default";
|
|
3872
3906
|
if (event && pointerDownInfo && event.pointerId === pointerDownInfo.pointerId) {
|
|
3873
|
-
if (
|
|
3907
|
+
if (pointerDownInfo.crosshairDrag) {
|
|
3908
|
+
const point = getCanvasPoint(event);
|
|
3909
|
+
if (getHitRegion(point.x, point.y) === "plot") {
|
|
3910
|
+
setCrosshairPoint(point);
|
|
3911
|
+
emitCrosshairMove(point.x, point.y, "plot");
|
|
3912
|
+
}
|
|
3913
|
+
} else if (!pointerDownInfo.moved) {
|
|
3874
3914
|
const clickPrice = pointerDownInfo.region === "plot" ? roundToPricePrecision(priceFromCanvasY(pointerDownInfo.y)) : void 0;
|
|
3875
3915
|
chartClickHandler?.({
|
|
3876
3916
|
x: pointerDownInfo.x,
|
|
@@ -3917,6 +3957,7 @@ function createChart(element, options = {}) {
|
|
|
3917
3957
|
zoomX(factor, point.x);
|
|
3918
3958
|
};
|
|
3919
3959
|
const onDoubleClick = (event) => {
|
|
3960
|
+
event.preventDefault();
|
|
3920
3961
|
if (!doubleClickEnabled) {
|
|
3921
3962
|
return;
|
|
3922
3963
|
}
|
|
@@ -3942,6 +3983,9 @@ function createChart(element, options = {}) {
|
|
|
3942
3983
|
}
|
|
3943
3984
|
resetViewport();
|
|
3944
3985
|
};
|
|
3986
|
+
const onContextMenu = (event) => {
|
|
3987
|
+
event.preventDefault();
|
|
3988
|
+
};
|
|
3945
3989
|
canvas.addEventListener("pointerdown", onPointerDown);
|
|
3946
3990
|
canvas.addEventListener("pointermove", onPointerMove);
|
|
3947
3991
|
canvas.addEventListener("pointerup", endPointerDrag);
|
|
@@ -3949,6 +3993,7 @@ function createChart(element, options = {}) {
|
|
|
3949
3993
|
canvas.addEventListener("pointerleave", endPointerDrag);
|
|
3950
3994
|
canvas.addEventListener("wheel", onWheel, { passive: false });
|
|
3951
3995
|
canvas.addEventListener("dblclick", onDoubleClick);
|
|
3996
|
+
canvas.addEventListener("contextmenu", onContextMenu);
|
|
3952
3997
|
const updateOptions = (nextOptions) => {
|
|
3953
3998
|
const wasTickerSmoothingEnabled = mergedOptions.tickerLine?.smoothing ?? false;
|
|
3954
3999
|
const previousWidth = width;
|
|
@@ -4246,6 +4291,7 @@ function createChart(element, options = {}) {
|
|
|
4246
4291
|
canvas.removeEventListener("pointerleave", endPointerDrag);
|
|
4247
4292
|
canvas.removeEventListener("wheel", onWheel);
|
|
4248
4293
|
canvas.removeEventListener("dblclick", onDoubleClick);
|
|
4294
|
+
canvas.removeEventListener("contextmenu", onContextMenu);
|
|
4249
4295
|
element.innerHTML = "";
|
|
4250
4296
|
};
|
|
4251
4297
|
draw();
|