@oliasoft-open-source/charts-library 4.7.7-beta-4 → 4.7.7-beta-6

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/index.js CHANGED
@@ -26514,6 +26514,7 @@ const setAnnotationBorderWidth = (chart2, annotationId, borderWidth) => {
26514
26514
  }
26515
26515
  };
26516
26516
  const handleAnnotationMouseDown = (event, canvas2, scales, annotations, setDraggingState, hoveredAnnotationId) => {
26517
+ console.log("canvas - handleAnnotationMouseDown", canvas2);
26517
26518
  const annotation2 = hoveredAnnotationId ? annotations == null ? void 0 : annotations[hoveredAnnotationId] : null;
26518
26519
  if (!annotation2) return;
26519
26520
  const { xScaleID = "x", yScaleID = "y" } = annotation2;
@@ -26539,6 +26540,7 @@ const handleAnnotationMouseDown = (event, canvas2, scales, annotations, setDragg
26539
26540
  };
26540
26541
  const handleAnnotationMouseMove = (event, canvas2, scales, isDragging2, activeAnnotation, dragStartX, dragStartY, chart2) => {
26541
26542
  if (isDragging2 && activeAnnotation) {
26543
+ console.log("canvas - handleAnnotationMouseMove", canvas2);
26542
26544
  if (!isNil(canvas2) && !isNil(canvas2.style)) {
26543
26545
  canvas2.style.cursor = CursorStyle.Move;
26544
26546
  }
@@ -26629,12 +26631,10 @@ const handleAnnotationMouseUp = (isDragging2, activeAnnotation, chart2, canvas2,
26629
26631
  }
26630
26632
  console.log("Chart", chart2);
26631
26633
  console.log("canvas", canvas2);
26632
- if (!isNil(canvas2) && !isNil(canvas2.style)) {
26633
- canvas2.style.cursor = CursorStyle.Pointer;
26634
- }
26634
+ console.log("canvas.ownerDocument", canvas2.ownerDocument);
26635
26635
  setDraggingState(false, null);
26636
+ chart2.update();
26636
26637
  }
26637
- chart2.update();
26638
26638
  }
26639
26639
  };
26640
26640
  const annotationLabel = (ctx, annotations, scales) => {
@@ -26676,7 +26676,7 @@ const annotationLabel = (ctx, annotations, scales) => {
26676
26676
  const annotationDraggerPlugin = {
26677
26677
  id: "annotationDraggerPlugin",
26678
26678
  beforeDraw(chart2) {
26679
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
26679
+ var _a2, _b2;
26680
26680
  let annotations = ((_b2 = (_a2 = chart2.options.plugins) == null ? void 0 : _a2.annotation) == null ? void 0 : _b2.annotations) ?? {};
26681
26681
  if (!annotations) return;
26682
26682
  annotationLabel(
@@ -26684,29 +26684,9 @@ const annotationDraggerPlugin = {
26684
26684
  annotations,
26685
26685
  chart2.scales
26686
26686
  );
26687
- const pluginOptions = ((_d2 = (_c2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _c2.plugins) == null ? void 0 : _d2.annotationDraggerPlugin) || {
26688
- enabled: false
26689
- };
26690
- if (pluginOptions.enabled) {
26691
- if ((_f2 = (_e2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _e2.plugins) == null ? void 0 : _f2.tooltip) {
26692
- chart2.options.plugins.tooltip.enabled = false;
26693
- }
26694
- chart2.options.hover = {
26695
- mode: void 0,
26696
- intersect: false
26697
- };
26698
- } else {
26699
- if ((_h2 = (_g2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _g2.plugins) == null ? void 0 : _h2.tooltip) {
26700
- chart2.options.plugins.tooltip.enabled = true;
26701
- }
26702
- chart2.options.hover = {
26703
- mode: ChartHoverMode.Nearest,
26704
- intersect: true
26705
- };
26706
- }
26707
26687
  },
26708
26688
  afterUpdate(chart2) {
26709
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
26689
+ var _a2, _b2, _c2, _d2;
26710
26690
  const { canvas: canvas2, scales, hoveredAnnotationId } = chart2;
26711
26691
  const pluginOptions = ((_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.plugins) == null ? void 0 : _b2.annotationDraggerPlugin) || {
26712
26692
  enabled: false
@@ -26714,23 +26694,6 @@ const annotationDraggerPlugin = {
26714
26694
  const typedScales = { ...scales, x: scales.x, y: scales.y };
26715
26695
  let annotations = ((_d2 = (_c2 = chart2.options.plugins) == null ? void 0 : _c2.annotation) == null ? void 0 : _d2.annotations) ?? {};
26716
26696
  if (!chart2 && !annotations) return;
26717
- if (pluginOptions.enabled) {
26718
- if ((_f2 = (_e2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _e2.plugins) == null ? void 0 : _f2.tooltip) {
26719
- chart2.options.plugins.tooltip.enabled = false;
26720
- }
26721
- chart2.options.hover = {
26722
- mode: void 0,
26723
- intersect: false
26724
- };
26725
- } else {
26726
- if ((_h2 = (_g2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _g2.plugins) == null ? void 0 : _h2.tooltip) {
26727
- chart2.options.plugins.tooltip.enabled = true;
26728
- }
26729
- chart2.options.hover = {
26730
- mode: ChartHoverMode.Nearest,
26731
- intersect: true
26732
- };
26733
- }
26734
26697
  let isDragging2 = false;
26735
26698
  let dragStartX, dragStartY;
26736
26699
  let activeAnnotation = null;
@@ -26770,12 +26733,13 @@ const annotationDraggerPlugin = {
26770
26733
  );
26771
26734
  handleAnnotationMouseMoveDebounce();
26772
26735
  });
26773
- canvas2.addEventListener(MouseEvents.MOUSEUP, () => {
26736
+ canvas2.addEventListener(MouseEvents.MOUSEUP, (event) => {
26737
+ const canvasEvent = event.currentTarget;
26774
26738
  handleAnnotationMouseUp(
26775
26739
  isDragging2,
26776
26740
  activeAnnotation,
26777
26741
  chart2,
26778
- canvas2,
26742
+ canvasEvent,
26779
26743
  setDraggingState
26780
26744
  );
26781
26745
  });