@oliasoft-open-source/charts-library 3.6.3 → 3.6.4
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 -16
- package/dist/index.js.map +1 -1
- package/dist/src/components/line-chart/controls/line-options.d.ts +2 -1
- package/dist/src/components/line-chart/line-chart.stories.d.ts +32 -0
- package/dist/src/components/line-chart/utils/check-custom-option/check-custom-option.d.ts +15 -0
- package/dist/src/components/line-chart/utils/check-custom-option/check-custom-option.test.d.ts +1 -0
- package/dist/src/components/line-chart/utils/enums.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { round as round$2, displayNumber, isCloseTo, roundByMagnitude, toNum } f
|
|
|
11
11
|
import cx from "classnames";
|
|
12
12
|
import { produce } from "immer";
|
|
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
|
-
import { debounce as debounce$3, isEqual } from "lodash";
|
|
14
|
+
import { isEmpty, isArray as isArray$2, some, has, debounce as debounce$3, isEqual } from "lodash";
|
|
15
15
|
import { roundNumberToPrecision } from "@oliasoft-open-source/units/dist/rounding/rounding";
|
|
16
16
|
/*!
|
|
17
17
|
* @kurkle/color v0.3.2
|
|
@@ -22877,7 +22877,8 @@ const LineOptions = ({
|
|
|
22877
22877
|
onToggleLine,
|
|
22878
22878
|
onTogglePoints,
|
|
22879
22879
|
pointsEnabled,
|
|
22880
|
-
translations
|
|
22880
|
+
translations,
|
|
22881
|
+
hasCustomOpt
|
|
22881
22882
|
}) => {
|
|
22882
22883
|
const options = [
|
|
22883
22884
|
{
|
|
@@ -22907,17 +22908,26 @@ const LineOptions = ({
|
|
|
22907
22908
|
}
|
|
22908
22909
|
];
|
|
22909
22910
|
const selectedOption = options.find((option) => option.selected);
|
|
22910
|
-
return /* @__PURE__ */ jsx(
|
|
22911
|
-
|
|
22911
|
+
return /* @__PURE__ */ jsx(
|
|
22912
|
+
Tooltip$2,
|
|
22912
22913
|
{
|
|
22913
|
-
|
|
22914
|
-
|
|
22915
|
-
|
|
22916
|
-
|
|
22917
|
-
|
|
22918
|
-
|
|
22914
|
+
text: selectedOption == null ? void 0 : selectedOption.label,
|
|
22915
|
+
placement: "bottom",
|
|
22916
|
+
enabled: !hasCustomOpt,
|
|
22917
|
+
children: /* @__PURE__ */ jsx(
|
|
22918
|
+
Button,
|
|
22919
|
+
{
|
|
22920
|
+
small: true,
|
|
22921
|
+
basic: true,
|
|
22922
|
+
colored: "muted",
|
|
22923
|
+
round: true,
|
|
22924
|
+
icon: selectedOption == null ? void 0 : selectedOption.icon,
|
|
22925
|
+
onClick: selectedOption == null ? void 0 : selectedOption.onClick,
|
|
22926
|
+
disabled: hasCustomOpt
|
|
22927
|
+
}
|
|
22928
|
+
)
|
|
22919
22929
|
}
|
|
22920
|
-
)
|
|
22930
|
+
);
|
|
22921
22931
|
};
|
|
22922
22932
|
function TbHandStop(props) {
|
|
22923
22933
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "fill": "none", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "stroke": "none", "d": "M0 0h24v24H0z", "fill": "none" } }, { "tag": "path", "attr": { "d": "M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5" } }, { "tag": "path", "attr": { "d": "M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5" } }, { "tag": "path", "attr": { "d": "M14 5.5a1.5 1.5 0 0 1 3 0v6.5" } }, { "tag": "path", "attr": { "d": "M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47" } }] })(props);
|
|
@@ -24489,6 +24499,27 @@ const ControlsPortal = ({
|
|
|
24489
24499
|
}
|
|
24490
24500
|
return children;
|
|
24491
24501
|
};
|
|
24502
|
+
const checkCustomOption = (data, customOptions) => {
|
|
24503
|
+
if (isEmpty(data) || isEmpty(customOptions))
|
|
24504
|
+
return false;
|
|
24505
|
+
const checkOption = (dataset) => {
|
|
24506
|
+
if (typeof customOptions === "string") {
|
|
24507
|
+
return has(dataset, customOptions);
|
|
24508
|
+
} else if (isArray$2(customOptions)) {
|
|
24509
|
+
return some(customOptions, (option) => has(dataset, option));
|
|
24510
|
+
} else {
|
|
24511
|
+
return some(
|
|
24512
|
+
Object.values(customOptions),
|
|
24513
|
+
(option) => has(dataset, option)
|
|
24514
|
+
);
|
|
24515
|
+
}
|
|
24516
|
+
};
|
|
24517
|
+
if (isArray$2(data)) {
|
|
24518
|
+
return some(data, (dataset) => checkOption(dataset));
|
|
24519
|
+
} else {
|
|
24520
|
+
return checkOption(data);
|
|
24521
|
+
}
|
|
24522
|
+
};
|
|
24492
24523
|
const Controls = ({
|
|
24493
24524
|
headerComponent,
|
|
24494
24525
|
subheaderComponent,
|
|
@@ -24533,6 +24564,7 @@ const Controls = ({
|
|
|
24533
24564
|
dispatch,
|
|
24534
24565
|
generatedDatasets
|
|
24535
24566
|
});
|
|
24567
|
+
const hasCustomOpt = checkCustomOption(generatedDatasets, "hasCustomOpt");
|
|
24536
24568
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
24537
24569
|
/* @__PURE__ */ jsxs("div", { className: styles$3.controls, children: [
|
|
24538
24570
|
!!options.title && /* @__PURE__ */ jsx(Text, { bold: true, children: options.title }),
|
|
@@ -24558,7 +24590,8 @@ const Controls = ({
|
|
|
24558
24590
|
pointsEnabled,
|
|
24559
24591
|
onToggleLine,
|
|
24560
24592
|
onTogglePoints,
|
|
24561
|
-
translations
|
|
24593
|
+
translations,
|
|
24594
|
+
hasCustomOpt
|
|
24562
24595
|
}
|
|
24563
24596
|
),
|
|
24564
24597
|
/* @__PURE__ */ jsx(
|
|
@@ -25135,6 +25168,11 @@ const INIT_KEYS = {
|
|
|
25135
25168
|
};
|
|
25136
25169
|
const LOWER_BOUND = 1e-4;
|
|
25137
25170
|
const UPPER_BOUND = 1e7;
|
|
25171
|
+
var CUSTOM_OPTION = /* @__PURE__ */ ((CUSTOM_OPTION2) => {
|
|
25172
|
+
CUSTOM_OPTION2["showLine"] = "showLine";
|
|
25173
|
+
CUSTOM_OPTION2["showPoints"] = "showPoints";
|
|
25174
|
+
return CUSTOM_OPTION2;
|
|
25175
|
+
})(CUSTOM_OPTION || {});
|
|
25138
25176
|
const generateLineChartDatasets = (datasets, state, options, { label }) => {
|
|
25139
25177
|
const copyDataset = [...datasets];
|
|
25140
25178
|
const { annotations, graph } = options;
|
|
@@ -25176,7 +25214,9 @@ const generateLineChartDatasets = (datasets, state, options, { label }) => {
|
|
|
25176
25214
|
borderColor,
|
|
25177
25215
|
backgroundColor,
|
|
25178
25216
|
pointBackgroundColor,
|
|
25179
|
-
borderDash
|
|
25217
|
+
borderDash,
|
|
25218
|
+
showPoints = true,
|
|
25219
|
+
showLine
|
|
25180
25220
|
} = line ?? {};
|
|
25181
25221
|
const { lineEnabled, pointsEnabled, axes = [] } = state ?? {};
|
|
25182
25222
|
const { lineTension, spanGaps } = graph ?? {};
|
|
@@ -25194,14 +25234,15 @@ const generateLineChartDatasets = (datasets, state, options, { label }) => {
|
|
|
25194
25234
|
const filteredData = data.filter(Boolean) || [];
|
|
25195
25235
|
const isSinglePoint = (filteredData == null ? void 0 : filteredData.length) === 1;
|
|
25196
25236
|
const linePointRadius = parseFloat(pointRadiusProp) || DEFAULT_POINT_RADIUS;
|
|
25197
|
-
const pointRadius = pointsEnabled || isSinglePoint ? linePointRadius : 0;
|
|
25237
|
+
const pointRadius = (pointsEnabled || isSinglePoint) && showPoints ? linePointRadius : 0;
|
|
25198
25238
|
const hoverRadius = parseFloat(pointHoverRadius) || DEFAULT_HOVER_RADIUS;
|
|
25199
25239
|
const indexedColor = COLORS[i2];
|
|
25240
|
+
const hasCustomOpt = checkCustomOption(line, CUSTOM_OPTION);
|
|
25200
25241
|
return {
|
|
25201
25242
|
...line,
|
|
25202
25243
|
label: line.label || `${label} ${i2 + 1}`,
|
|
25203
25244
|
data: filteredData,
|
|
25204
|
-
showLine: lineEnabled,
|
|
25245
|
+
showLine: showLine ?? lineEnabled,
|
|
25205
25246
|
lineTension,
|
|
25206
25247
|
spanGaps,
|
|
25207
25248
|
borderWidth: parseFloat(borderWidth) || DEFAULT_BORDER_WIDTH,
|
|
@@ -25212,7 +25253,8 @@ const generateLineChartDatasets = (datasets, state, options, { label }) => {
|
|
|
25212
25253
|
pointBackgroundColor: pointBackgroundColor ?? indexedColor ?? generateRandomColor(COLORS),
|
|
25213
25254
|
pointRadius,
|
|
25214
25255
|
pointHoverRadius: hoverRadius,
|
|
25215
|
-
pointHitRadius: line.pointHitRadius ?? hoverRadius
|
|
25256
|
+
pointHitRadius: line.pointHitRadius ?? hoverRadius,
|
|
25257
|
+
...hasCustomOpt ? { hasCustomOpt } : {}
|
|
25216
25258
|
};
|
|
25217
25259
|
});
|
|
25218
25260
|
};
|