@oliasoft-open-source/charts-library 4.4.6 → 4.5.0

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
@@ -25340,6 +25340,12 @@ var AnnotationType = /* @__PURE__ */ ((AnnotationType2) => {
25340
25340
  AnnotationType2["ELLIPSE"] = "ellipse";
25341
25341
  return AnnotationType2;
25342
25342
  })(AnnotationType || {});
25343
+ var DragAxis = /* @__PURE__ */ ((DragAxis2) => {
25344
+ DragAxis2["X"] = "x";
25345
+ DragAxis2["Y"] = "y";
25346
+ DragAxis2["Both"] = "both";
25347
+ return DragAxis2;
25348
+ })(DragAxis || {});
25343
25349
  const handleLineEnter = (element, chart2, annotation2) => {
25344
25350
  var _a2;
25345
25351
  chart2.canvas.style.cursor = CursorStyle.Pointer;
@@ -26143,21 +26149,29 @@ const handleAnnotationMouseDown = (event, canvas2, scales, annotations, setDragg
26143
26149
  const handleAnnotationMouseMove = (event, canvas2, scales, isDragging2, activeAnnotation, dragStartX, dragStartY, chart2) => {
26144
26150
  if (isDragging2 && activeAnnotation) {
26145
26151
  canvas2.style.cursor = CursorStyle.Move;
26152
+ const dragAxis = (activeAnnotation == null ? void 0 : activeAnnotation.dragAxis) ?? DragAxis.Both;
26146
26153
  const { x: x2, y: y2 } = getMousePositionInCoordinates(event, canvas2, scales);
26147
26154
  const metrics = calculateAnnotationMetricsInValues(activeAnnotation);
26148
26155
  let newCenterX = x2 - dragStartX;
26149
26156
  let newCenterY = y2 - dragStartY;
26150
- if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.POINT) {
26151
- newCenterX = x2 - dragStartX;
26152
- newCenterY = y2 - dragStartY;
26153
- activeAnnotation.xValue = newCenterX;
26154
- activeAnnotation.yValue = newCenterY;
26155
- } else if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.BOX) {
26156
- if (!isNil(metrics == null ? void 0 : metrics.width) && !isNil(metrics.height)) {
26157
- activeAnnotation.xMin = newCenterX - metrics.width / 2;
26158
- activeAnnotation.xMax = newCenterX + metrics.width / 2;
26159
- activeAnnotation.yMin = newCenterY - metrics.height / 2;
26160
- activeAnnotation.yMax = newCenterY + metrics.height / 2;
26157
+ if (dragAxis !== DragAxis.Y) {
26158
+ if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.POINT) {
26159
+ activeAnnotation.xValue = newCenterX;
26160
+ } else if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.BOX) {
26161
+ if (!isNil(metrics == null ? void 0 : metrics.width)) {
26162
+ activeAnnotation.xMin = newCenterX - metrics.width / 2;
26163
+ activeAnnotation.xMax = newCenterX + metrics.width / 2;
26164
+ }
26165
+ }
26166
+ }
26167
+ if (dragAxis !== DragAxis.X) {
26168
+ if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.POINT) {
26169
+ activeAnnotation.yValue = newCenterY;
26170
+ } else if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.BOX) {
26171
+ if (!isNil(metrics == null ? void 0 : metrics.height)) {
26172
+ activeAnnotation.yMin = newCenterY - metrics.height / 2;
26173
+ activeAnnotation.yMax = newCenterY + metrics.height / 2;
26174
+ }
26161
26175
  }
26162
26176
  }
26163
26177
  chart2.update();