@oliasoft-open-source/charts-library 4.3.2 → 4.3.3-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
|
@@ -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, debounce as debounce$3,
|
|
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";
|
|
15
15
|
import { roundNumberToPrecision } from "@oliasoft-open-source/units/dist/rounding/rounding";
|
|
16
16
|
/*!
|
|
17
17
|
* @kurkle/color v0.3.2
|
|
@@ -25329,9 +25329,11 @@ var AnnotationType = /* @__PURE__ */ ((AnnotationType2) => {
|
|
|
25329
25329
|
return AnnotationType2;
|
|
25330
25330
|
})(AnnotationType || {});
|
|
25331
25331
|
const handleLineEnter = (element, chart2, annotation2) => {
|
|
25332
|
-
var _a2;
|
|
25333
|
-
chart2.canvas.style.cursor
|
|
25334
|
-
|
|
25332
|
+
var _a2, _b2, _c2;
|
|
25333
|
+
if (!isNil((_b2 = (_a2 = chart2 == null ? void 0 : chart2.canvas) == null ? void 0 : _a2.style) == null ? void 0 : _b2.cursor)) {
|
|
25334
|
+
chart2.canvas.style.cursor = CursorStyle.Pointer;
|
|
25335
|
+
}
|
|
25336
|
+
if ((_c2 = element.options.scaleID) == null ? void 0 : _c2.includes(AxisType.X)) {
|
|
25335
25337
|
if (element.options.label) {
|
|
25336
25338
|
element.options.label.xAdjust = chart2.chartArea.left;
|
|
25337
25339
|
}
|
|
@@ -25348,8 +25350,11 @@ const handleLineEnter = (element, chart2, annotation2) => {
|
|
|
25348
25350
|
chart2.draw();
|
|
25349
25351
|
};
|
|
25350
25352
|
const handleLineLeave = (element, chart2, annotation2) => {
|
|
25353
|
+
var _a2, _b2;
|
|
25351
25354
|
element.options.borderWidth = BORDER_WIDTH.INITIAL;
|
|
25352
|
-
chart2.canvas.style.cursor
|
|
25355
|
+
if (!isNil((_b2 = (_a2 = chart2 == null ? void 0 : chart2.canvas) == null ? void 0 : _a2.style) == null ? void 0 : _b2.cursor)) {
|
|
25356
|
+
chart2.canvas.style.cursor = CursorStyle.Initial;
|
|
25357
|
+
}
|
|
25353
25358
|
chart2.hoveredAnnotationId = null;
|
|
25354
25359
|
if (element.options.label) {
|
|
25355
25360
|
element.label.options.display = false;
|
|
@@ -25362,37 +25367,49 @@ const handleLineLeave = (element, chart2, annotation2) => {
|
|
|
25362
25367
|
chart2.draw();
|
|
25363
25368
|
};
|
|
25364
25369
|
const handleBoxEnter = (element, chart2, annotation2) => {
|
|
25370
|
+
var _a2, _b2;
|
|
25365
25371
|
if (annotation2 == null ? void 0 : annotation2.enableDrag) {
|
|
25366
25372
|
chart2.hoveredAnnotationId = element.options.id || null;
|
|
25367
25373
|
chart2.update();
|
|
25368
25374
|
element.options.borderWidth = BORDER_WIDTH.HOVERED;
|
|
25369
|
-
chart2.canvas.style.cursor
|
|
25375
|
+
if (!isNil((_b2 = (_a2 = chart2 == null ? void 0 : chart2.canvas) == null ? void 0 : _a2.style) == null ? void 0 : _b2.cursor)) {
|
|
25376
|
+
chart2.canvas.style.cursor = CursorStyle.Pointer;
|
|
25377
|
+
}
|
|
25370
25378
|
}
|
|
25371
25379
|
chart2.draw();
|
|
25372
25380
|
};
|
|
25373
25381
|
const handleBoxLeave = (element, chart2, annotation2) => {
|
|
25382
|
+
var _a2, _b2;
|
|
25374
25383
|
if (annotation2 == null ? void 0 : annotation2.enableDrag) {
|
|
25375
25384
|
chart2.hoveredAnnotationId = null;
|
|
25376
25385
|
element.options.borderWidth = BORDER_WIDTH.INITIAL;
|
|
25377
|
-
chart2.canvas.style.cursor
|
|
25386
|
+
if (!isNil((_b2 = (_a2 = chart2 == null ? void 0 : chart2.canvas) == null ? void 0 : _a2.style) == null ? void 0 : _b2.cursor)) {
|
|
25387
|
+
chart2.canvas.style.cursor = CursorStyle.Initial;
|
|
25388
|
+
}
|
|
25378
25389
|
chart2.update();
|
|
25379
25390
|
}
|
|
25380
25391
|
chart2.draw();
|
|
25381
25392
|
};
|
|
25382
25393
|
const handlePointEnter = (element, chart2, annotation2) => {
|
|
25394
|
+
var _a2, _b2;
|
|
25383
25395
|
if (annotation2 == null ? void 0 : annotation2.enableDrag) {
|
|
25384
25396
|
chart2.hoveredAnnotationId = element.options.id || null;
|
|
25385
25397
|
chart2.update();
|
|
25386
25398
|
element.options.borderWidth = BORDER_WIDTH.POINT_HOVERED;
|
|
25387
|
-
chart2.canvas.style.cursor
|
|
25399
|
+
if (!isNil((_b2 = (_a2 = chart2 == null ? void 0 : chart2.canvas) == null ? void 0 : _a2.style) == null ? void 0 : _b2.cursor)) {
|
|
25400
|
+
chart2.canvas.style.cursor = CursorStyle.Pointer;
|
|
25401
|
+
}
|
|
25388
25402
|
}
|
|
25389
25403
|
chart2.draw();
|
|
25390
25404
|
};
|
|
25391
25405
|
const handlePointLeave = (element, chart2, annotation2) => {
|
|
25406
|
+
var _a2, _b2;
|
|
25392
25407
|
if (annotation2 == null ? void 0 : annotation2.enableDrag) {
|
|
25393
25408
|
chart2.hoveredAnnotationId = null;
|
|
25394
25409
|
element.options.borderWidth = BORDER_WIDTH.INITIAL;
|
|
25395
|
-
chart2.canvas.style.cursor
|
|
25410
|
+
if (!isNil((_b2 = (_a2 = chart2 == null ? void 0 : chart2.canvas) == null ? void 0 : _a2.style) == null ? void 0 : _b2.cursor)) {
|
|
25411
|
+
chart2.canvas.style.cursor = CursorStyle.Initial;
|
|
25412
|
+
}
|
|
25396
25413
|
chart2.update();
|
|
25397
25414
|
}
|
|
25398
25415
|
chart2.draw();
|
|
@@ -25477,7 +25494,6 @@ const generateAnnotations = (annotationsData) => {
|
|
|
25477
25494
|
const onDragEnd = () => (cord, annotation2) => (ann == null ? void 0 : ann.onDragEnd) ? ann == null ? void 0 : ann.onDragEnd(cord, annotation2) : void 0;
|
|
25478
25495
|
return {
|
|
25479
25496
|
...ann,
|
|
25480
|
-
drawTime: "afterDraw",
|
|
25481
25497
|
display: ann == null ? void 0 : ann.display,
|
|
25482
25498
|
annotationIndex: idx,
|
|
25483
25499
|
id: `${ann == null ? void 0 : ann.label}-${ann == null ? void 0 : ann.value}-${idx}`,
|
|
@@ -25810,13 +25826,13 @@ const useToggleCustomLegendVisibility = (memoState, memoOptions) => {
|
|
|
25810
25826
|
const parent = document.getElementById(
|
|
25811
25827
|
memoOptions.legend.customLegend.customLegendContainerID
|
|
25812
25828
|
);
|
|
25813
|
-
if (parent
|
|
25829
|
+
if (!isNil(parent)) {
|
|
25814
25830
|
parent.style.visibility = memoState.legendEnabled ? "visible" : "hidden";
|
|
25815
25831
|
}
|
|
25816
25832
|
}
|
|
25817
25833
|
}, [
|
|
25818
25834
|
(_b2 = (_a2 = memoOptions == null ? void 0 : memoOptions.legend) == null ? void 0 : _a2.customLegend) == null ? void 0 : _b2.customLegendPlugin,
|
|
25819
|
-
memoState.legendEnabled
|
|
25835
|
+
memoState == null ? void 0 : memoState.legendEnabled
|
|
25820
25836
|
]);
|
|
25821
25837
|
};
|
|
25822
25838
|
const useStoreChartStateInStorage = (memoState, persistenceId) => {
|
|
@@ -26113,13 +26129,16 @@ const calculateAnnotationMetricsInValuesInPixels = (annotation2, scales) => {
|
|
|
26113
26129
|
};
|
|
26114
26130
|
};
|
|
26115
26131
|
const handleAnnotationMouseDown = (event, canvas2, scales, annotations, setDraggingState, hoveredAnnotationId) => {
|
|
26132
|
+
var _a2;
|
|
26116
26133
|
const { x: x2, y: y2 } = getMousePositionInCoordinates(event, canvas2, scales);
|
|
26117
26134
|
const annotation2 = hoveredAnnotationId ? annotations == null ? void 0 : annotations[hoveredAnnotationId] : null;
|
|
26118
26135
|
if (!annotation2)
|
|
26119
26136
|
return;
|
|
26120
26137
|
const metrics = calculateAnnotationMetricsInValues(annotation2);
|
|
26121
26138
|
if (annotation2 && annotation2.enableDrag && !isNil(metrics.centerY) && !isNil(metrics.centerX)) {
|
|
26122
|
-
canvas2.style.cursor
|
|
26139
|
+
if (!isNil((_a2 = canvas2 == null ? void 0 : canvas2.style) == null ? void 0 : _a2.cursor)) {
|
|
26140
|
+
canvas2.style.cursor = CursorStyle.Move;
|
|
26141
|
+
}
|
|
26123
26142
|
const dragStartX = x2 - metrics.centerX;
|
|
26124
26143
|
const dragStartY = y2 - metrics.centerY;
|
|
26125
26144
|
setDraggingState(true, annotation2, dragStartX, dragStartY);
|
|
@@ -26129,8 +26148,11 @@ const handleAnnotationMouseDown = (event, canvas2, scales, annotations, setDragg
|
|
|
26129
26148
|
}
|
|
26130
26149
|
};
|
|
26131
26150
|
const handleAnnotationMouseMove = (event, canvas2, scales, isDragging2, activeAnnotation, dragStartX, dragStartY, chart2) => {
|
|
26151
|
+
var _a2;
|
|
26132
26152
|
if (isDragging2 && activeAnnotation) {
|
|
26133
|
-
canvas2.style.cursor
|
|
26153
|
+
if (!isNil((_a2 = canvas2 == null ? void 0 : canvas2.style) == null ? void 0 : _a2.cursor)) {
|
|
26154
|
+
canvas2.style.cursor = CursorStyle.Move;
|
|
26155
|
+
}
|
|
26134
26156
|
const { x: x2, y: y2 } = getMousePositionInCoordinates(event, canvas2, scales);
|
|
26135
26157
|
const metrics = calculateAnnotationMetricsInValues(activeAnnotation);
|
|
26136
26158
|
let newCenterX = x2 - dragStartX;
|
|
@@ -26177,6 +26199,7 @@ const handleAnnotationMouseMove = (event, canvas2, scales, isDragging2, activeAn
|
|
|
26177
26199
|
}
|
|
26178
26200
|
};
|
|
26179
26201
|
const handleAnnotationMouseUp = (isDragging2, activeAnnotation, chart2, setDraggingState) => {
|
|
26202
|
+
var _a2, _b2;
|
|
26180
26203
|
if (isDragging2) {
|
|
26181
26204
|
if (activeAnnotation) {
|
|
26182
26205
|
const { centerX = -1, centerY = -1 } = calculateAnnotationMetricsInValues(activeAnnotation) ?? {};
|
|
@@ -26186,7 +26209,9 @@ const handleAnnotationMouseUp = (isDragging2, activeAnnotation, chart2, setDragg
|
|
|
26186
26209
|
cloneDeep(activeAnnotation)
|
|
26187
26210
|
);
|
|
26188
26211
|
}
|
|
26189
|
-
chart2.canvas.style.cursor
|
|
26212
|
+
if (!isNil((_b2 = (_a2 = chart2 == null ? void 0 : chart2.canvas) == null ? void 0 : _a2.style) == null ? void 0 : _b2.cursor)) {
|
|
26213
|
+
chart2.canvas.style.cursor = CursorStyle.Pointer;
|
|
26214
|
+
}
|
|
26190
26215
|
setDraggingState(false, null);
|
|
26191
26216
|
}
|
|
26192
26217
|
chart2.update();
|
|
@@ -26276,8 +26301,8 @@ const annotationDraggerPlugin = {
|
|
|
26276
26301
|
dragStartY = startY;
|
|
26277
26302
|
}
|
|
26278
26303
|
};
|
|
26279
|
-
if (!canvas2.dataset.annotationDraggerInitialized && pluginOptions.enabled && hoveredAnnotationId) {
|
|
26280
|
-
canvas2.addEventListener(MouseEvents.MOUSEDOWN, (event) => {
|
|
26304
|
+
if (canvas2 && !canvas2.dataset.annotationDraggerInitialized && pluginOptions.enabled && hoveredAnnotationId) {
|
|
26305
|
+
canvas2 == null ? void 0 : canvas2.addEventListener(MouseEvents.MOUSEDOWN, (event) => {
|
|
26281
26306
|
var _a3, _b3, _c3;
|
|
26282
26307
|
handleAnnotationMouseDown(
|
|
26283
26308
|
event,
|
|
@@ -26288,7 +26313,7 @@ const annotationDraggerPlugin = {
|
|
|
26288
26313
|
chart2.hoveredAnnotationId
|
|
26289
26314
|
);
|
|
26290
26315
|
});
|
|
26291
|
-
canvas2.addEventListener(MouseEvents.MOUSEMOVE, (event) => {
|
|
26316
|
+
canvas2 == null ? void 0 : canvas2.addEventListener(MouseEvents.MOUSEMOVE, (event) => {
|
|
26292
26317
|
handleAnnotationMouseMove(
|
|
26293
26318
|
event,
|
|
26294
26319
|
canvas2,
|
|
@@ -26300,7 +26325,7 @@ const annotationDraggerPlugin = {
|
|
|
26300
26325
|
chart2
|
|
26301
26326
|
);
|
|
26302
26327
|
});
|
|
26303
|
-
canvas2.addEventListener(MouseEvents.MOUSEUP, () => {
|
|
26328
|
+
canvas2 == null ? void 0 : canvas2.addEventListener(MouseEvents.MOUSEUP, () => {
|
|
26304
26329
|
handleAnnotationMouseUp(
|
|
26305
26330
|
isDragging2,
|
|
26306
26331
|
activeAnnotation,
|
|
@@ -26311,11 +26336,11 @@ const annotationDraggerPlugin = {
|
|
|
26311
26336
|
canvas2.dataset.annotationDraggerInitialized = "true";
|
|
26312
26337
|
}
|
|
26313
26338
|
if (!pluginOptions.enabled) {
|
|
26314
|
-
canvas2.removeEventListener(MouseEvents.MOUSEDOWN, () => {
|
|
26339
|
+
canvas2 == null ? void 0 : canvas2.removeEventListener(MouseEvents.MOUSEDOWN, () => {
|
|
26315
26340
|
});
|
|
26316
|
-
canvas2.removeEventListener(MouseEvents.MOUSEMOVE, () => {
|
|
26341
|
+
canvas2 == null ? void 0 : canvas2.removeEventListener(MouseEvents.MOUSEMOVE, () => {
|
|
26317
26342
|
});
|
|
26318
|
-
canvas2.removeEventListener(MouseEvents.MOUSEUP, () => {
|
|
26343
|
+
canvas2 == null ? void 0 : canvas2.removeEventListener(MouseEvents.MOUSEUP, () => {
|
|
26319
26344
|
});
|
|
26320
26345
|
canvas2.dataset.annotationDraggerInitialized = "";
|
|
26321
26346
|
}
|