@oliasoft-open-source/charts-library 4.4.4 → 4.4.6
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 +34 -15
- package/dist/index.js.map +1 -1
- package/dist/src/components/common/common.interface.d.ts +1 -0
- package/dist/src/components/common/helpers/custom-format-number.d.ts +1 -1
- package/dist/src/components/pie-chart/pie-chart-defalut-props.interface.d.ts +2 -5
- package/dist/src/components/scatter-chart/hooks/use-scatter-chart-config.d.ts +1 -1
- package/dist/src/components/scatter-chart/scatter-chart-default-props.interface.d.ts +1 -0
- package/dist/src/components/scatter-chart/scatter-chart.interface.d.ts +1 -0
- package/dist/src/components/scatter-chart/utils/get-tooltip-config.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -13,7 +13,6 @@ import { round as round$2, displayNumber, isCloseTo, roundByMagnitude } from "@o
|
|
|
13
13
|
import cx from "classnames";
|
|
14
14
|
import { Portal, Icon, Tooltip as Tooltip$2, Button, Flex, Text, Menu, Popover, Field, InputGroup, NumberInput, InputGroupAddon, Select, ButtonGroup, Spacer } from "@oliasoft-open-source/react-ui-library";
|
|
15
15
|
import { isEmpty, isArray as isArray$2, some, has, cloneDeep, defaultTo, findIndex, set as set$2, debounce as debounce$3, isNil, map as map$3, find, get as get$1 } from "lodash";
|
|
16
|
-
import { roundNumberToPrecision } from "@oliasoft-open-source/units/dist/rounding/rounding";
|
|
17
16
|
/*!
|
|
18
17
|
* @kurkle/color v0.3.2
|
|
19
18
|
* https://github.com/kurkle/color#readme
|
|
@@ -26994,7 +26993,8 @@ const defaultChartStyling$2 = (styling) => ({
|
|
|
26994
26993
|
});
|
|
26995
26994
|
const defaultTooltip$2 = (tooltip) => ({
|
|
26996
26995
|
tooltips: (tooltip == null ? void 0 : tooltip.tooltips) ?? true,
|
|
26997
|
-
showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false
|
|
26996
|
+
showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false,
|
|
26997
|
+
scientificNotation: (tooltip == null ? void 0 : tooltip.scientificNotation) ?? true
|
|
26998
26998
|
});
|
|
26999
26999
|
const defaultGraph$2 = (graph) => ({
|
|
27000
27000
|
showDataLabels: (graph == null ? void 0 : graph.showDataLabels) || false,
|
|
@@ -27039,6 +27039,8 @@ const getDefaultProps$2 = (props) => {
|
|
|
27039
27039
|
}
|
|
27040
27040
|
};
|
|
27041
27041
|
};
|
|
27042
|
+
const DISPLAY_SCIENTIFIC_LOWER_BOUND = 1e-4;
|
|
27043
|
+
const DISPLAY_SCIENTIFIC_UPPER_BOUND = 1e7;
|
|
27042
27044
|
const usePieChartConfig = (chart2) => {
|
|
27043
27045
|
const [pointHover, setPointHover] = useState(false);
|
|
27044
27046
|
const { data, options } = chart2;
|
|
@@ -27171,6 +27173,16 @@ const usePieChartConfig = (chart2) => {
|
|
|
27171
27173
|
};
|
|
27172
27174
|
};
|
|
27173
27175
|
const getToolTips = () => {
|
|
27176
|
+
const customFormatNumber2 = (labelNumber) => {
|
|
27177
|
+
var _a2;
|
|
27178
|
+
let roundOptions = {};
|
|
27179
|
+
if (!((_a2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _a2.scientificNotation)) {
|
|
27180
|
+
roundOptions = { scientific: false };
|
|
27181
|
+
} else if (Math.abs(labelNumber) < DISPLAY_SCIENTIFIC_LOWER_BOUND || Math.abs(labelNumber) > DISPLAY_SCIENTIFIC_UPPER_BOUND) {
|
|
27182
|
+
roundOptions = { roundScientificCoefficient: 3 };
|
|
27183
|
+
}
|
|
27184
|
+
return displayNumber(roundByMagnitude(labelNumber), roundOptions);
|
|
27185
|
+
};
|
|
27174
27186
|
return {
|
|
27175
27187
|
callbacks: {
|
|
27176
27188
|
title: (tooltipItem) => {
|
|
@@ -27187,8 +27199,7 @@ const usePieChartConfig = (chart2) => {
|
|
|
27187
27199
|
const value = tooltipItem.dataset.data[dataIndex];
|
|
27188
27200
|
const labelValue = typeof value === "object" ? `${value.value || ""} ${options.tooltip.showLabelsInTooltips && value.label ? "(" + value.label + ")" : ""}` : value;
|
|
27189
27201
|
const unit = (data == null ? void 0 : data.yUnit) ? `[${data == null ? void 0 : data.yUnit}]` : "";
|
|
27190
|
-
|
|
27191
|
-
return `${dataLabel} ${formattedValue} ${unit}`;
|
|
27202
|
+
return `${dataLabel} ${customFormatNumber2(labelValue)} ${unit}`;
|
|
27192
27203
|
}
|
|
27193
27204
|
},
|
|
27194
27205
|
padding: TOOLTIP_PADDING,
|
|
@@ -39859,8 +39870,6 @@ const getBarChartDataLabels = (options) => {
|
|
|
39859
39870
|
formatter: formatterCallback
|
|
39860
39871
|
} : { display: false };
|
|
39861
39872
|
};
|
|
39862
|
-
const DISPLAY_SCIENTIFIC_LOWER_BOUND = 1e-4;
|
|
39863
|
-
const DISPLAY_SCIENTIFIC_UPPER_BOUND = 1e7;
|
|
39864
39873
|
const getBarChartToolTips = (options) => {
|
|
39865
39874
|
var _a2;
|
|
39866
39875
|
const getTooltipLabels = (dataset) => {
|
|
@@ -39896,8 +39905,11 @@ const getBarChartToolTips = (options) => {
|
|
|
39896
39905
|
return axisLabel + barLabel;
|
|
39897
39906
|
};
|
|
39898
39907
|
const customFormatNumber2 = (labelNumber) => {
|
|
39908
|
+
var _a3;
|
|
39899
39909
|
let roundOptions = {};
|
|
39900
|
-
if (
|
|
39910
|
+
if (!((_a3 = options == null ? void 0 : options.tooltip) == null ? void 0 : _a3.scientificNotation)) {
|
|
39911
|
+
roundOptions = { scientific: false };
|
|
39912
|
+
} else if (Math.abs(labelNumber) < DISPLAY_SCIENTIFIC_LOWER_BOUND || Math.abs(labelNumber) > DISPLAY_SCIENTIFIC_UPPER_BOUND) {
|
|
39901
39913
|
roundOptions = { roundScientificCoefficient: 3 };
|
|
39902
39914
|
}
|
|
39903
39915
|
return displayNumber(roundByMagnitude(labelNumber), roundOptions);
|
|
@@ -40033,7 +40045,8 @@ const defaultChartStyling$1 = (styling) => ({
|
|
|
40033
40045
|
});
|
|
40034
40046
|
const defaultTooltip$1 = (tooltip) => ({
|
|
40035
40047
|
tooltips: (tooltip == null ? void 0 : tooltip.tooltips) ?? true,
|
|
40036
|
-
showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false
|
|
40048
|
+
showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false,
|
|
40049
|
+
scientificNotation: (tooltip == null ? void 0 : tooltip.scientificNotation) ?? true
|
|
40037
40050
|
});
|
|
40038
40051
|
const defaultGraph$1 = (graph) => ({
|
|
40039
40052
|
showDataLabels: (graph == null ? void 0 : graph.showDataLabels) || false,
|
|
@@ -40182,9 +40195,11 @@ const BarChartWithLegend = (props) => {
|
|
|
40182
40195
|
const { options } = getDefaultProps$1(props);
|
|
40183
40196
|
return /* @__PURE__ */ jsx(LegendProvider, { options, children: /* @__PURE__ */ jsx(BarChart, { ...props }) });
|
|
40184
40197
|
};
|
|
40185
|
-
const customFormatNumber = (labelNumber) => {
|
|
40198
|
+
const customFormatNumber = (labelNumber, scientificNotation) => {
|
|
40186
40199
|
let roundOptions = {};
|
|
40187
|
-
if (
|
|
40200
|
+
if (!scientificNotation) {
|
|
40201
|
+
roundOptions = { scientific: false };
|
|
40202
|
+
} else if (Math.abs(labelNumber) < DISPLAY_SCIENTIFIC_LOWER_BOUND || Math.abs(labelNumber) > DISPLAY_SCIENTIFIC_UPPER_BOUND) {
|
|
40188
40203
|
roundOptions = { roundScientificCoefficient: 3 };
|
|
40189
40204
|
}
|
|
40190
40205
|
return displayNumber(roundByMagnitude(labelNumber), roundOptions);
|
|
@@ -40197,12 +40212,15 @@ const titleCallback = (tooltipItems, options) => {
|
|
|
40197
40212
|
return label;
|
|
40198
40213
|
}
|
|
40199
40214
|
};
|
|
40200
|
-
const labelCallback = (tooltipItem) => {
|
|
40215
|
+
const labelCallback = (tooltipItem, options) => {
|
|
40216
|
+
var _a2;
|
|
40201
40217
|
const { raw, dataset } = tooltipItem ?? {};
|
|
40202
40218
|
const datapointLabel = raw == null ? void 0 : raw.label;
|
|
40219
|
+
const scientificNotation = (_a2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _a2.scientificNotation;
|
|
40203
40220
|
return `${datapointLabel ?? (dataset == null ? void 0 : dataset.label)} ( x: ${customFormatNumber(
|
|
40204
|
-
raw == null ? void 0 : raw.x
|
|
40205
|
-
|
|
40221
|
+
raw == null ? void 0 : raw.x,
|
|
40222
|
+
scientificNotation
|
|
40223
|
+
)} , y: ${customFormatNumber(raw == null ? void 0 : raw.y, scientificNotation)} )`;
|
|
40206
40224
|
};
|
|
40207
40225
|
const getTooltipsConfig = (options) => {
|
|
40208
40226
|
var _a2, _b2, _c2;
|
|
@@ -40210,7 +40228,7 @@ const getTooltipsConfig = (options) => {
|
|
|
40210
40228
|
enabled: (_a2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _a2.enabled,
|
|
40211
40229
|
callbacks: {
|
|
40212
40230
|
title: (tooltipItems) => titleCallback(tooltipItems, options),
|
|
40213
|
-
label: labelCallback
|
|
40231
|
+
label: (tooltipItems) => labelCallback(tooltipItems, options)
|
|
40214
40232
|
},
|
|
40215
40233
|
backgroundColor: (_b2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _b2.backgroundColor,
|
|
40216
40234
|
displayColors: (_c2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _c2.displayColors,
|
|
@@ -40386,7 +40404,8 @@ const defaultTooltip = (tooltip) => ({
|
|
|
40386
40404
|
tooltips: (tooltip == null ? void 0 : tooltip.tooltips) ?? true,
|
|
40387
40405
|
showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false,
|
|
40388
40406
|
backgroundColor: (tooltip == null ? void 0 : tooltip.backgroundColor) || "#333",
|
|
40389
|
-
displayColors: (tooltip == null ? void 0 : tooltip.displayColors) || false
|
|
40407
|
+
displayColors: (tooltip == null ? void 0 : tooltip.displayColors) || false,
|
|
40408
|
+
scientificNotation: (tooltip == null ? void 0 : tooltip.scientificNotation) ?? true
|
|
40390
40409
|
});
|
|
40391
40410
|
const defaultGraph = (graph) => ({
|
|
40392
40411
|
showMinorGridlines: (graph == null ? void 0 : graph.showMinorGridlines) ?? false,
|