@oliasoft-open-source/charts-library 4.7.0-beta-7 → 4.7.0-beta-9
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 +58 -19
- package/dist/index.js.map +1 -1
- package/dist/src/components/bar-chart/bar-chart.stories.d.ts +89 -89
- package/dist/src/components/common/common.interface.d.ts +1 -0
- package/dist/src/components/common/helpers/chart-consts.d.ts +1 -0
- package/dist/src/components/common/helpers/chart-utils.d.ts +1 -1
- package/dist/src/components/common/helpers/get-chart-annotation.d.ts +1 -0
- package/dist/src/components/common/plugins/annotation-dragger-plugin/helpers.d.ts +1 -0
- package/dist/src/components/line-chart/line-chart.interface.d.ts +1 -0
- package/dist/src/components/line-chart/line-chart.stories.d.ts +118 -104
- package/dist/src/components/line-chart/line-chart.test-case.stories.d.ts +4 -4
- package/dist/src/components/pie-chart/pie-chart.stories.d.ts +24 -24
- package/dist/src/components/scatter-chart/scatter-chart.stories.d.ts +26 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22677,6 +22677,7 @@ const chartMinorGridlinesPlugin = {
|
|
|
22677
22677
|
}
|
|
22678
22678
|
};
|
|
22679
22679
|
const BORDER_WIDTH = {
|
|
22680
|
+
ZERO: 0,
|
|
22680
22681
|
INITIAL: 2,
|
|
22681
22682
|
HOVERED: 6,
|
|
22682
22683
|
POINT_HOVERED: 8
|
|
@@ -22936,10 +22937,15 @@ const initialState = ({ options, persistenceId }) => {
|
|
|
22936
22937
|
const {
|
|
22937
22938
|
additionalAxesOptions: { range: customAxesRange = {} },
|
|
22938
22939
|
axes,
|
|
22939
|
-
chartOptions: {
|
|
22940
|
+
chartOptions: {
|
|
22941
|
+
enableZoom,
|
|
22942
|
+
enablePan,
|
|
22943
|
+
showPoints,
|
|
22944
|
+
showLine,
|
|
22945
|
+
enableDragAnnotation
|
|
22946
|
+
},
|
|
22940
22947
|
legend: { display },
|
|
22941
|
-
dragData
|
|
22942
|
-
annotations: { enableDragAnnotation }
|
|
22948
|
+
dragData
|
|
22943
22949
|
} = options;
|
|
22944
22950
|
const getStateAxesByType = (axisType, customAxesRange2) => {
|
|
22945
22951
|
var _a2, _b2, _c2, _d2, _e2;
|
|
@@ -22990,7 +22996,7 @@ const initialState = ({ options, persistenceId }) => {
|
|
|
22990
22996
|
enableDragAnnotation: enableDragAnnotationStorage
|
|
22991
22997
|
} = getChartStateFromStorage(persistenceId) || {};
|
|
22992
22998
|
return {
|
|
22993
|
-
zoomEnabled: zoomEnabled ?? enableZoom,
|
|
22999
|
+
zoomEnabled: enableDragAnnotation ?? enableDragAnnotationStorage ? false : zoomEnabled ?? enableZoom,
|
|
22994
23000
|
panEnabled: panEnabled ?? enablePan,
|
|
22995
23001
|
pointsEnabled: pointsEnabled ?? showPoints,
|
|
22996
23002
|
lineEnabled: lineEnabled ?? showLine,
|
|
@@ -22998,7 +23004,7 @@ const initialState = ({ options, persistenceId }) => {
|
|
|
22998
23004
|
axes: stateAxes,
|
|
22999
23005
|
showTable: false,
|
|
23000
23006
|
enableDragPoints: (dragData == null ? void 0 : dragData.enableDragData) && enableDragPoints,
|
|
23001
|
-
enableDragAnnotation: enableDragAnnotation
|
|
23007
|
+
enableDragAnnotation: enableDragAnnotation ?? enableDragAnnotationStorage,
|
|
23002
23008
|
initialAxesRanges: []
|
|
23003
23009
|
};
|
|
23004
23010
|
};
|
|
@@ -24981,9 +24987,10 @@ const defaultLegend$3 = (legend2) => ({
|
|
|
24981
24987
|
});
|
|
24982
24988
|
const defaultChartOptions$3 = (options) => ({
|
|
24983
24989
|
showPoints: (options == null ? void 0 : options.showPoints) ?? true,
|
|
24990
|
+
showLine: (options == null ? void 0 : options.showLine) ?? true,
|
|
24984
24991
|
enableZoom: (options == null ? void 0 : options.enableZoom) ?? true,
|
|
24985
24992
|
enablePan: (options == null ? void 0 : options.enablePan) ?? false,
|
|
24986
|
-
|
|
24993
|
+
enableDragAnnotation: (options == null ? void 0 : options.enableDragAnnotation) ?? false,
|
|
24987
24994
|
closeOnOutsideClick: (options == null ? void 0 : options.closeOnOutsideClick) ?? false
|
|
24988
24995
|
});
|
|
24989
24996
|
const defaultInteractions$3 = (interactions) => ({
|
|
@@ -25800,7 +25807,8 @@ const generateAnnotations = (annotationsData) => {
|
|
|
25800
25807
|
onDrag,
|
|
25801
25808
|
onDragEnd,
|
|
25802
25809
|
pointStyle: (ann == null ? void 0 : ann.pointStyle) ?? PointStyle.Circle,
|
|
25803
|
-
resizable: (ann == null ? void 0 : ann.resizable) ??
|
|
25810
|
+
resizable: (ann == null ? void 0 : ann.resizable) ?? true,
|
|
25811
|
+
displayDragCoordinates: (ann == null ? void 0 : ann.displayDragCoordinates) ?? true
|
|
25804
25812
|
};
|
|
25805
25813
|
});
|
|
25806
25814
|
};
|
|
@@ -26483,6 +26491,14 @@ const updateAnnotationPositionWithinBounds = (axis, newPosition, activeAnnotatio
|
|
|
26483
26491
|
}
|
|
26484
26492
|
}
|
|
26485
26493
|
};
|
|
26494
|
+
const setAnnotationBorderWidth = (chart2, annotationId, borderWidth) => {
|
|
26495
|
+
var _a2, _b2, _c2;
|
|
26496
|
+
if (!annotationId) return;
|
|
26497
|
+
const annotations = (_c2 = (_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.plugins) == null ? void 0 : _b2.annotation) == null ? void 0 : _c2.annotations;
|
|
26498
|
+
if (annotations && annotationId && annotations[annotationId]) {
|
|
26499
|
+
annotations[annotationId].borderWidth = borderWidth;
|
|
26500
|
+
}
|
|
26501
|
+
};
|
|
26486
26502
|
const handleAnnotationMouseDown = (event, canvas2, scales, annotations, setDraggingState, hoveredAnnotationId) => {
|
|
26487
26503
|
const { x: x2, y: y2 } = getMousePositionInCoordinates(event, canvas2, scales);
|
|
26488
26504
|
const annotation2 = hoveredAnnotationId ? annotations == null ? void 0 : annotations[hoveredAnnotationId] : null;
|
|
@@ -26501,6 +26517,8 @@ const handleAnnotationMouseDown = (event, canvas2, scales, annotations, setDragg
|
|
|
26501
26517
|
const handleAnnotationMouseMove = (event, canvas2, scales, isDragging2, activeAnnotation, dragStartX, dragStartY, chart2) => {
|
|
26502
26518
|
if (isDragging2 && activeAnnotation) {
|
|
26503
26519
|
canvas2.style.cursor = CursorStyle.Move;
|
|
26520
|
+
const annotationId = activeAnnotation == null ? void 0 : activeAnnotation.id;
|
|
26521
|
+
setAnnotationBorderWidth(chart2, annotationId, BORDER_WIDTH.HOVERED);
|
|
26504
26522
|
const dragAxis = (activeAnnotation == null ? void 0 : activeAnnotation.dragAxis) ?? DragAxis.Both;
|
|
26505
26523
|
const { x: x2, y: y2 } = getMousePositionInCoordinates(event, canvas2, scales);
|
|
26506
26524
|
const metrics = calculateAnnotationMetricsInValues(activeAnnotation);
|
|
@@ -26539,24 +26557,28 @@ const handleAnnotationMouseMove = (event, canvas2, scales, isDragging2, activeAn
|
|
|
26539
26557
|
chart2.draw();
|
|
26540
26558
|
ctx.font = DEFAULT_FONT_FAMILY;
|
|
26541
26559
|
ctx.fillStyle = "black";
|
|
26542
|
-
|
|
26543
|
-
|
|
26544
|
-
|
|
26545
|
-
|
|
26546
|
-
|
|
26547
|
-
labelY
|
|
26548
|
-
|
|
26549
|
-
|
|
26550
|
-
labelY
|
|
26560
|
+
if (activeAnnotation == null ? void 0 : activeAnnotation.displayDragCoordinates) {
|
|
26561
|
+
let labelX = xValue - 45;
|
|
26562
|
+
let labelY = yValue - 20;
|
|
26563
|
+
const labelText = `X: ${round$2(centerX, 2)}, Y: ${round$2(centerY, 2)}`;
|
|
26564
|
+
const labelHeight = 14;
|
|
26565
|
+
if (labelY - labelHeight < 0) {
|
|
26566
|
+
labelY = yValue + labelHeight + 15;
|
|
26567
|
+
}
|
|
26568
|
+
if (labelY > height) {
|
|
26569
|
+
labelY = height - 7;
|
|
26570
|
+
}
|
|
26571
|
+
ctx.fillText(labelText, labelX, labelY);
|
|
26572
|
+
ctx.restore();
|
|
26551
26573
|
}
|
|
26552
|
-
ctx.fillText(labelText, labelX, labelY);
|
|
26553
|
-
ctx.restore();
|
|
26554
26574
|
}
|
|
26555
26575
|
}
|
|
26556
26576
|
};
|
|
26557
26577
|
const handleAnnotationMouseUp = (isDragging2, activeAnnotation, chart2, setDraggingState) => {
|
|
26558
26578
|
if (isDragging2) {
|
|
26559
26579
|
if (activeAnnotation) {
|
|
26580
|
+
const annotationId = activeAnnotation == null ? void 0 : activeAnnotation.id;
|
|
26581
|
+
setAnnotationBorderWidth(chart2, annotationId, BORDER_WIDTH.ZERO);
|
|
26560
26582
|
const { centerX = -1, centerY = -1 } = calculateAnnotationMetricsInValues(activeAnnotation) ?? {};
|
|
26561
26583
|
if (activeAnnotation == null ? void 0 : activeAnnotation.onDragEnd) {
|
|
26562
26584
|
activeAnnotation.onDragEnd(
|
|
@@ -26633,7 +26655,7 @@ const annotationDraggerPlugin = {
|
|
|
26633
26655
|
}
|
|
26634
26656
|
},
|
|
26635
26657
|
afterUpdate(chart2) {
|
|
26636
|
-
var _a2, _b2, _c2, _d2;
|
|
26658
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
|
|
26637
26659
|
const { canvas: canvas2, scales, hoveredAnnotationId } = chart2;
|
|
26638
26660
|
const pluginOptions = ((_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.plugins) == null ? void 0 : _b2.annotationDraggerPlugin) || {
|
|
26639
26661
|
enabled: false
|
|
@@ -26641,6 +26663,23 @@ const annotationDraggerPlugin = {
|
|
|
26641
26663
|
const typedScales = { x: scales.x, y: scales.y };
|
|
26642
26664
|
let annotations = ((_d2 = (_c2 = chart2.options.plugins) == null ? void 0 : _c2.annotation) == null ? void 0 : _d2.annotations) ?? {};
|
|
26643
26665
|
if (!chart2 && !annotations) return;
|
|
26666
|
+
if (pluginOptions.enabled) {
|
|
26667
|
+
if ((_f2 = (_e2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _e2.plugins) == null ? void 0 : _f2.tooltip) {
|
|
26668
|
+
chart2.options.plugins.tooltip.enabled = false;
|
|
26669
|
+
}
|
|
26670
|
+
chart2.options.hover = {
|
|
26671
|
+
mode: void 0,
|
|
26672
|
+
intersect: false
|
|
26673
|
+
};
|
|
26674
|
+
} else {
|
|
26675
|
+
if ((_h2 = (_g2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _g2.plugins) == null ? void 0 : _h2.tooltip) {
|
|
26676
|
+
chart2.options.plugins.tooltip.enabled = true;
|
|
26677
|
+
}
|
|
26678
|
+
chart2.options.hover = {
|
|
26679
|
+
mode: ChartHoverMode.Nearest,
|
|
26680
|
+
intersect: true
|
|
26681
|
+
};
|
|
26682
|
+
}
|
|
26644
26683
|
let isDragging2 = false;
|
|
26645
26684
|
let dragStartX, dragStartY;
|
|
26646
26685
|
let activeAnnotation = null;
|