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

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,7 +26514,6 @@ 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);
26518
26517
  const annotation2 = hoveredAnnotationId ? annotations == null ? void 0 : annotations[hoveredAnnotationId] : null;
26519
26518
  if (!annotation2) return;
26520
26519
  const { xScaleID = "x", yScaleID = "y" } = annotation2;
@@ -26540,7 +26539,6 @@ const handleAnnotationMouseDown = (event, canvas2, scales, annotations, setDragg
26540
26539
  };
26541
26540
  const handleAnnotationMouseMove = (event, canvas2, scales, isDragging2, activeAnnotation, dragStartX, dragStartY, chart2) => {
26542
26541
  if (isDragging2 && activeAnnotation) {
26543
- console.log("canvas - handleAnnotationMouseMove", canvas2);
26544
26542
  if (!isNil(canvas2) && !isNil(canvas2.style)) {
26545
26543
  canvas2.style.cursor = CursorStyle.Move;
26546
26544
  }
@@ -26617,26 +26615,6 @@ const handleAnnotationMouseMove = (event, canvas2, scales, isDragging2, activeAn
26617
26615
  }
26618
26616
  }
26619
26617
  };
26620
- const handleAnnotationMouseUp = (isDragging2, activeAnnotation, chart2, canvas2, setDraggingState) => {
26621
- if (isDragging2) {
26622
- if (activeAnnotation) {
26623
- const annotationId = activeAnnotation == null ? void 0 : activeAnnotation.id;
26624
- setAnnotationBorderWidth(chart2, annotationId, BORDER_WIDTH.ZERO);
26625
- const { centerX = -1, centerY = -1 } = calculateAnnotationMetricsInValues(activeAnnotation) ?? {};
26626
- if (activeAnnotation == null ? void 0 : activeAnnotation.onDragEnd) {
26627
- activeAnnotation.onDragEnd(
26628
- { x: centerX, y: centerY },
26629
- activeAnnotation
26630
- );
26631
- }
26632
- console.log("Chart", chart2);
26633
- console.log("canvas", canvas2);
26634
- console.log("canvas.ownerDocument", canvas2.ownerDocument);
26635
- setDraggingState(false, null);
26636
- chart2.update();
26637
- }
26638
- }
26639
- };
26640
26618
  const annotationLabel = (ctx, annotations, scales) => {
26641
26619
  Object.values(annotations).forEach((annotation2) => {
26642
26620
  var _a2;
@@ -26676,7 +26654,7 @@ const annotationLabel = (ctx, annotations, scales) => {
26676
26654
  const annotationDraggerPlugin = {
26677
26655
  id: "annotationDraggerPlugin",
26678
26656
  beforeDraw(chart2) {
26679
- var _a2, _b2;
26657
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
26680
26658
  let annotations = ((_b2 = (_a2 = chart2.options.plugins) == null ? void 0 : _a2.annotation) == null ? void 0 : _b2.annotations) ?? {};
26681
26659
  if (!annotations) return;
26682
26660
  annotationLabel(
@@ -26684,9 +26662,29 @@ const annotationDraggerPlugin = {
26684
26662
  annotations,
26685
26663
  chart2.scales
26686
26664
  );
26665
+ const pluginOptions = ((_d2 = (_c2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _c2.plugins) == null ? void 0 : _d2.annotationDraggerPlugin) || {
26666
+ enabled: false
26667
+ };
26668
+ if (pluginOptions.enabled) {
26669
+ if ((_f2 = (_e2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _e2.plugins) == null ? void 0 : _f2.tooltip) {
26670
+ chart2.options.plugins.tooltip.enabled = false;
26671
+ }
26672
+ chart2.options.hover = {
26673
+ mode: void 0,
26674
+ intersect: false
26675
+ };
26676
+ } else {
26677
+ if ((_h2 = (_g2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _g2.plugins) == null ? void 0 : _h2.tooltip) {
26678
+ chart2.options.plugins.tooltip.enabled = true;
26679
+ }
26680
+ chart2.options.hover = {
26681
+ mode: ChartHoverMode.Nearest,
26682
+ intersect: true
26683
+ };
26684
+ }
26687
26685
  },
26688
26686
  afterUpdate(chart2) {
26689
- var _a2, _b2, _c2, _d2;
26687
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
26690
26688
  const { canvas: canvas2, scales, hoveredAnnotationId } = chart2;
26691
26689
  const pluginOptions = ((_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.plugins) == null ? void 0 : _b2.annotationDraggerPlugin) || {
26692
26690
  enabled: false
@@ -26694,6 +26692,23 @@ const annotationDraggerPlugin = {
26694
26692
  const typedScales = { ...scales, x: scales.x, y: scales.y };
26695
26693
  let annotations = ((_d2 = (_c2 = chart2.options.plugins) == null ? void 0 : _c2.annotation) == null ? void 0 : _d2.annotations) ?? {};
26696
26694
  if (!chart2 && !annotations) return;
26695
+ if (pluginOptions.enabled) {
26696
+ if ((_f2 = (_e2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _e2.plugins) == null ? void 0 : _f2.tooltip) {
26697
+ chart2.options.plugins.tooltip.enabled = false;
26698
+ }
26699
+ chart2.options.hover = {
26700
+ mode: void 0,
26701
+ intersect: false
26702
+ };
26703
+ } else {
26704
+ if ((_h2 = (_g2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _g2.plugins) == null ? void 0 : _h2.tooltip) {
26705
+ chart2.options.plugins.tooltip.enabled = true;
26706
+ }
26707
+ chart2.options.hover = {
26708
+ mode: ChartHoverMode.Nearest,
26709
+ intersect: true
26710
+ };
26711
+ }
26697
26712
  let isDragging2 = false;
26698
26713
  let dragStartX, dragStartY;
26699
26714
  let activeAnnotation = null;
@@ -26734,14 +26749,7 @@ const annotationDraggerPlugin = {
26734
26749
  handleAnnotationMouseMoveDebounce();
26735
26750
  });
26736
26751
  canvas2.addEventListener(MouseEvents.MOUSEUP, (event) => {
26737
- const canvasEvent = event.currentTarget;
26738
- handleAnnotationMouseUp(
26739
- isDragging2,
26740
- activeAnnotation,
26741
- chart2,
26742
- canvasEvent,
26743
- setDraggingState
26744
- );
26752
+ event.currentTarget;
26745
26753
  });
26746
26754
  canvas2.dataset.annotationDraggerInitialized = "true";
26747
26755
  }