@oliasoft-open-source/charts-library 3.4.11 → 3.4.12-beta-1
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 +33 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25404,22 +25404,42 @@ const useStoreChartStateInStorage = (memoState, persistenceId) => {
|
|
|
25404
25404
|
memoState.zoomEnabled
|
|
25405
25405
|
]);
|
|
25406
25406
|
};
|
|
25407
|
-
const useUpdateAxesRanges = (range, dispatch) => {
|
|
25408
|
-
const
|
|
25407
|
+
const useUpdateAxesRanges = (range, dispatch, generatedDatasets, chartRef, options) => {
|
|
25408
|
+
const prevProps = useRef({
|
|
25409
|
+
range: null,
|
|
25410
|
+
datasets: null
|
|
25411
|
+
});
|
|
25412
|
+
const { annotations: { annotationsData = [] } = {} } = options || {};
|
|
25409
25413
|
const updateAxesRanges = useCallback(() => {
|
|
25410
|
-
|
|
25411
|
-
|
|
25414
|
+
let axes = null;
|
|
25415
|
+
if (range && range.x && range.y && !isEqual(range, prevProps.current.range)) {
|
|
25416
|
+
axes = Object.entries(range).map(([key, { min, max }]) => ({
|
|
25412
25417
|
id: key,
|
|
25413
25418
|
min: min ?? 0,
|
|
25414
25419
|
max: max ?? 0
|
|
25415
25420
|
}));
|
|
25421
|
+
prevProps.current.range = range;
|
|
25422
|
+
} else if (range && !isEqual(generatedDatasets, prevProps.current.datasets)) {
|
|
25423
|
+
const scalesKeys = Object.keys(range) ?? [];
|
|
25424
|
+
const data = getAxesDataFromMetasets(
|
|
25425
|
+
chartRef,
|
|
25426
|
+
scalesKeys,
|
|
25427
|
+
annotationsData
|
|
25428
|
+
);
|
|
25429
|
+
axes = Object.keys(range).map((key) => ({
|
|
25430
|
+
id: key,
|
|
25431
|
+
min: Math.min(...data[key]) ?? 0,
|
|
25432
|
+
max: Math.max(...data[key]) ?? 0
|
|
25433
|
+
}));
|
|
25434
|
+
prevProps.current.datasets = generatedDatasets;
|
|
25435
|
+
}
|
|
25436
|
+
if (axes) {
|
|
25416
25437
|
dispatch({
|
|
25417
25438
|
type: UPDATE_AXES_RANGES,
|
|
25418
25439
|
payload: { axes }
|
|
25419
25440
|
});
|
|
25420
|
-
prevRange.current = range;
|
|
25421
25441
|
}
|
|
25422
|
-
}, [range]);
|
|
25442
|
+
}, [range, generatedDatasets, dispatch]);
|
|
25423
25443
|
useEffect(() => {
|
|
25424
25444
|
updateAxesRanges();
|
|
25425
25445
|
}, [updateAxesRanges]);
|
|
@@ -25456,7 +25476,13 @@ const useChartState = ({
|
|
|
25456
25476
|
} = memoOptions;
|
|
25457
25477
|
useStoreChartStateInStorage(memoState, persistenceId);
|
|
25458
25478
|
useToggleCustomLegendVisibility(memoState, memoOptions);
|
|
25459
|
-
useUpdateAxesRanges(
|
|
25479
|
+
useUpdateAxesRanges(
|
|
25480
|
+
range,
|
|
25481
|
+
dispatch,
|
|
25482
|
+
generatedDatasets,
|
|
25483
|
+
chartRef,
|
|
25484
|
+
memoOptions
|
|
25485
|
+
);
|
|
25460
25486
|
useSaveInitialAxesRanges(chartRef, axes, generatedDatasets, dispatch);
|
|
25461
25487
|
};
|
|
25462
25488
|
const WORD_SEPARATOR = " ";
|