@oliasoft-open-source/charts-library 3.2.0 → 3.2.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 +43 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import React, { forwardRef, useRef, useEffect, useMemo, useCallback, useState, u
|
|
|
10
10
|
import { round as round$2, toNum, displayNumber, isCloseTo } from "@oliasoft-open-source/units";
|
|
11
11
|
import cx from "classnames";
|
|
12
12
|
import { produce } from "immer";
|
|
13
|
-
import { Icon, Tooltip as Tooltip$2, Button, Flex, Text, Menu, Popover, Field, InputGroup, NumberInput, InputGroupAddon, Select, ButtonGroup, Spacer } from "@oliasoft-open-source/react-ui-library";
|
|
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 PropTypes from "prop-types";
|
|
15
15
|
import { debounce as debounce$3, isEqual } from "lodash";
|
|
16
16
|
/*!
|
|
@@ -31208,7 +31208,7 @@ const isGreaterThanMin = (value, min) => {
|
|
|
31208
31208
|
return value === void 0 || min === void 0 || Number(value) > Number(min);
|
|
31209
31209
|
};
|
|
31210
31210
|
const generateAxisId = (axisType, index2 = 0, hasMultiAxes = false) => {
|
|
31211
|
-
const i2 = hasMultiAxes ? index2 + 1 : "";
|
|
31211
|
+
const i2 = hasMultiAxes && index2 !== 0 ? index2 + 1 : "";
|
|
31212
31212
|
return `${axisType}${i2}`;
|
|
31213
31213
|
};
|
|
31214
31214
|
const getAxisTypeFromKey = (string) => {
|
|
@@ -32306,6 +32306,12 @@ AxesOptionsPopover.propTypes = {
|
|
|
32306
32306
|
options: PropTypes.arrayOf(PropTypes.string)
|
|
32307
32307
|
})
|
|
32308
32308
|
};
|
|
32309
|
+
const ControlsPortal = ({ children, controlsPortalId }) => {
|
|
32310
|
+
if (controlsPortalId && document.getElementById(controlsPortalId)) {
|
|
32311
|
+
return /* @__PURE__ */ jsx(Portal, { id: controlsPortalId, children });
|
|
32312
|
+
}
|
|
32313
|
+
return children;
|
|
32314
|
+
};
|
|
32309
32315
|
const Controls = ({
|
|
32310
32316
|
props: { headerComponent, subheaderComponent, table: table2 },
|
|
32311
32317
|
chartRef,
|
|
@@ -32313,7 +32319,8 @@ const Controls = ({
|
|
|
32313
32319
|
options,
|
|
32314
32320
|
dispatch,
|
|
32315
32321
|
generatedDatasets,
|
|
32316
|
-
translations
|
|
32322
|
+
translations,
|
|
32323
|
+
controlsPortalId
|
|
32317
32324
|
}) => {
|
|
32318
32325
|
const {
|
|
32319
32326
|
enableDragPoints,
|
|
@@ -32353,7 +32360,7 @@ const Controls = ({
|
|
|
32353
32360
|
/* @__PURE__ */ jsxs("div", { className: styles$2.controls, children: [
|
|
32354
32361
|
!!options.title && /* @__PURE__ */ jsx(Text, { bold: true, children: options.title }),
|
|
32355
32362
|
headerComponent,
|
|
32356
|
-
/* @__PURE__ */ jsxs("div", { className: styles$2.buttons, children: [
|
|
32363
|
+
/* @__PURE__ */ jsx(ControlsPortal, { controlsPortalId, children: /* @__PURE__ */ jsxs("div", { className: styles$2.buttons, children: [
|
|
32357
32364
|
!showTable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
32358
32365
|
/* @__PURE__ */ jsx(
|
|
32359
32366
|
AxesOptions,
|
|
@@ -32385,17 +32392,24 @@ const Controls = ({
|
|
|
32385
32392
|
translations
|
|
32386
32393
|
}
|
|
32387
32394
|
),
|
|
32388
|
-
/* @__PURE__ */ jsx(
|
|
32389
|
-
|
|
32395
|
+
/* @__PURE__ */ jsx(
|
|
32396
|
+
Tooltip$2,
|
|
32390
32397
|
{
|
|
32391
|
-
|
|
32392
|
-
|
|
32393
|
-
|
|
32394
|
-
|
|
32395
|
-
|
|
32396
|
-
|
|
32398
|
+
text: translations.downloadAsPNG,
|
|
32399
|
+
placement: "bottom-end",
|
|
32400
|
+
children: /* @__PURE__ */ jsx(
|
|
32401
|
+
Button,
|
|
32402
|
+
{
|
|
32403
|
+
small: true,
|
|
32404
|
+
basic: true,
|
|
32405
|
+
colored: "muted",
|
|
32406
|
+
round: true,
|
|
32407
|
+
icon: /* @__PURE__ */ jsx(RiFileDownloadLine, {}),
|
|
32408
|
+
onClick: handleDownload
|
|
32409
|
+
}
|
|
32410
|
+
)
|
|
32397
32411
|
}
|
|
32398
|
-
)
|
|
32412
|
+
),
|
|
32399
32413
|
/* @__PURE__ */ jsx(
|
|
32400
32414
|
DragOptions,
|
|
32401
32415
|
{
|
|
@@ -32429,7 +32443,7 @@ const Controls = ({
|
|
|
32429
32443
|
)
|
|
32430
32444
|
}
|
|
32431
32445
|
) : null
|
|
32432
|
-
] })
|
|
32446
|
+
] }) })
|
|
32433
32447
|
] }),
|
|
32434
32448
|
subheaderComponent
|
|
32435
32449
|
] });
|
|
@@ -32438,7 +32452,8 @@ Controls.defaultProps = {
|
|
|
32438
32452
|
props: {
|
|
32439
32453
|
headerComponent: null,
|
|
32440
32454
|
subheaderComponent: null,
|
|
32441
|
-
table: null
|
|
32455
|
+
table: null,
|
|
32456
|
+
controlsPortalId: null
|
|
32442
32457
|
},
|
|
32443
32458
|
state: {
|
|
32444
32459
|
initialAxesRanges: []
|
|
@@ -32449,7 +32464,8 @@ Controls.propTypes = {
|
|
|
32449
32464
|
props: PropTypes.shape({
|
|
32450
32465
|
headerComponent: PropTypes.node,
|
|
32451
32466
|
subheaderComponent: PropTypes.node,
|
|
32452
|
-
table: PropTypes.node
|
|
32467
|
+
table: PropTypes.node,
|
|
32468
|
+
controlsPortalId: PropTypes.string
|
|
32453
32469
|
}),
|
|
32454
32470
|
chartRef: PropTypes.object.isRequired,
|
|
32455
32471
|
state: PropTypes.shape({
|
|
@@ -32485,6 +32501,7 @@ const LineChartPropTypes = {
|
|
|
32485
32501
|
table: PropTypes.node,
|
|
32486
32502
|
chart: PropTypes.shape({
|
|
32487
32503
|
persistenceId: PropTypes.string,
|
|
32504
|
+
controlsPortalId: PropTypes.string,
|
|
32488
32505
|
testId: PropTypes.string,
|
|
32489
32506
|
data: PropTypes.object.isRequired,
|
|
32490
32507
|
options: PropTypes.shape({
|
|
@@ -32648,6 +32665,7 @@ const getDefaultProps$2 = (props) => {
|
|
|
32648
32665
|
props.chart.options.dragData = props.chart.options.dragData || {};
|
|
32649
32666
|
const chart2 = {
|
|
32650
32667
|
persistenceId: props.chart.persistenceId ?? "",
|
|
32668
|
+
controlsPortalId: props.chart.controlsPortalId ?? null,
|
|
32651
32669
|
testId: props.chart.testId ?? null,
|
|
32652
32670
|
data: props.chart.data,
|
|
32653
32671
|
options: {
|
|
@@ -33167,11 +33185,7 @@ const generateAnnotations = (options, state) => {
|
|
|
33167
33185
|
if (!((_a2 = state == null ? void 0 : state.showAnnotationLineIndex) == null ? void 0 : _a2.includes(i2))) {
|
|
33168
33186
|
return { ...acc };
|
|
33169
33187
|
}
|
|
33170
|
-
const
|
|
33171
|
-
var _a3;
|
|
33172
|
-
const axisType = curr.annotationAxis;
|
|
33173
|
-
return ((_a3 = options.axes[axisType]) == null ? void 0 : _a3.length) > 1 ? `${axisType}1` : axisType;
|
|
33174
|
-
};
|
|
33188
|
+
const scaleID = (curr == null ? void 0 : curr.annotationAxis) ?? void 0;
|
|
33175
33189
|
const color2 = (curr == null ? void 0 : curr.color) || COLORS[i2];
|
|
33176
33190
|
const type = (curr == null ? void 0 : curr.type) || "line";
|
|
33177
33191
|
const adjustScaleRange2 = curr == null ? void 0 : curr.adjustScaleRange;
|
|
@@ -33201,7 +33215,7 @@ const generateAnnotations = (options, state) => {
|
|
|
33201
33215
|
const annotation2 = {
|
|
33202
33216
|
...curr,
|
|
33203
33217
|
id: `${curr == null ? void 0 : curr.label}-${curr == null ? void 0 : curr.value}-${i2}`,
|
|
33204
|
-
scaleID
|
|
33218
|
+
scaleID,
|
|
33205
33219
|
label,
|
|
33206
33220
|
backgroundColor: color2,
|
|
33207
33221
|
borderColor,
|
|
@@ -33780,7 +33794,8 @@ const LineChart = (props) => {
|
|
|
33780
33794
|
data: { datasets },
|
|
33781
33795
|
options,
|
|
33782
33796
|
testId,
|
|
33783
|
-
persistenceId
|
|
33797
|
+
persistenceId,
|
|
33798
|
+
controlsPortalId
|
|
33784
33799
|
} = chart2;
|
|
33785
33800
|
const { annotations, axes, chartStyling, graph } = options;
|
|
33786
33801
|
const [state, dispatch] = useReducer(
|
|
@@ -33839,7 +33854,8 @@ const LineChart = (props) => {
|
|
|
33839
33854
|
options,
|
|
33840
33855
|
dispatch,
|
|
33841
33856
|
generatedDatasets,
|
|
33842
|
-
translations
|
|
33857
|
+
translations,
|
|
33858
|
+
controlsPortalId
|
|
33843
33859
|
}
|
|
33844
33860
|
),
|
|
33845
33861
|
table2 && state.showTable ? /* @__PURE__ */ jsx("div", { className: styles$3.table, children: table2 }) : /* @__PURE__ */ jsx("div", { className: styles$3.canvas, children: /* @__PURE__ */ jsx(
|
|
@@ -34608,8 +34624,9 @@ const getBarChartAxes = (chart2, axisType) => {
|
|
|
34608
34624
|
const color2 = curr.color || COLORS[i2] || generateRandomColor$1(COLORS);
|
|
34609
34625
|
axisData.color = color2;
|
|
34610
34626
|
axisData.position = curr.position || getAxisPosition(axisType, i2);
|
|
34611
|
-
const axis = getBarChartAxis(chart2, axisType, axisData
|
|
34612
|
-
|
|
34627
|
+
const axis = getBarChartAxis(chart2, axisType, axisData);
|
|
34628
|
+
const axisId = i2 === 0 ? axisType : `${axisType}${i2 + 1}`;
|
|
34629
|
+
return { ...acc, [axisId]: axis };
|
|
34613
34630
|
}, {});
|
|
34614
34631
|
return axes;
|
|
34615
34632
|
};
|