@oliasoft-open-source/charts-library 4.3.3-beta-8 → 4.3.3-beta-9

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
@@ -11,7 +11,7 @@ import { produce } from "immer";
11
11
  import { round as round$2, displayNumber, isCloseTo, roundByMagnitude } from "@oliasoft-open-source/units";
12
12
  import cx from "classnames";
13
13
  import { Icon, Tooltip as Tooltip$2, Button, Flex, Text, Menu, Popover, Field, InputGroup, NumberInput, InputGroupAddon, Select, ButtonGroup, Spacer, Portal } from "@oliasoft-open-source/react-ui-library";
14
- import { isEmpty, isArray as isArray$2, some, has, cloneDeep, defaultTo, findIndex, set as set$2, isNil, debounce as debounce$3, map as map$3, find, get as get$1, values } from "lodash";
14
+ import { isEmpty, isArray as isArray$2, some, has, cloneDeep, defaultTo, findIndex, set as set$2, isNil, debounce as debounce$3, isFunction as isFunction$2, map as map$3, find, get as get$1, values } from "lodash";
15
15
  import { roundNumberToPrecision } from "@oliasoft-open-source/units/dist/rounding/rounding";
16
16
  /*!
17
17
  * @kurkle/color v0.3.2
@@ -26170,7 +26170,6 @@ const handleAnnotationMouseMove = (event, canvas2, scales, isDragging2, activeAn
26170
26170
  activeAnnotation.yMax = newCenterY + metrics.height / 2;
26171
26171
  }
26172
26172
  }
26173
- chart2 == null ? void 0 : chart2.update();
26174
26173
  if (activeAnnotation == null ? void 0 : activeAnnotation.onDrag) {
26175
26174
  activeAnnotation.onDrag({ x: x2, y: y2 }, cloneDeep(activeAnnotation));
26176
26175
  }
@@ -26212,9 +26211,13 @@ const handleAnnotationMouseUp = (isDragging2, activeAnnotation, chart2, setDragg
26212
26211
  if (!isNil((_b2 = (_a2 = chart2 == null ? void 0 : chart2.canvas) == null ? void 0 : _a2.style) == null ? void 0 : _b2.cursor)) {
26213
26212
  chart2.canvas.style.cursor = CursorStyle.Pointer;
26214
26213
  }
26214
+ }
26215
+ if (chart2 == null ? void 0 : chart2.canvas) {
26215
26216
  setDraggingState(false, null);
26217
+ chart2 == null ? void 0 : chart2.update();
26218
+ } else {
26219
+ console.error("Canvas is not available during mouse up");
26216
26220
  }
26217
- chart2 == null ? void 0 : chart2.update();
26218
26221
  }
26219
26222
  };
26220
26223
  const annotationLabel = (ctx, annotations, scales) => {
@@ -26280,10 +26283,9 @@ const annotationDraggerPlugin = {
26280
26283
  };
26281
26284
  }
26282
26285
  },
26283
- afterUpdate(chart2) {
26284
- var _a2, _b2, _c2, _d2, _e2, _f2;
26286
+ afterRender(chart2) {
26287
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
26285
26288
  const { canvas: canvas2, scales, hoveredAnnotationId } = chart2;
26286
- console.log("Chart afterUpdate:", chart2);
26287
26289
  const pluginOptions = ((_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.plugins) == null ? void 0 : _b2.annotationDraggerPlugin) || {
26288
26290
  enabled: false
26289
26291
  };
@@ -26303,8 +26305,14 @@ const annotationDraggerPlugin = {
26303
26305
  }
26304
26306
  };
26305
26307
  if (!((_f2 = canvas2 == null ? void 0 : canvas2.dataset) == null ? void 0 : _f2.annotationDraggerInitialized) && (pluginOptions == null ? void 0 : pluginOptions.enabled) && hoveredAnnotationId) {
26306
- if (!isNil(canvas2) && !isEmpty(canvas2)) {
26307
- console.log("Canvas exists:", cloneDeep(canvas2));
26308
+ console.group("Condition");
26309
+ console.log("addEventListener", (_g2 = chart2 == null ? void 0 : chart2.canvas) == null ? void 0 : _g2.addEventListener);
26310
+ console.log("nil", !isNil(canvas2));
26311
+ console.log("isEmpty", !isEmpty(canvas2));
26312
+ console.log("isFunction", isFunction$2(canvas2.addEventListener));
26313
+ console.groupEnd();
26314
+ if (!isNil(canvas2) && !isEmpty(canvas2) && isFunction$2(canvas2.addEventListener)) {
26315
+ console.log("Canvas exists and has addEventListener:", canvas2);
26308
26316
  canvas2.addEventListener(MouseEvents.MOUSEDOWN, (event) => {
26309
26317
  var _a3, _b3, _c3;
26310
26318
  handleAnnotationMouseDown(
@@ -26338,11 +26346,15 @@ const annotationDraggerPlugin = {
26338
26346
  });
26339
26347
  canvas2.dataset.annotationDraggerInitialized = "true";
26340
26348
  } else {
26341
- console.error("Canvas is null or empty:", canvas2);
26349
+ console.error(
26350
+ "Canvas is null, empty, or does not support addEventListener:",
26351
+ canvas2
26352
+ );
26342
26353
  }
26343
26354
  }
26344
26355
  if (!pluginOptions.enabled) {
26345
- if (canvas2) {
26356
+ if (canvas2 && isFunction$2(canvas2.removeEventListener)) {
26357
+ console.log("Removing event listeners from canvas:", canvas2);
26346
26358
  canvas2.removeEventListener(MouseEvents.MOUSEDOWN, () => {
26347
26359
  });
26348
26360
  canvas2.removeEventListener(MouseEvents.MOUSEMOVE, () => {