@oliasoft-open-source/charts-library 3.4.5 → 3.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 +22 -61
- package/dist/index.js.map +1 -1
- package/dist/src/components/line-chart/utils/axis-scales/axis-scales.d.ts +1 -1
- package/dist/src/components/line-chart/utils/get-annotations-data.d.ts +1 -0
- package/dist/src/components/line-chart/utils/get-axes-data-from-metasets.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22170,7 +22170,8 @@ const generateAxisId = (axisType, index2 = 0, hasMultiAxes = false) => {
|
|
|
22170
22170
|
return `${axisType}${i2}`;
|
|
22171
22171
|
};
|
|
22172
22172
|
const getAxisTypeFromKey = (string) => {
|
|
22173
|
-
|
|
22173
|
+
var _a2;
|
|
22174
|
+
return ((_a2 = string.match(/[^0-9/]+/gi)) == null ? void 0 : _a2[0]) || "";
|
|
22174
22175
|
};
|
|
22175
22176
|
const generateKey = (values) => {
|
|
22176
22177
|
const key = values.join("");
|
|
@@ -24856,77 +24857,37 @@ const getSuggestedAxisRange = ({
|
|
|
24856
24857
|
max: round$2(maxAxisValue, DECIMAL_POINT_TOLERANCE)
|
|
24857
24858
|
};
|
|
24858
24859
|
};
|
|
24859
|
-
const checkMultiAxis = (scalesKeys) => {
|
|
24860
|
-
let counts = {
|
|
24861
|
-
x: 0,
|
|
24862
|
-
y: 0
|
|
24863
|
-
};
|
|
24864
|
-
scalesKeys.forEach((axeKey) => {
|
|
24865
|
-
const key = getAxisTypeFromKey(axeKey);
|
|
24866
|
-
counts[key]++;
|
|
24867
|
-
});
|
|
24868
|
-
const res = counts.x > counts.y && AxisType.X || counts.y > counts.x && AxisType.Y || counts.x === counts.y && null;
|
|
24869
|
-
return res;
|
|
24870
|
-
};
|
|
24871
24860
|
const getAnnotationsData = (data) => {
|
|
24872
|
-
return data.reduce((acc, obj) => {
|
|
24861
|
+
return data == null ? void 0 : data.reduce((acc, obj) => {
|
|
24873
24862
|
return {
|
|
24874
24863
|
...acc,
|
|
24875
24864
|
[obj.annotationAxis]: [...acc[obj.annotationAxis] || [], +obj.value]
|
|
24876
24865
|
};
|
|
24877
24866
|
}, {});
|
|
24878
24867
|
};
|
|
24879
|
-
const
|
|
24880
|
-
|
|
24881
|
-
|
|
24882
|
-
return
|
|
24883
|
-
|
|
24884
|
-
|
|
24885
|
-
|
|
24886
|
-
|
|
24887
|
-
|
|
24888
|
-
|
|
24889
|
-
|
|
24890
|
-
}
|
|
24891
|
-
};
|
|
24892
|
-
const getDataForMultiAxes = () => {
|
|
24893
|
-
const multiAxesKey = checkMultiAxis(scalesKeys);
|
|
24894
|
-
const axes = (scalesKeys == null ? void 0 : scalesKeys.filter((key) => key == null ? void 0 : key.includes(multiAxesKey))) ?? [];
|
|
24895
|
-
const data = getAnnotationsData(annotationsData);
|
|
24896
|
-
const [first, second] = axes;
|
|
24897
|
-
const reduceData = (arr, key) => arr.reduce((acc, { [key]: value }) => [...acc, value], []);
|
|
24898
|
-
return datasets.reduce(
|
|
24899
|
-
(acc, obj) => {
|
|
24900
|
-
const key = Object.values(obj).find((val) => axes.includes(val)) ?? multiAxesKey;
|
|
24901
|
-
return key ? {
|
|
24902
|
-
...acc,
|
|
24903
|
-
[key]: [
|
|
24904
|
-
.../* @__PURE__ */ new Set([
|
|
24905
|
-
...acc[key],
|
|
24906
|
-
...reduceData(obj == null ? void 0 : obj.data, multiAxesKey),
|
|
24907
|
-
...key === multiAxesKey && (data == null ? void 0 : data[multiAxesKey]) || []
|
|
24908
|
-
])
|
|
24909
|
-
]
|
|
24910
|
-
} : acc;
|
|
24911
|
-
},
|
|
24912
|
-
{ [first]: [], [second]: [] }
|
|
24913
|
-
);
|
|
24914
|
-
};
|
|
24915
|
-
return {
|
|
24916
|
-
...getData(),
|
|
24917
|
-
...getDataForMultiAxes()
|
|
24918
|
-
};
|
|
24868
|
+
const getAxesDataFromMetasets = (chartRef, scalesKeys, annotationsData) => {
|
|
24869
|
+
var _a2;
|
|
24870
|
+
if (!chartRef || !scalesKeys)
|
|
24871
|
+
return {};
|
|
24872
|
+
const metasets = ((_a2 = chartRef == null ? void 0 : chartRef.current) == null ? void 0 : _a2.getSortedVisibleDatasetMetas()) ?? [];
|
|
24873
|
+
const annotData = getAnnotationsData(annotationsData);
|
|
24874
|
+
return metasets && (scalesKeys == null ? void 0 : scalesKeys.reduce((acc, key) => {
|
|
24875
|
+
const data = metasets.filter((dataset) => Object.values(dataset).includes(key)).flatMap((dataset) => dataset._parsed).map((parsedData) => parsedData[getAxisTypeFromKey(key)]).concat((annotData == null ? void 0 : annotData[key]) ?? []);
|
|
24876
|
+
return {
|
|
24877
|
+
...acc,
|
|
24878
|
+
[key]: [...new Set(data)]
|
|
24879
|
+
};
|
|
24880
|
+
}, {}));
|
|
24919
24881
|
};
|
|
24920
|
-
const autoScale = (options, state, generatedDatasets) => {
|
|
24921
|
-
const { additionalAxesOptions = {}, annotations = {} } = options || {};
|
|
24922
|
-
const { annotationsData = [] } = annotations || {};
|
|
24882
|
+
const autoScale = (options, state, generatedDatasets, chartRef) => {
|
|
24883
|
+
const { additionalAxesOptions = {}, annotations: { annotationsData } = {} } = options || {};
|
|
24923
24884
|
const scales = getLineChartScales(options, state) || {};
|
|
24924
24885
|
if (!(additionalAxesOptions == null ? void 0 : additionalAxesOptions.autoAxisPadding) && !estimateDataSeriesHaveCloseValues(generatedDatasets)) {
|
|
24925
24886
|
return scales;
|
|
24926
24887
|
}
|
|
24927
24888
|
const scalesKeys = Object.keys(scales) ?? [];
|
|
24928
|
-
const data =
|
|
24929
|
-
const adjustedScales = scalesKeys == null ? void 0 : scalesKeys.reduce((acc, key) => {
|
|
24889
|
+
const data = getAxesDataFromMetasets(chartRef, scalesKeys, annotationsData);
|
|
24890
|
+
const adjustedScales = data && (scalesKeys == null ? void 0 : scalesKeys.reduce((acc, key) => {
|
|
24930
24891
|
const { min: propMin = void 0, max: propMax = void 0 } = scales[key];
|
|
24931
24892
|
const { min, max } = getSuggestedAxisRange({
|
|
24932
24893
|
data: data[key],
|
|
@@ -24941,7 +24902,7 @@ const autoScale = (options, state, generatedDatasets) => {
|
|
|
24941
24902
|
}
|
|
24942
24903
|
};
|
|
24943
24904
|
return { ...acc, ...res };
|
|
24944
|
-
}, {});
|
|
24905
|
+
}, {}));
|
|
24945
24906
|
return adjustedScales ?? scales;
|
|
24946
24907
|
};
|
|
24947
24908
|
const getCondition = (x2, y2, left2, right2, bottom2) => {
|
|
@@ -25210,7 +25171,7 @@ const useChartOptions = ({
|
|
|
25210
25171
|
[legendEnabled]
|
|
25211
25172
|
);
|
|
25212
25173
|
const scales = useMemo(
|
|
25213
|
-
() => autoScale(options, state, generatedDatasets),
|
|
25174
|
+
() => autoScale(options, state, generatedDatasets, chartRef),
|
|
25214
25175
|
[options, state, generatedDatasets]
|
|
25215
25176
|
);
|
|
25216
25177
|
const dragData = useMemo(
|