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

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,12 @@ 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
+ console.log("chart?.canvas MOUSE UP", chart2 == null ? void 0 : chart2.canvas);
26216
+ if (chart2 == null ? void 0 : chart2.canvas) {
26215
26217
  setDraggingState(false, null);
26218
+ chart2 == null ? void 0 : chart2.update();
26216
26219
  }
26217
- chart2 == null ? void 0 : chart2.update();
26218
26220
  }
26219
26221
  };
26220
26222
  const annotationLabel = (ctx, annotations, scales) => {
@@ -26280,15 +26282,13 @@ const annotationDraggerPlugin = {
26280
26282
  };
26281
26283
  }
26282
26284
  },
26283
- afterUpdate(chart2) {
26284
- var _a2, _b2, _c2, _d2, _e2, _f2;
26285
- const { canvas: canvas2, scales, hoveredAnnotationId } = chart2;
26286
- console.log("Chart afterUpdate:", chart2);
26285
+ afterRender(chart2) {
26286
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2;
26287
26287
  const pluginOptions = ((_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.plugins) == null ? void 0 : _b2.annotationDraggerPlugin) || {
26288
26288
  enabled: false
26289
26289
  };
26290
- const typedScales = { x: scales.x, y: scales.y };
26291
- let annotations = ((_e2 = (_d2 = (_c2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _c2.plugins) == null ? void 0 : _d2.annotation) == null ? void 0 : _e2.annotations) ?? {};
26290
+ const typedScales = { x: (_c2 = chart2 == null ? void 0 : chart2.scales) == null ? void 0 : _c2.x, y: (_d2 = chart2 == null ? void 0 : chart2.scales) == null ? void 0 : _d2.y };
26291
+ let annotations = ((_g2 = (_f2 = (_e2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _e2.plugins) == null ? void 0 : _f2.annotation) == null ? void 0 : _g2.annotations) ?? {};
26292
26292
  if (!annotations)
26293
26293
  return;
26294
26294
  let isDragging2 = false;
@@ -26302,33 +26302,45 @@ const annotationDraggerPlugin = {
26302
26302
  dragStartY = startY;
26303
26303
  }
26304
26304
  };
26305
- 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
- canvas2.addEventListener(MouseEvents.MOUSEDOWN, (event) => {
26309
- var _a3, _b3, _c3;
26310
- handleAnnotationMouseDown(
26311
- event,
26312
- canvas2,
26313
- typedScales,
26314
- (_c3 = (_b3 = (_a3 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a3.plugins) == null ? void 0 : _b3.annotation) == null ? void 0 : _c3.annotations,
26315
- setDraggingState,
26316
- chart2.hoveredAnnotationId
26317
- );
26318
- });
26319
- canvas2.addEventListener(MouseEvents.MOUSEMOVE, (event) => {
26320
- handleAnnotationMouseMove(
26321
- event,
26322
- canvas2,
26323
- typedScales,
26324
- isDragging2,
26325
- activeAnnotation,
26326
- dragStartX,
26327
- dragStartY,
26328
- chart2
26329
- );
26330
- });
26331
- canvas2.addEventListener(MouseEvents.MOUSEUP, () => {
26305
+ if (!((_i2 = (_h2 = chart2 == null ? void 0 : chart2.canvas) == null ? void 0 : _h2.dataset) == null ? void 0 : _i2.annotationDraggerInitialized) && (pluginOptions == null ? void 0 : pluginOptions.enabled) && (chart2 == null ? void 0 : chart2.hoveredAnnotationId)) {
26306
+ console.group("Condition");
26307
+ console.log("addEventListener", (_j2 = chart2 == null ? void 0 : chart2.canvas) == null ? void 0 : _j2.addEventListener);
26308
+ console.log("nil", !isNil(chart2 == null ? void 0 : chart2.canvas));
26309
+ console.log("isEmpty", !isEmpty(chart2 == null ? void 0 : chart2.canvas));
26310
+ console.log("isFunction", isFunction$2(chart2 == null ? void 0 : chart2.canvas.addEventListener));
26311
+ console.groupEnd();
26312
+ if (!isNil(chart2 == null ? void 0 : chart2.canvas) && !isEmpty(chart2 == null ? void 0 : chart2.canvas) && isFunction$2(chart2 == null ? void 0 : chart2.canvas.addEventListener)) {
26313
+ console.log("Canvas exists and has addEventListener:", chart2 == null ? void 0 : chart2.canvas);
26314
+ (_k2 = chart2 == null ? void 0 : chart2.canvas) == null ? void 0 : _k2.addEventListener(
26315
+ MouseEvents.MOUSEDOWN,
26316
+ (event) => {
26317
+ var _a3, _b3, _c3;
26318
+ handleAnnotationMouseDown(
26319
+ event,
26320
+ chart2 == null ? void 0 : chart2.canvas,
26321
+ typedScales,
26322
+ (_c3 = (_b3 = (_a3 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a3.plugins) == null ? void 0 : _b3.annotation) == null ? void 0 : _c3.annotations,
26323
+ setDraggingState,
26324
+ chart2.hoveredAnnotationId
26325
+ );
26326
+ }
26327
+ );
26328
+ (_l2 = chart2 == null ? void 0 : chart2.canvas) == null ? void 0 : _l2.addEventListener(
26329
+ MouseEvents.MOUSEMOVE,
26330
+ (event) => {
26331
+ handleAnnotationMouseMove(
26332
+ event,
26333
+ chart2 == null ? void 0 : chart2.canvas,
26334
+ typedScales,
26335
+ isDragging2,
26336
+ activeAnnotation,
26337
+ dragStartX,
26338
+ dragStartY,
26339
+ chart2
26340
+ );
26341
+ }
26342
+ );
26343
+ chart2 == null ? void 0 : chart2.canvas.addEventListener(MouseEvents.MOUSEUP, () => {
26332
26344
  handleAnnotationMouseUp(
26333
26345
  isDragging2,
26334
26346
  activeAnnotation,
@@ -26336,20 +26348,24 @@ const annotationDraggerPlugin = {
26336
26348
  setDraggingState
26337
26349
  );
26338
26350
  });
26339
- canvas2.dataset.annotationDraggerInitialized = "true";
26351
+ chart2.canvas.dataset.annotationDraggerInitialized = "true";
26340
26352
  } else {
26341
- console.error("Canvas is null or empty:", canvas2);
26353
+ console.error(
26354
+ "Canvas is null, empty, or does not support addEventListener:",
26355
+ chart2 == null ? void 0 : chart2.canvas
26356
+ );
26342
26357
  }
26343
26358
  }
26344
26359
  if (!pluginOptions.enabled) {
26345
- if (canvas2) {
26346
- canvas2.removeEventListener(MouseEvents.MOUSEDOWN, () => {
26360
+ if ((chart2 == null ? void 0 : chart2.canvas) && isFunction$2(chart2 == null ? void 0 : chart2.canvas.removeEventListener)) {
26361
+ console.log("Removing event listeners from canvas:", chart2 == null ? void 0 : chart2.canvas);
26362
+ chart2 == null ? void 0 : chart2.canvas.removeEventListener(MouseEvents.MOUSEDOWN, () => {
26347
26363
  });
26348
- canvas2.removeEventListener(MouseEvents.MOUSEMOVE, () => {
26364
+ chart2 == null ? void 0 : chart2.canvas.removeEventListener(MouseEvents.MOUSEMOVE, () => {
26349
26365
  });
26350
- canvas2.removeEventListener(MouseEvents.MOUSEUP, () => {
26366
+ chart2 == null ? void 0 : chart2.canvas.removeEventListener(MouseEvents.MOUSEUP, () => {
26351
26367
  });
26352
- canvas2.dataset.annotationDraggerInitialized = "";
26368
+ chart2.canvas.dataset.annotationDraggerInitialized = "";
26353
26369
  }
26354
26370
  }
26355
26371
  }