@oliasoft-open-source/charts-library 4.3.1 → 4.3.2-beta-2

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
@@ -25477,6 +25477,7 @@ const generateAnnotations = (annotationsData) => {
25477
25477
  const onDragEnd = () => (cord, annotation2) => (ann == null ? void 0 : ann.onDragEnd) ? ann == null ? void 0 : ann.onDragEnd(cord, annotation2) : void 0;
25478
25478
  return {
25479
25479
  ...ann,
25480
+ drawTime: "afterDraw",
25480
25481
  display: ann == null ? void 0 : ann.display,
25481
25482
  annotationIndex: idx,
25482
25483
  id: `${ann == null ? void 0 : ann.label}-${ann == null ? void 0 : ann.value}-${idx}`,
@@ -26117,7 +26118,7 @@ const handleAnnotationMouseDown = (event, canvas2, scales, annotations, setDragg
26117
26118
  if (!annotation2)
26118
26119
  return;
26119
26120
  const metrics = calculateAnnotationMetricsInValues(annotation2);
26120
- if (annotation2 && annotation2.enableDrag && metrics.centerY && metrics.centerX) {
26121
+ if (annotation2 && annotation2.enableDrag && !isNil(metrics.centerY) && !isNil(metrics.centerX)) {
26121
26122
  canvas2.style.cursor = CursorStyle.Move;
26122
26123
  const dragStartX = x2 - metrics.centerX;
26123
26124
  const dragStartY = y2 - metrics.centerY;
@@ -26140,7 +26141,7 @@ const handleAnnotationMouseMove = (event, canvas2, scales, isDragging2, activeAn
26140
26141
  activeAnnotation.xValue = newCenterX;
26141
26142
  activeAnnotation.yValue = newCenterY;
26142
26143
  } else if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.BOX) {
26143
- if ((metrics == null ? void 0 : metrics.width) && metrics.height) {
26144
+ if (!isNil(metrics == null ? void 0 : metrics.width) && !isNil(metrics.height)) {
26144
26145
  activeAnnotation.xMin = newCenterX - metrics.width / 2;
26145
26146
  activeAnnotation.xMax = newCenterX + metrics.width / 2;
26146
26147
  activeAnnotation.yMin = newCenterY - metrics.height / 2;
@@ -26154,7 +26155,7 @@ const handleAnnotationMouseMove = (event, canvas2, scales, isDragging2, activeAn
26154
26155
  const { ctx, width, height } = chart2;
26155
26156
  const { centerX, centerY } = calculateAnnotationMetricsInValues(activeAnnotation) ?? {};
26156
26157
  const { centerX: xValue, centerY: yValue } = calculateAnnotationMetricsInValuesInPixels(activeAnnotation, scales);
26157
- if (centerX && centerY && xValue && yValue) {
26158
+ if (!isNil(centerX) && !isNil(centerY) && !isNil(xValue) && !isNil(yValue)) {
26158
26159
  ctx.save();
26159
26160
  ctx.clearRect(0, 0, width, height);
26160
26161
  chart2.draw();
@@ -26224,7 +26225,7 @@ const annotationLabel = (ctx, annotations, scales) => {
26224
26225
  const annotationDraggerPlugin = {
26225
26226
  id: "annotationDraggerPlugin",
26226
26227
  beforeDraw(chart2) {
26227
- var _a2, _b2;
26228
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
26228
26229
  let annotations = ((_b2 = (_a2 = chart2.options.plugins) == null ? void 0 : _a2.annotation) == null ? void 0 : _b2.annotations) ?? {};
26229
26230
  if (!annotations)
26230
26231
  return;
@@ -26233,6 +26234,26 @@ const annotationDraggerPlugin = {
26233
26234
  annotations,
26234
26235
  chart2.scales
26235
26236
  );
26237
+ const pluginOptions = ((_d2 = (_c2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _c2.plugins) == null ? void 0 : _d2.annotationDraggerPlugin) || {
26238
+ enabled: false
26239
+ };
26240
+ if (pluginOptions.enabled) {
26241
+ if ((_f2 = (_e2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _e2.plugins) == null ? void 0 : _f2.tooltip) {
26242
+ chart2.options.plugins.tooltip.enabled = false;
26243
+ }
26244
+ chart2.options.hover = {
26245
+ mode: void 0,
26246
+ intersect: false
26247
+ };
26248
+ } else {
26249
+ if ((_h2 = (_g2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _g2.plugins) == null ? void 0 : _h2.tooltip) {
26250
+ chart2.options.plugins.tooltip.enabled = true;
26251
+ }
26252
+ chart2.options.hover = {
26253
+ mode: ChartHoverMode.Nearest,
26254
+ intersect: true
26255
+ };
26256
+ }
26236
26257
  },
26237
26258
  afterUpdate(chart2) {
26238
26259
  var _a2, _b2, _c2, _d2;