@oliasoft-open-source/charts-library 3.7.5 → 3.8.0-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 +81 -12
- package/dist/index.js.map +1 -1
- package/dist/src/components/line-chart/line-chart.interface.d.ts +24 -1
- package/dist/src/components/line-chart/line-chart.stories.d.ts +212 -170
- package/dist/src/components/line-chart/plugins/custom-point-ellipsis-plugin.d.ts +6 -0
- package/dist/src/components/line-chart/plugins/plugin-constants.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
|
8
8
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
9
9
|
import React, { forwardRef, useRef, useEffect, createContext as createContext$2, memo, useLayoutEffect, useState, useCallback, useMemo, isValidElement, cloneElement, useContext, useReducer } from "react";
|
|
10
10
|
import { produce } from "immer";
|
|
11
|
-
import { round as round$2, displayNumber, isCloseTo, roundByMagnitude, toNum } from "@oliasoft-open-source/units";
|
|
11
|
+
import { round as round$2, displayNumber, isCloseTo, roundByMagnitude, to as to$2, toNum } 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
14
|
import { isEmpty, isArray as isArray$2, some, has, debounce as debounce$3 } from "lodash";
|
|
@@ -24957,6 +24957,7 @@ const TextLabelPosition = {
|
|
|
24957
24957
|
BOTTOM_CENTER: "bottom-center",
|
|
24958
24958
|
BOTTOM_RIGHT: "bottom-right"
|
|
24959
24959
|
};
|
|
24960
|
+
const DEGTORAD = 90;
|
|
24960
24961
|
const defaultAxis = (position) => ({
|
|
24961
24962
|
label: "",
|
|
24962
24963
|
position,
|
|
@@ -25008,17 +25009,24 @@ const defaultGraph$2 = (graph) => ({
|
|
|
25008
25009
|
showMinorGridlines: (graph == null ? void 0 : graph.showMinorGridlines) ?? false
|
|
25009
25010
|
});
|
|
25010
25011
|
const defaultAnnotations$1 = (annotations) => {
|
|
25011
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
|
|
25012
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2;
|
|
25012
25013
|
return {
|
|
25014
|
+
pointEllipsisAnnotation: {
|
|
25015
|
+
radiusX: ((_a2 = annotations == null ? void 0 : annotations.pointEllipsisAnnotation) == null ? void 0 : _a2.radiusX) ?? 10,
|
|
25016
|
+
radiusY: ((_b2 = annotations == null ? void 0 : annotations.pointEllipsisAnnotation) == null ? void 0 : _b2.radiusY) ?? 5,
|
|
25017
|
+
color: (_c2 = annotations == null ? void 0 : annotations.pointEllipsisAnnotation) == null ? void 0 : _c2.color,
|
|
25018
|
+
rotation: ((_d2 = annotations == null ? void 0 : annotations.pointEllipsisAnnotation) == null ? void 0 : _d2.rotation) ?? DEGTORAD,
|
|
25019
|
+
lineWidth: ((_e2 = annotations == null ? void 0 : annotations.pointEllipsisAnnotation) == null ? void 0 : _e2.lineWidth) ?? 1
|
|
25020
|
+
},
|
|
25013
25021
|
labelAnnotation: {
|
|
25014
|
-
showLabel: ((
|
|
25015
|
-
text: ((
|
|
25016
|
-
position: ((
|
|
25017
|
-
fontSize: ((
|
|
25018
|
-
xOffset: ((
|
|
25019
|
-
yOffset: ((
|
|
25020
|
-
maxWidth: ((
|
|
25021
|
-
lineHeight: ((
|
|
25022
|
+
showLabel: ((_f2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _f2.showLabel) ?? false,
|
|
25023
|
+
text: ((_g2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _g2.text) ?? "",
|
|
25024
|
+
position: ((_h2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _h2.position) ?? TextLabelPosition.BOTTOM_RIGHT,
|
|
25025
|
+
fontSize: ((_i2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _i2.fontSize) ?? 12,
|
|
25026
|
+
xOffset: ((_j2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _j2.xOffset) ?? 5,
|
|
25027
|
+
yOffset: ((_k2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _k2.yOffset) ?? 5,
|
|
25028
|
+
maxWidth: ((_l2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _l2.maxWidth) ?? 300,
|
|
25029
|
+
lineHeight: ((_m2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _m2.lineHeight) ?? 12
|
|
25022
25030
|
},
|
|
25023
25031
|
showAnnotations: (annotations == null ? void 0 : annotations.showAnnotations) ?? false,
|
|
25024
25032
|
controlAnnotation: (annotations == null ? void 0 : annotations.controlAnnotation) ?? false,
|
|
@@ -25184,6 +25192,7 @@ const generateLineChartDatasets = (datasets, state, options, { label }) => {
|
|
|
25184
25192
|
pointRadius,
|
|
25185
25193
|
pointHoverRadius: hoverRadius,
|
|
25186
25194
|
pointHitRadius: line.pointHitRadius ?? hoverRadius,
|
|
25195
|
+
showEllipsesAnnotation: (line == null ? void 0 : line.showEllipsesAnnotation) ?? false,
|
|
25187
25196
|
...hasCustomOpt ? { hasCustomOpt } : {}
|
|
25188
25197
|
};
|
|
25189
25198
|
});
|
|
@@ -25791,6 +25800,63 @@ const useChartOptions = ({
|
|
|
25791
25800
|
[state, options, chartRef]
|
|
25792
25801
|
);
|
|
25793
25802
|
};
|
|
25803
|
+
const customPointEllipsisPlugin = (options) => {
|
|
25804
|
+
var _a2;
|
|
25805
|
+
const { radiusX, radiusY, rotation, lineWidth, color: color2 } = ((_a2 = options == null ? void 0 : options.annotations) == null ? void 0 : _a2.pointEllipsisAnnotation) ?? {};
|
|
25806
|
+
return {
|
|
25807
|
+
id: "ellipseAnnotation",
|
|
25808
|
+
afterDatasetsDraw: (chart2) => {
|
|
25809
|
+
var _a3, _b2, _c2;
|
|
25810
|
+
const { ctx, chartArea } = chart2;
|
|
25811
|
+
if (isEmpty((_a3 = options == null ? void 0 : options.annotations) == null ? void 0 : _a3.pointEllipsisAnnotation))
|
|
25812
|
+
return;
|
|
25813
|
+
(_c2 = (_b2 = chart2 == null ? void 0 : chart2.data) == null ? void 0 : _b2.datasets) == null ? void 0 : _c2.forEach(
|
|
25814
|
+
(dataset, datasetIndex) => {
|
|
25815
|
+
const meta = chart2.getDatasetMeta(datasetIndex);
|
|
25816
|
+
if (!meta.hidden && dataset.showEllipsesAnnotation) {
|
|
25817
|
+
meta.data.forEach((element, index2) => {
|
|
25818
|
+
var _a4, _b3;
|
|
25819
|
+
const pointElement = element;
|
|
25820
|
+
const { x: x2, y: y2 } = ((_a4 = pointElement.getCenterPoint) == null ? void 0 : _a4.call(pointElement)) || {
|
|
25821
|
+
x: 0,
|
|
25822
|
+
y: 0
|
|
25823
|
+
};
|
|
25824
|
+
if (x2 < chartArea.left || x2 > chartArea.right || y2 < chartArea.top || y2 > chartArea.bottom) {
|
|
25825
|
+
return;
|
|
25826
|
+
}
|
|
25827
|
+
const { ellipseOptions } = (_b3 = dataset == null ? void 0 : dataset.data) == null ? void 0 : _b3[index2];
|
|
25828
|
+
const {
|
|
25829
|
+
radiusX: ellipseRadiusX = radiusX,
|
|
25830
|
+
radiusY: ellipseRadiusY = radiusY,
|
|
25831
|
+
rotation: ellipseRotation = rotation,
|
|
25832
|
+
lineWidth: ellipseLineWidth = lineWidth,
|
|
25833
|
+
color: ellipseColor = color2
|
|
25834
|
+
} = ellipseOptions ?? {};
|
|
25835
|
+
const customRadiusX = Number(ellipseRadiusX);
|
|
25836
|
+
const customRadiusY = Number(ellipseRadiusY);
|
|
25837
|
+
const customRotation = to$2(Number(ellipseRotation), "deg", "rad");
|
|
25838
|
+
ctx.save();
|
|
25839
|
+
ctx.strokeStyle = ellipseColor ?? color2 ?? dataset.borderColor ?? COLORS[datasetIndex];
|
|
25840
|
+
ctx.lineWidth = ellipseLineWidth ?? lineWidth ?? 1;
|
|
25841
|
+
ctx.beginPath();
|
|
25842
|
+
ctx.ellipse(
|
|
25843
|
+
x2,
|
|
25844
|
+
y2,
|
|
25845
|
+
customRadiusX,
|
|
25846
|
+
customRadiusY,
|
|
25847
|
+
customRotation,
|
|
25848
|
+
0,
|
|
25849
|
+
2 * Math.PI
|
|
25850
|
+
);
|
|
25851
|
+
ctx.stroke();
|
|
25852
|
+
ctx.restore();
|
|
25853
|
+
});
|
|
25854
|
+
}
|
|
25855
|
+
}
|
|
25856
|
+
);
|
|
25857
|
+
}
|
|
25858
|
+
};
|
|
25859
|
+
};
|
|
25794
25860
|
const useChartPlugins = ({ options, resetZoom: resetZoom2 }) => {
|
|
25795
25861
|
const { graph, legend: legend2 } = options;
|
|
25796
25862
|
const debouncedResetZoom = useCallback(
|
|
@@ -25809,13 +25875,15 @@ const useChartPlugins = ({ options, resetZoom: resetZoom2 }) => {
|
|
|
25809
25875
|
},
|
|
25810
25876
|
[debouncedResetZoom]
|
|
25811
25877
|
);
|
|
25878
|
+
const ellipsePlugin = customPointEllipsisPlugin(options);
|
|
25812
25879
|
return useMemo(() => {
|
|
25813
25880
|
return [
|
|
25814
25881
|
...getPlugins(graph, legend2),
|
|
25815
25882
|
{
|
|
25816
25883
|
id: "customEventCatcher",
|
|
25817
25884
|
beforeEvent: handleDoubleClick
|
|
25818
|
-
}
|
|
25885
|
+
},
|
|
25886
|
+
ellipsePlugin
|
|
25819
25887
|
];
|
|
25820
25888
|
}, [handleDoubleClick]);
|
|
25821
25889
|
};
|
|
@@ -26151,7 +26219,8 @@ Chart$2.register(
|
|
|
26151
26219
|
plugin$1,
|
|
26152
26220
|
plugin,
|
|
26153
26221
|
annotation,
|
|
26154
|
-
chartAreaTextPlugin
|
|
26222
|
+
chartAreaTextPlugin,
|
|
26223
|
+
customPointEllipsisPlugin()
|
|
26155
26224
|
);
|
|
26156
26225
|
const LineChart = (props) => {
|
|
26157
26226
|
var _a2, _b2;
|