@oliasoft-open-source/charts-library 4.3.3-beta-1 → 4.3.3-beta-3
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 +46 -44
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26222,11 +26222,11 @@ const annotationLabel = (ctx, annotations, scales) => {
|
|
|
26222
26222
|
var _a2;
|
|
26223
26223
|
if (annotation2.type === AnnotationType.POINT && !isNil(annotation2 == null ? void 0 : annotation2.label) && ((_a2 = annotation2 == null ? void 0 : annotation2.label) == null ? void 0 : _a2.display)) {
|
|
26224
26224
|
const { content, font, color: color2, position, padding } = (annotation2 == null ? void 0 : annotation2.label) ?? {};
|
|
26225
|
-
ctx.save();
|
|
26225
|
+
ctx == null ? void 0 : ctx.save();
|
|
26226
26226
|
ctx.font = font;
|
|
26227
26227
|
ctx.fillStyle = color2;
|
|
26228
26228
|
const { centerX = -1, centerY = -1 } = calculateAnnotationMetricsInValuesInPixels(annotation2, scales);
|
|
26229
|
-
const textWidth = ctx.measureText(content).width;
|
|
26229
|
+
const textWidth = ctx == null ? void 0 : ctx.measureText(content).width;
|
|
26230
26230
|
let textX = centerX - textWidth / 2;
|
|
26231
26231
|
let textY = centerY + 20;
|
|
26232
26232
|
switch (position) {
|
|
@@ -26242,8 +26242,8 @@ const annotationLabel = (ctx, annotations, scales) => {
|
|
|
26242
26242
|
textY = centerY;
|
|
26243
26243
|
break;
|
|
26244
26244
|
}
|
|
26245
|
-
ctx.fillText(content, textX, textY);
|
|
26246
|
-
ctx.restore();
|
|
26245
|
+
ctx == null ? void 0 : ctx.fillText(content, textX, textY);
|
|
26246
|
+
ctx == null ? void 0 : ctx.restore();
|
|
26247
26247
|
}
|
|
26248
26248
|
});
|
|
26249
26249
|
};
|
|
@@ -26255,9 +26255,9 @@ const annotationDraggerPlugin = {
|
|
|
26255
26255
|
if (!annotations)
|
|
26256
26256
|
return;
|
|
26257
26257
|
annotationLabel(
|
|
26258
|
-
chart2.ctx,
|
|
26258
|
+
chart2 == null ? void 0 : chart2.ctx,
|
|
26259
26259
|
annotations,
|
|
26260
|
-
chart2.scales
|
|
26260
|
+
chart2 == null ? void 0 : chart2.scales
|
|
26261
26261
|
);
|
|
26262
26262
|
const pluginOptions = ((_d2 = (_c2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _c2.plugins) == null ? void 0 : _d2.annotationDraggerPlugin) || {
|
|
26263
26263
|
enabled: false
|
|
@@ -26281,14 +26281,14 @@ const annotationDraggerPlugin = {
|
|
|
26281
26281
|
}
|
|
26282
26282
|
},
|
|
26283
26283
|
afterUpdate(chart2) {
|
|
26284
|
-
var _a2, _b2, _c2, _d2;
|
|
26284
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
26285
26285
|
const { canvas: canvas2, scales, hoveredAnnotationId } = chart2;
|
|
26286
26286
|
const pluginOptions = ((_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.plugins) == null ? void 0 : _b2.annotationDraggerPlugin) || {
|
|
26287
26287
|
enabled: false
|
|
26288
26288
|
};
|
|
26289
26289
|
const typedScales = { x: scales.x, y: scales.y };
|
|
26290
|
-
let annotations = ((_d2 = (_c2 = chart2.options.plugins) == null ? void 0 :
|
|
26291
|
-
if (!chart2
|
|
26290
|
+
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) ?? {};
|
|
26291
|
+
if (!chart2 || !annotations)
|
|
26292
26292
|
return;
|
|
26293
26293
|
let isDragging2 = false;
|
|
26294
26294
|
let dragStartX, dragStartY;
|
|
@@ -26301,46 +26301,48 @@ const annotationDraggerPlugin = {
|
|
|
26301
26301
|
dragStartY = startY;
|
|
26302
26302
|
}
|
|
26303
26303
|
};
|
|
26304
|
-
if (!canvas2.dataset.annotationDraggerInitialized && pluginOptions.enabled && hoveredAnnotationId) {
|
|
26305
|
-
|
|
26306
|
-
|
|
26307
|
-
|
|
26308
|
-
|
|
26309
|
-
|
|
26310
|
-
|
|
26311
|
-
|
|
26312
|
-
|
|
26313
|
-
|
|
26314
|
-
|
|
26315
|
-
|
|
26316
|
-
|
|
26317
|
-
|
|
26318
|
-
|
|
26319
|
-
|
|
26320
|
-
|
|
26321
|
-
|
|
26322
|
-
|
|
26323
|
-
|
|
26324
|
-
|
|
26325
|
-
|
|
26326
|
-
|
|
26327
|
-
|
|
26328
|
-
|
|
26329
|
-
|
|
26330
|
-
|
|
26331
|
-
|
|
26332
|
-
|
|
26333
|
-
|
|
26334
|
-
|
|
26335
|
-
|
|
26304
|
+
if (!((_f2 = canvas2 == null ? void 0 : canvas2.dataset) == null ? void 0 : _f2.annotationDraggerInitialized) && (pluginOptions == null ? void 0 : pluginOptions.enabled) && hoveredAnnotationId) {
|
|
26305
|
+
if (!isNil(canvas2)) {
|
|
26306
|
+
canvas2 == null ? void 0 : canvas2.addEventListener(MouseEvents.MOUSEDOWN, (event) => {
|
|
26307
|
+
var _a3, _b3, _c3;
|
|
26308
|
+
handleAnnotationMouseDown(
|
|
26309
|
+
event,
|
|
26310
|
+
canvas2,
|
|
26311
|
+
typedScales,
|
|
26312
|
+
(_c3 = (_b3 = (_a3 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a3.plugins) == null ? void 0 : _b3.annotation) == null ? void 0 : _c3.annotations,
|
|
26313
|
+
setDraggingState,
|
|
26314
|
+
chart2.hoveredAnnotationId
|
|
26315
|
+
);
|
|
26316
|
+
});
|
|
26317
|
+
canvas2 == null ? void 0 : canvas2.addEventListener(MouseEvents.MOUSEMOVE, (event) => {
|
|
26318
|
+
handleAnnotationMouseMove(
|
|
26319
|
+
event,
|
|
26320
|
+
canvas2,
|
|
26321
|
+
typedScales,
|
|
26322
|
+
isDragging2,
|
|
26323
|
+
activeAnnotation,
|
|
26324
|
+
dragStartX,
|
|
26325
|
+
dragStartY,
|
|
26326
|
+
chart2
|
|
26327
|
+
);
|
|
26328
|
+
});
|
|
26329
|
+
canvas2 == null ? void 0 : canvas2.addEventListener(MouseEvents.MOUSEUP, () => {
|
|
26330
|
+
handleAnnotationMouseUp(
|
|
26331
|
+
isDragging2,
|
|
26332
|
+
activeAnnotation,
|
|
26333
|
+
chart2,
|
|
26334
|
+
setDraggingState
|
|
26335
|
+
);
|
|
26336
|
+
});
|
|
26337
|
+
}
|
|
26336
26338
|
canvas2.dataset.annotationDraggerInitialized = "true";
|
|
26337
26339
|
}
|
|
26338
26340
|
if (!pluginOptions.enabled) {
|
|
26339
|
-
canvas2.removeEventListener(MouseEvents.MOUSEDOWN, () => {
|
|
26341
|
+
canvas2 == null ? void 0 : canvas2.removeEventListener(MouseEvents.MOUSEDOWN, () => {
|
|
26340
26342
|
});
|
|
26341
|
-
canvas2.removeEventListener(MouseEvents.MOUSEMOVE, () => {
|
|
26343
|
+
canvas2 == null ? void 0 : canvas2.removeEventListener(MouseEvents.MOUSEMOVE, () => {
|
|
26342
26344
|
});
|
|
26343
|
-
canvas2.removeEventListener(MouseEvents.MOUSEUP, () => {
|
|
26345
|
+
canvas2 == null ? void 0 : canvas2.removeEventListener(MouseEvents.MOUSEUP, () => {
|
|
26344
26346
|
});
|
|
26345
26347
|
canvas2.dataset.annotationDraggerInitialized = "";
|
|
26346
26348
|
}
|