@oliasoft-open-source/charts-library 5.4.0 → 5.5.0-beta-1
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/assets/{Color-AVL7NMMY-994VbFdE.js → Color-AVL7NMMY-zaNUeRlM.js} +1 -1
- package/dist/assets/{DocsRenderer-PQXLIZUC-bAUpr2nb.js → DocsRenderer-PQXLIZUC-Bx-B9-KR.js} +2 -2
- package/dist/assets/{bar-chart.stories-BgSpvkVq.js → bar-chart.stories-7JsLHcG3.js} +1 -1
- package/dist/assets/client-BU8uqlt-.js +1 -0
- package/dist/assets/{components-Dh2frV4l.js → components-BRtSYMX1.js} +1 -1
- package/dist/assets/{get-draggableData-DaqZhgHK.js → get-draggableData-DLG_9bYP.js} +1 -1
- package/dist/assets/{iframe-D8t45Jkw.js → iframe-BB_acgFo.js} +5 -5
- package/dist/assets/{legend-CPlrxuvf.js → legend-DjGWzEoG.js} +2 -2
- package/dist/assets/{legend-context-SNdgAaoM.js → legend-context-DYd0_91O.js} +3 -3
- package/dist/assets/line-chart-Dr0Umbr0.js +1 -0
- package/dist/assets/{line-chart.stories-ChpI0UHM.js → line-chart.stories-IpGXM2oK.js} +57 -45
- package/dist/assets/{line-chart.test-case.stories-B-SWX8h6.js → line-chart.test-case.stories-C8qzoxBG.js} +1 -1
- package/dist/assets/{pie-chart.stories-CBcjkrFA.js → pie-chart.stories-CCG8Hazm.js} +1 -1
- package/dist/assets/{react-18-DMqmYXih.js → react-18-ChWqu3Oz.js} +1 -1
- package/dist/assets/{react-BgjAoB93.js → react-DgulxvbH.js} +1 -1
- package/dist/assets/{scatter-chart.stories-BqsR5bsR.js → scatter-chart.stories-D4Z0da7a.js} +1 -1
- package/dist/common/common.interface.d.ts +9 -0
- package/dist/common/helpers/enums.d.ts +2 -1
- package/dist/common/helpers/get-chart-annotation.d.ts +5 -3
- package/dist/common/plugins/annotation-dragger-plugin/enums.d.ts +2 -1
- package/dist/iframe.html +1 -1
- package/dist/index.js +285 -110
- package/dist/index.json +1 -1
- package/dist/line-chart/plugins/callout-plugin/callout-plugin.d.ts +11 -0
- package/dist/line-chart/plugins/callout-plugin/helpers.d.ts +25 -0
- package/dist/line-chart/utils/get-line-chart-tooltips.d.ts +4 -8
- package/dist/project.json +1 -1
- package/dist/src/components/common/common.interface.d.ts +3 -0
- package/dist/src/components/common/helpers/enums.d.ts +2 -1
- package/dist/src/components/common/helpers/get-chart-annotation.d.ts +5 -3
- package/dist/src/components/common/plugins/annotation-dragger-plugin/enums.d.ts +2 -1
- package/dist/src/components/line-chart/plugins/callout-plugin/callout-plugin.d.ts +11 -0
- package/dist/src/components/line-chart/plugins/callout-plugin/helpers.d.ts +25 -0
- package/package.json +1 -1
- package/dist/assets/client-BDy5C6da.js +0 -1
- package/dist/assets/line-chart-WOEGLOk2.js +0 -1
package/dist/index.js
CHANGED
|
@@ -17632,6 +17632,7 @@ let AnnotationType = /* @__PURE__ */ function(AnnotationType$2) {
|
|
|
17632
17632
|
AnnotationType$2["Ellipse"] = "ellipse";
|
|
17633
17633
|
AnnotationType$2["Line"] = "line";
|
|
17634
17634
|
AnnotationType$2["Text"] = "text";
|
|
17635
|
+
AnnotationType$2["Label"] = "label";
|
|
17635
17636
|
return AnnotationType$2;
|
|
17636
17637
|
}({});
|
|
17637
17638
|
let PointStyle = /* @__PURE__ */ function(PointStyle$1) {
|
|
@@ -18727,6 +18728,7 @@ var defaultAnnotations$2 = (annotations) => ({
|
|
|
18727
18728
|
showAnnotations: annotations?.showAnnotations ?? false,
|
|
18728
18729
|
controlAnnotation: annotations?.controlAnnotation ?? false,
|
|
18729
18730
|
enableDragAnnotation: annotations?.enableDragAnnotation ?? false,
|
|
18731
|
+
enableCalloutAnnotation: annotations?.enableCalloutAnnotation ?? false,
|
|
18730
18732
|
annotationsData: defaultAnnotationsData$2(annotations?.annotationsData)
|
|
18731
18733
|
});
|
|
18732
18734
|
var defaultLegend$3 = (legend$1) => ({
|
|
@@ -19286,6 +19288,7 @@ let AnnotationType$1 = /* @__PURE__ */ function(AnnotationType$2) {
|
|
|
19286
19288
|
AnnotationType$2["BOX"] = "box";
|
|
19287
19289
|
AnnotationType$2["LINE"] = "line";
|
|
19288
19290
|
AnnotationType$2["ELLIPSE"] = "ellipse";
|
|
19291
|
+
AnnotationType$2["LABEL"] = "label";
|
|
19289
19292
|
return AnnotationType$2;
|
|
19290
19293
|
}({});
|
|
19291
19294
|
let DragAxis = /* @__PURE__ */ function(DragAxis$1) {
|
|
@@ -19368,112 +19371,199 @@ var handlePointLeave = (element, chart$4, annotation$1) => {
|
|
|
19368
19371
|
}
|
|
19369
19372
|
chart$4.draw();
|
|
19370
19373
|
};
|
|
19371
|
-
var
|
|
19372
|
-
|
|
19373
|
-
|
|
19374
|
-
|
|
19375
|
-
|
|
19376
|
-
|
|
19377
|
-
|
|
19378
|
-
|
|
19379
|
-
|
|
19380
|
-
|
|
19381
|
-
|
|
19382
|
-
|
|
19383
|
-
|
|
19384
|
-
|
|
19385
|
-
|
|
19386
|
-
|
|
19387
|
-
|
|
19388
|
-
|
|
19389
|
-
|
|
19390
|
-
|
|
19391
|
-
|
|
19392
|
-
|
|
19393
|
-
|
|
19394
|
-
|
|
19395
|
-
|
|
19396
|
-
|
|
19397
|
-
|
|
19398
|
-
|
|
19399
|
-
|
|
19400
|
-
|
|
19401
|
-
|
|
19402
|
-
|
|
19403
|
-
|
|
19404
|
-
|
|
19405
|
-
|
|
19406
|
-
|
|
19407
|
-
|
|
19408
|
-
|
|
19409
|
-
|
|
19410
|
-
|
|
19411
|
-
|
|
19412
|
-
|
|
19413
|
-
|
|
19414
|
-
|
|
19415
|
-
|
|
19416
|
-
|
|
19417
|
-
}[type] || defLabel;
|
|
19418
|
-
const enter = ({ element }, { chart: chart$4 }) => {
|
|
19419
|
-
switch (type) {
|
|
19420
|
-
case AnnotationType$1.LINE:
|
|
19421
|
-
handleLineEnter(element, chart$4, ann);
|
|
19422
|
-
break;
|
|
19423
|
-
case AnnotationType$1.BOX:
|
|
19424
|
-
handleBoxEnter(element, chart$4, ann);
|
|
19425
|
-
break;
|
|
19426
|
-
case AnnotationType$1.POINT:
|
|
19427
|
-
handlePointEnter(element, chart$4, ann);
|
|
19428
|
-
break;
|
|
19429
|
-
default: break;
|
|
19430
|
-
}
|
|
19431
|
-
};
|
|
19432
|
-
const leave = ({ element }, { chart: chart$4 }) => {
|
|
19433
|
-
switch (type) {
|
|
19434
|
-
case AnnotationType$1.LINE:
|
|
19435
|
-
handleLineLeave(element, chart$4, ann);
|
|
19436
|
-
break;
|
|
19437
|
-
case AnnotationType$1.BOX:
|
|
19438
|
-
handleBoxLeave(element, chart$4, ann);
|
|
19439
|
-
break;
|
|
19440
|
-
case AnnotationType$1.POINT:
|
|
19441
|
-
handlePointLeave(element, chart$4, ann);
|
|
19442
|
-
break;
|
|
19443
|
-
default: break;
|
|
19444
|
-
}
|
|
19445
|
-
};
|
|
19446
|
-
const onDragStart = () => (cord, annotation$1) => ann?.onDragStart ? ann?.onDragStart(cord, annotation$1) : void 0;
|
|
19447
|
-
const onDrag = () => (cord, annotation$1) => ann?.onDrag ? ann?.onDrag(cord, annotation$1) : void 0;
|
|
19448
|
-
const onDragEnd = () => (cord, annotation$1) => ann?.onDragEnd ? ann?.onDragEnd(cord, annotation$1) : void 0;
|
|
19449
|
-
return {
|
|
19450
|
-
...ann,
|
|
19451
|
-
display: ann?.display,
|
|
19452
|
-
annotationIndex: idx,
|
|
19453
|
-
id: `${ann?.label}-${ann?.value}-${idx}`,
|
|
19454
|
-
scaleID,
|
|
19455
|
-
label,
|
|
19374
|
+
var handleLabelEnter = (element, chart$4, annotation$1) => {
|
|
19375
|
+
if (annotation$1?.enableDrag) {
|
|
19376
|
+
chart$4.hoveredAnnotationId = element.options.id || null;
|
|
19377
|
+
chart$4.update("none");
|
|
19378
|
+
element.options.borderWidth = BORDER_WIDTH.POINT_HOVERED;
|
|
19379
|
+
chart$4.canvas.style.cursor = CursorStyle.Pointer;
|
|
19380
|
+
}
|
|
19381
|
+
chart$4.draw();
|
|
19382
|
+
};
|
|
19383
|
+
var handleLabelLeave = (element, chart$4, annotation$1) => {
|
|
19384
|
+
if (annotation$1?.enableDrag) {
|
|
19385
|
+
chart$4.hoveredAnnotationId = null;
|
|
19386
|
+
element.options.borderWidth = BORDER_WIDTH.INITIAL;
|
|
19387
|
+
chart$4.canvas.style.cursor = CursorStyle.Initial;
|
|
19388
|
+
chart$4.update("none");
|
|
19389
|
+
}
|
|
19390
|
+
chart$4.draw();
|
|
19391
|
+
};
|
|
19392
|
+
const generateAnn = (ann, index$2) => {
|
|
19393
|
+
const scaleID = ann?.annotationAxis ?? void 0;
|
|
19394
|
+
const inputColor = ann?.color ?? COLORS[index$2];
|
|
19395
|
+
const color$3 = !!ann?.opacity ? addTransparency(inputColor, ann?.opacity) : inputColor;
|
|
19396
|
+
const type = ann?.type ?? AnnotationType$1.LINE;
|
|
19397
|
+
const adjustScaleRange$1 = ann?.adjustScaleRange;
|
|
19398
|
+
const borderColor = {
|
|
19399
|
+
[AnnotationType$1.LINE]: color$3,
|
|
19400
|
+
[AnnotationType$1.POINT]: color$3,
|
|
19401
|
+
[AnnotationType$1.LABEL]: color$3,
|
|
19402
|
+
[AnnotationType$1.BOX]: color$3,
|
|
19403
|
+
[AnnotationType$1.ELLIPSE]: "transparent"
|
|
19404
|
+
}[type] || "transparent";
|
|
19405
|
+
const borderWidth = {
|
|
19406
|
+
[AnnotationType$1.LINE]: BORDER_WIDTH.INITIAL,
|
|
19407
|
+
[AnnotationType$1.BOX]: BORDER_WIDTH.ZERO,
|
|
19408
|
+
[AnnotationType$1.POINT]: BORDER_WIDTH.ZERO,
|
|
19409
|
+
[AnnotationType$1.LABEL]: BORDER_WIDTH.ZERO,
|
|
19410
|
+
[AnnotationType$1.ELLIPSE]: ann?.borderWidth ?? 0
|
|
19411
|
+
}[type] ?? 0;
|
|
19412
|
+
const borderDash = type === AnnotationType$1.LINE ? ANNOTATION_DASH : void 0;
|
|
19413
|
+
const defLabel = {
|
|
19414
|
+
content: ann?.label,
|
|
19415
|
+
display: true,
|
|
19416
|
+
font: { weight: "normal" }
|
|
19417
|
+
};
|
|
19418
|
+
const label = {
|
|
19419
|
+
[AnnotationType$1.LINE]: {
|
|
19456
19420
|
backgroundColor: color$3,
|
|
19457
|
-
|
|
19458
|
-
|
|
19459
|
-
|
|
19460
|
-
|
|
19461
|
-
|
|
19462
|
-
|
|
19463
|
-
|
|
19464
|
-
|
|
19465
|
-
|
|
19466
|
-
|
|
19467
|
-
|
|
19468
|
-
|
|
19469
|
-
|
|
19470
|
-
|
|
19421
|
+
content: ann?.label,
|
|
19422
|
+
display: false,
|
|
19423
|
+
position: Position.Top
|
|
19424
|
+
},
|
|
19425
|
+
[AnnotationType$1.POINT]: {
|
|
19426
|
+
backgroundColor: ann?.labelConfig?.backgroundColor ?? "transparent",
|
|
19427
|
+
content: ann?.label,
|
|
19428
|
+
display: ann?.labelConfig?.display ?? !!ann?.label,
|
|
19429
|
+
position: ann?.labelConfig?.position ?? Position.Bottom,
|
|
19430
|
+
color: ann?.labelConfig?.color ?? "hsl(60, 10.34482759%, 12.5%)",
|
|
19431
|
+
font: ann?.labelConfig?.font ?? `12px "Roobert", "Noto Sans", sans-serif`,
|
|
19432
|
+
borderWidth: BORDER_WIDTH.INITIAL,
|
|
19433
|
+
padding: 5,
|
|
19434
|
+
borderRadius: 3,
|
|
19435
|
+
borderColor: ann?.labelConfig?.borderColor ?? "transparent"
|
|
19436
|
+
},
|
|
19437
|
+
[AnnotationType$1.LABEL]: defLabel,
|
|
19438
|
+
[AnnotationType$1.BOX]: defLabel,
|
|
19439
|
+
[AnnotationType$1.ELLIPSE]: defLabel
|
|
19440
|
+
}[type] || defLabel;
|
|
19441
|
+
const enter = ({ element }, { chart: chart$4 }) => {
|
|
19442
|
+
console.log("enter");
|
|
19443
|
+
switch (type) {
|
|
19444
|
+
case AnnotationType$1.LINE:
|
|
19445
|
+
handleLineEnter(element, chart$4, ann);
|
|
19446
|
+
break;
|
|
19447
|
+
case AnnotationType$1.BOX:
|
|
19448
|
+
handleBoxEnter(element, chart$4, ann);
|
|
19449
|
+
break;
|
|
19450
|
+
case AnnotationType$1.LABEL:
|
|
19451
|
+
handleLabelEnter(element, chart$4, ann);
|
|
19452
|
+
break;
|
|
19453
|
+
case AnnotationType$1.POINT:
|
|
19454
|
+
handlePointEnter(element, chart$4, ann);
|
|
19455
|
+
break;
|
|
19456
|
+
default: break;
|
|
19457
|
+
}
|
|
19458
|
+
};
|
|
19459
|
+
const leave = ({ element }, { chart: chart$4 }) => {
|
|
19460
|
+
switch (type) {
|
|
19461
|
+
case AnnotationType$1.LINE:
|
|
19462
|
+
handleLineLeave(element, chart$4, ann);
|
|
19463
|
+
break;
|
|
19464
|
+
case AnnotationType$1.BOX:
|
|
19465
|
+
handleBoxLeave(element, chart$4, ann);
|
|
19466
|
+
break;
|
|
19467
|
+
case AnnotationType$1.LABEL:
|
|
19468
|
+
handleLabelLeave(element, chart$4, ann);
|
|
19469
|
+
break;
|
|
19470
|
+
case AnnotationType$1.POINT:
|
|
19471
|
+
handlePointLeave(element, chart$4, ann);
|
|
19472
|
+
break;
|
|
19473
|
+
default: break;
|
|
19474
|
+
}
|
|
19475
|
+
};
|
|
19476
|
+
const onDragStart = () => (cord, annotation$1) => ann?.onDragStart ? ann?.onDragStart(cord, annotation$1) : void 0;
|
|
19477
|
+
const onDrag = () => (cord, annotation$1) => ann?.onDrag ? ann?.onDrag(cord, annotation$1) : void 0;
|
|
19478
|
+
const onDragEnd = () => (cord, annotation$1) => ann?.onDragEnd ? ann?.onDragEnd(cord, annotation$1) : void 0;
|
|
19479
|
+
return {
|
|
19480
|
+
...ann,
|
|
19481
|
+
display: ann?.display,
|
|
19482
|
+
annotationIndex: index$2,
|
|
19483
|
+
id: ann?.id ?? `${ann?.label}-${index$2}`,
|
|
19484
|
+
scaleID,
|
|
19485
|
+
label,
|
|
19486
|
+
backgroundColor: color$3,
|
|
19487
|
+
borderColor,
|
|
19488
|
+
borderWidth,
|
|
19489
|
+
borderDash,
|
|
19490
|
+
type,
|
|
19491
|
+
adjustScaleRange: adjustScaleRange$1,
|
|
19492
|
+
enter,
|
|
19493
|
+
leave,
|
|
19494
|
+
onDragStart,
|
|
19495
|
+
onDrag,
|
|
19496
|
+
onDragEnd,
|
|
19497
|
+
pointStyle: ann?.pointStyle ?? PointStyle.Circle,
|
|
19498
|
+
resizable: ann?.resizable ?? true,
|
|
19499
|
+
displayDragCoordinates: ann?.displayDragCoordinates ?? true
|
|
19500
|
+
};
|
|
19501
|
+
};
|
|
19502
|
+
var getCalloutAnnotation = (refAnnotation, index$2) => {
|
|
19503
|
+
const generated = generateAnn(refAnnotation, index$2);
|
|
19504
|
+
if (!generated) return [];
|
|
19505
|
+
const { label,...baseRest } = generated;
|
|
19506
|
+
const baseId = baseRest.id;
|
|
19507
|
+
const calloutCfg = refAnnotation?.labelConfig?.callout ?? {};
|
|
19508
|
+
const baseAnnotation = {
|
|
19509
|
+
...baseRest,
|
|
19510
|
+
label: { display: false }
|
|
19511
|
+
};
|
|
19512
|
+
const side = index$2 % 2 === 0 ? 1 : -1;
|
|
19513
|
+
const row = Math.floor(index$2 / 2);
|
|
19514
|
+
const xAdjust = typeof calloutCfg.xAdjust === "number" ? calloutCfg.xAdjust : side * 60;
|
|
19515
|
+
const yAdjust = typeof calloutCfg.yAdjust === "number" ? calloutCfg.yAdjust : -40 - row * 22;
|
|
19516
|
+
const color$3 = calloutCfg?.color ?? "hsl(60, 10.34482759%, 12.5%)";
|
|
19517
|
+
const font = calloutCfg?.font ?? `12px "Roobert", "Noto Sans", sans-serif`;
|
|
19518
|
+
const borderColor = calloutCfg?.borderColor ?? "transparent";
|
|
19519
|
+
const strokeStyle = calloutCfg.strokeStyle ?? baseAnnotation.borderColor;
|
|
19520
|
+
const lineWidth = typeof calloutCfg.lineWidth === "number" ? calloutCfg.lineWidth : 1;
|
|
19521
|
+
const startOffset = typeof calloutCfg.startOffset === "number" ? calloutCfg.startOffset : 4;
|
|
19522
|
+
const endOffset = typeof calloutCfg.endOffset === "number" ? calloutCfg.endOffset : 4;
|
|
19523
|
+
return [baseAnnotation, {
|
|
19524
|
+
...baseAnnotation,
|
|
19525
|
+
id: `callout-annotation-${index$2}`,
|
|
19526
|
+
type: "label",
|
|
19527
|
+
backgroundColor: "transparent",
|
|
19528
|
+
content: `${label?.content ?? refAnnotation?.label ?? ""}`,
|
|
19529
|
+
color: color$3,
|
|
19530
|
+
font,
|
|
19531
|
+
borderColor,
|
|
19532
|
+
borderWidth: BORDER_WIDTH.INITIAL,
|
|
19533
|
+
padding: 5,
|
|
19534
|
+
xAdjust,
|
|
19535
|
+
yAdjust,
|
|
19536
|
+
resizable: false,
|
|
19537
|
+
displayDragCoordinates: false,
|
|
19538
|
+
enableDrag: true,
|
|
19539
|
+
enter: ({ element }, { chart: chart$4 }) => {
|
|
19540
|
+
return handleLabelEnter(element, chart$4, { enableDrag: true });
|
|
19541
|
+
},
|
|
19542
|
+
leave: ({ element }, { chart: chart$4 }) => {
|
|
19543
|
+
return handleLabelLeave(element, chart$4, { enableDrag: true });
|
|
19544
|
+
},
|
|
19545
|
+
onDragStart: calloutCfg?.onDragStart ? () => (coords) => calloutCfg?.onDragStart?.(coords, refAnnotation) : void 0,
|
|
19546
|
+
onDrag: calloutCfg?.onDrag ? () => (coords) => calloutCfg?.onDrag?.(coords, refAnnotation) : void 0,
|
|
19547
|
+
onDragEnd: calloutCfg?.onDragEnd ? () => (coords) => calloutCfg?.onDragEnd?.(coords, refAnnotation) : void 0,
|
|
19548
|
+
calloutConnector: {
|
|
19549
|
+
enabled: true,
|
|
19550
|
+
fromId: baseId,
|
|
19551
|
+
strokeStyle,
|
|
19552
|
+
lineWidth,
|
|
19553
|
+
startOffset,
|
|
19554
|
+
endOffset
|
|
19555
|
+
}
|
|
19556
|
+
}];
|
|
19557
|
+
};
|
|
19558
|
+
var generateAnnotations = (annotationsData) => {
|
|
19559
|
+
return annotationsData?.flatMap((ann, idx) => {
|
|
19560
|
+
if (ann?.labelConfig?.callout?.enabled ?? false) return getCalloutAnnotation(ann, idx);
|
|
19561
|
+
return generateAnn(ann, idx);
|
|
19471
19562
|
});
|
|
19472
19563
|
};
|
|
19473
|
-
|
|
19564
|
+
const getAnnotation = ({ showAnnotations, annotationsData }) => {
|
|
19474
19565
|
return showAnnotations && annotationsData && annotationsData?.length ? generateAnnotations(annotationsData) ?? [] : [];
|
|
19475
19566
|
};
|
|
19476
|
-
var get_chart_annotation_default = getAnnotation;
|
|
19477
19567
|
const useUpdateAnnotations = (options, dispatch) => {
|
|
19478
19568
|
if (!options.annotations?.controlAnnotation) return;
|
|
19479
19569
|
const prevAnnotationsRef = useRef(null);
|
|
@@ -19483,7 +19573,7 @@ const useUpdateAnnotations = (options, dispatch) => {
|
|
|
19483
19573
|
if (!prev || prev.showAnnotations !== showAnnotations || !isEqual(prev.annotationsData, annotationsData)) {
|
|
19484
19574
|
dispatch({
|
|
19485
19575
|
type: SET_ANNOTATION,
|
|
19486
|
-
payload:
|
|
19576
|
+
payload: getAnnotation({
|
|
19487
19577
|
showAnnotations,
|
|
19488
19578
|
annotationsData
|
|
19489
19579
|
})
|
|
@@ -19502,7 +19592,7 @@ const LegendProvider = ({ children, options, datasets }) => {
|
|
|
19502
19592
|
...ds,
|
|
19503
19593
|
hidden: false
|
|
19504
19594
|
} })) ?? [];
|
|
19505
|
-
const annotation$1 =
|
|
19595
|
+
const annotation$1 = getAnnotation({
|
|
19506
19596
|
showAnnotations,
|
|
19507
19597
|
annotationsData
|
|
19508
19598
|
});
|
|
@@ -19581,7 +19671,11 @@ const useLegendState = ({ chartRef, options }) => {
|
|
|
19581
19671
|
const toAnnotationObject = (annotationArr = []) => {
|
|
19582
19672
|
let annotations = {};
|
|
19583
19673
|
if (annotationArr.length) annotations = annotationArr.reduce((acc, annotation$1, idx) => {
|
|
19584
|
-
|
|
19674
|
+
const key = annotation$1?.id ?? `annotation${idx + 1}`;
|
|
19675
|
+
acc[key] = {
|
|
19676
|
+
...annotation$1,
|
|
19677
|
+
id: key
|
|
19678
|
+
};
|
|
19585
19679
|
return acc;
|
|
19586
19680
|
}, {});
|
|
19587
19681
|
return { annotations };
|
|
@@ -19603,7 +19697,7 @@ const useChartOptions = ({ chartRef, state, options, dispatch, generatedDatasets
|
|
|
19603
19697
|
}) ?? {};
|
|
19604
19698
|
const { state: legendState } = useLegend() ?? {};
|
|
19605
19699
|
const { annotation: annotationFromLegend } = legendState ?? {};
|
|
19606
|
-
const annotation$1 = (controlAnnotation ? annotationFromLegend :
|
|
19700
|
+
const annotation$1 = (controlAnnotation ? annotationFromLegend : getAnnotation({
|
|
19607
19701
|
showAnnotations,
|
|
19608
19702
|
annotationsData
|
|
19609
19703
|
})) ?? [];
|
|
@@ -19641,6 +19735,7 @@ const useChartOptions = ({ chartRef, state, options, dispatch, generatedDatasets
|
|
|
19641
19735
|
const plugins$1 = {
|
|
19642
19736
|
datalabels,
|
|
19643
19737
|
annotationDraggerPlugin: { enabled: state?.enableDragAnnotation },
|
|
19738
|
+
calloutConnectorPlugin: { enableCalloutAnnotation: options?.annotations.enableCalloutAnnotation },
|
|
19644
19739
|
annotation: toAnnotationObject(annotation$1),
|
|
19645
19740
|
zoom: {
|
|
19646
19741
|
pan: panOptions,
|
|
@@ -19860,7 +19955,7 @@ const calculateAnnotationMetricsInValues = (annotation$1) => {
|
|
|
19860
19955
|
centerY = (yMin + yMax) / 2;
|
|
19861
19956
|
width = xMax - xMin;
|
|
19862
19957
|
height = yMax - yMin;
|
|
19863
|
-
} else if (!isNil(xValue) && !isNil(yValue) && type === AnnotationType$1.POINT) {
|
|
19958
|
+
} else if (!isNil(xValue) && !isNil(yValue) && (type === AnnotationType$1.POINT || type === AnnotationType$1.LABEL)) {
|
|
19864
19959
|
centerX = xValue;
|
|
19865
19960
|
centerY = yValue;
|
|
19866
19961
|
width = 0;
|
|
@@ -19898,7 +19993,7 @@ const calculateAnnotationMetricsInValuesInPixels = (annotation$1, scales$1, xSca
|
|
|
19898
19993
|
height = yMinValue - yMaxValue;
|
|
19899
19994
|
centerX = xScale?.getPixelForValue(xCenterValue) ?? -1;
|
|
19900
19995
|
centerY = yScale?.getPixelForValue(yCenterValue) ?? -1;
|
|
19901
|
-
} else if (!isNil(xValue) && !isNil(yValue) && type === AnnotationType$1.POINT) {
|
|
19996
|
+
} else if (!isNil(xValue) && !isNil(yValue) && (type === AnnotationType$1.POINT || type === AnnotationType$1.LABEL)) {
|
|
19902
19997
|
width = 0;
|
|
19903
19998
|
height = 0;
|
|
19904
19999
|
centerX = xScale?.getPixelForValue(xValue) ?? -1;
|
|
@@ -19925,7 +20020,7 @@ const isWithinChartArea = ({ x, y, chartArea, scales: scales$1, metrics, resizab
|
|
|
19925
20020
|
const maxX = xScale?.getValueForPixel(chartArea.right) ?? Number.POSITIVE_INFINITY;
|
|
19926
20021
|
const minY = yScale?.getValueForPixel(chartArea.bottom) ?? Number.NEGATIVE_INFINITY;
|
|
19927
20022
|
const maxY = yScale?.getValueForPixel(chartArea.top) ?? Number.POSITIVE_INFINITY;
|
|
19928
|
-
if (annotationType === AnnotationType$1.POINT) return (x !== void 0 ? x >= minX && x <= maxX : true) && (y !== void 0 ? y >= minY && y <= maxY : true);
|
|
20023
|
+
if (annotationType === AnnotationType$1.POINT || annotationType === AnnotationType$1.LABEL) return (x !== void 0 ? x >= minX && x <= maxX : true) && (y !== void 0 ? y >= minY && y <= maxY : true);
|
|
19929
20024
|
if (annotationType === AnnotationType$1.BOX && metrics.width !== void 0 && metrics.height !== void 0) {
|
|
19930
20025
|
const boxXMin = x !== void 0 ? x - metrics.width / 2 : void 0;
|
|
19931
20026
|
const boxXMax = x !== void 0 ? x + metrics.width / 2 : void 0;
|
|
@@ -19949,7 +20044,7 @@ const updateAnnotationPositionWithinBounds = (axis, newPosition, activeAnnotatio
|
|
|
19949
20044
|
xScaleID,
|
|
19950
20045
|
yScaleID
|
|
19951
20046
|
})) return;
|
|
19952
|
-
if (activeAnnotation.type === AnnotationType$1.POINT) {
|
|
20047
|
+
if (activeAnnotation.type === AnnotationType$1.POINT || activeAnnotation.type === AnnotationType$1.LABEL) {
|
|
19953
20048
|
if (axis === "x") activeAnnotation.xValue = newPosition;
|
|
19954
20049
|
else if (axis === "y") activeAnnotation.yValue = newPosition;
|
|
19955
20050
|
} else if (activeAnnotation.type === AnnotationType$1.BOX && metrics) {
|
|
@@ -20142,6 +20237,86 @@ const annotationDraggerPlugin = {
|
|
|
20142
20237
|
}
|
|
20143
20238
|
}
|
|
20144
20239
|
};
|
|
20240
|
+
var getRadius = (el) => {
|
|
20241
|
+
if (typeof el.options?.radius === "number") return el.options.radius;
|
|
20242
|
+
if (typeof el.width === "number" && typeof el.height === "number") return Math.min(el.width, el.height) / 2;
|
|
20243
|
+
return 0;
|
|
20244
|
+
};
|
|
20245
|
+
const computeConnectorPoints = (fromEl, labelEl, connector) => {
|
|
20246
|
+
const x1c = fromEl?.centerX;
|
|
20247
|
+
const y1c = fromEl?.centerY;
|
|
20248
|
+
const cx$1 = labelEl?.centerX;
|
|
20249
|
+
const cy = labelEl?.centerY;
|
|
20250
|
+
const labelWidth = labelEl?.width ?? 0;
|
|
20251
|
+
const labelHeight = labelEl?.height ?? 0;
|
|
20252
|
+
const ux = cx$1 - x1c;
|
|
20253
|
+
const uy = cy - y1c;
|
|
20254
|
+
const len = Math.sqrt(ux * ux + uy * uy) || 1;
|
|
20255
|
+
const dx = ux / len;
|
|
20256
|
+
const dy = uy / len;
|
|
20257
|
+
const fromRadius = getRadius(fromEl);
|
|
20258
|
+
const startOffset = (connector?.startOffset ?? 4) + fromRadius;
|
|
20259
|
+
const startX = x1c + dx * startOffset;
|
|
20260
|
+
const startY = y1c + dy * startOffset;
|
|
20261
|
+
let endX = cx$1;
|
|
20262
|
+
let endY = cy;
|
|
20263
|
+
if (labelWidth > 0 && labelHeight > 0) {
|
|
20264
|
+
const hw = labelWidth / 2;
|
|
20265
|
+
const hh = labelHeight / 2;
|
|
20266
|
+
const vx = x1c - cx$1;
|
|
20267
|
+
const vy = y1c - cy;
|
|
20268
|
+
const vlen = Math.sqrt(vx * vx + vy * vy) || 1;
|
|
20269
|
+
const vxn = vx / vlen;
|
|
20270
|
+
const vyn = vy / vlen;
|
|
20271
|
+
const tx = Math.abs(vxn) > 1e-6 ? hw / Math.abs(vxn) : Number.POSITIVE_INFINITY;
|
|
20272
|
+
const ty = Math.abs(vyn) > 1e-6 ? hh / Math.abs(vyn) : Number.POSITIVE_INFINITY;
|
|
20273
|
+
const total = Math.min(tx, ty) + (connector.endOffset ?? 4);
|
|
20274
|
+
endX = cx$1 + vxn * total;
|
|
20275
|
+
endY = cy + vyn * total;
|
|
20276
|
+
} else {
|
|
20277
|
+
const endOffset = connector.endOffset ?? 4;
|
|
20278
|
+
endX = cx$1 - dx * endOffset;
|
|
20279
|
+
endY = cy - dy * endOffset;
|
|
20280
|
+
}
|
|
20281
|
+
return {
|
|
20282
|
+
startX,
|
|
20283
|
+
startY,
|
|
20284
|
+
endX,
|
|
20285
|
+
endY
|
|
20286
|
+
};
|
|
20287
|
+
};
|
|
20288
|
+
const calloutConnectorPlugin = {
|
|
20289
|
+
id: "calloutConnector",
|
|
20290
|
+
afterDraw(chart$4) {
|
|
20291
|
+
const { enableCalloutAnnotation } = chart$4?.options?.plugins?.calloutConnectorPlugin || { enableCalloutAnnotation: false };
|
|
20292
|
+
if (!enableCalloutAnnotation) return;
|
|
20293
|
+
const elements$1 = annotation.getAnnotations(chart$4);
|
|
20294
|
+
if (!elements$1 || !elements$1.length) return;
|
|
20295
|
+
const annRoot = chart$4.options.plugins?.annotation;
|
|
20296
|
+
if (!annRoot) return;
|
|
20297
|
+
const raw = annRoot.annotations;
|
|
20298
|
+
if (!raw) return;
|
|
20299
|
+
(Array.isArray(raw) ? raw : Object.values(raw)).forEach((opt) => {
|
|
20300
|
+
const connector = opt?.calloutConnector;
|
|
20301
|
+
if (!connector || !connector.enabled || !opt?.id) return;
|
|
20302
|
+
const labelEl = elements$1.find((el) => el.options && el.options.id === opt.id);
|
|
20303
|
+
const fromEl = elements$1.find((el) => el.options && el.options.id === connector.fromId);
|
|
20304
|
+
if (!labelEl || !fromEl) return;
|
|
20305
|
+
const { startX, startY, endX, endY } = computeConnectorPoints(fromEl, labelEl, connector) ?? {};
|
|
20306
|
+
const ctx = chart$4?.ctx;
|
|
20307
|
+
ctx?.save?.();
|
|
20308
|
+
ctx?.beginPath?.();
|
|
20309
|
+
ctx?.moveTo?.(startX, startY);
|
|
20310
|
+
ctx?.lineTo?.(endX, endY);
|
|
20311
|
+
ctx.lineWidth = connector?.lineWidth ?? 1;
|
|
20312
|
+
ctx.strokeStyle = connector?.strokeStyle ?? "rgba(120,120,120,0.9)";
|
|
20313
|
+
if (connector?.lineDash && connector?.lineDash?.length) ctx?.setLineDash?.(connector.lineDash);
|
|
20314
|
+
ctx.lineCap = "round";
|
|
20315
|
+
ctx?.stroke?.();
|
|
20316
|
+
ctx?.restore?.();
|
|
20317
|
+
});
|
|
20318
|
+
}
|
|
20319
|
+
};
|
|
20145
20320
|
let defaultTranslations = /* @__PURE__ */ function(defaultTranslations$1) {
|
|
20146
20321
|
defaultTranslations$1["label"] = "Label";
|
|
20147
20322
|
defaultTranslations$1["pointsLines"] = "Points & lines";
|
|
@@ -20578,7 +20753,7 @@ var Legend$1 = ({ chartRef, legendConfig }) => {
|
|
|
20578
20753
|
] });
|
|
20579
20754
|
};
|
|
20580
20755
|
var legend_default = Legend$1;
|
|
20581
|
-
Chart.register(LinearScale, PointElement, LineElement, CategoryScale, LogarithmicScale, plugin_legend, plugin_tooltip, plugin_title, index, plugin, plugin$1, annotation, chartAreaTextPlugin, annotationDraggerPlugin, ellipsisAnnotationPlugin);
|
|
20756
|
+
Chart.register(LinearScale, PointElement, LineElement, CategoryScale, LogarithmicScale, plugin_legend, plugin_tooltip, plugin_title, index, plugin, plugin$1, annotation, chartAreaTextPlugin, annotationDraggerPlugin, ellipsisAnnotationPlugin, calloutConnectorPlugin);
|
|
20582
20757
|
var LineChart = (props) => {
|
|
20583
20758
|
setDefaultTheme();
|
|
20584
20759
|
const chartRef = useRef(null);
|