@oliasoft-open-source/charts-library 2.14.0 → 2.14.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/package.json
CHANGED
package/release-notes.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Charts Library Release Notes
|
|
2
2
|
|
|
3
|
+
## 2.14.1
|
|
4
|
+
- Fix save initAxesRange when dataset changed by parent component([OW-11332](https://oliasoft.atlassian.net/browse/OW-11332))
|
|
5
|
+
|
|
3
6
|
## 2.14.0
|
|
4
7
|
- Refactored line chart, for better performance, readable and reduce not needed re-renders
|
|
5
8
|
|
|
@@ -80,7 +80,14 @@ const LineChart = (props) => {
|
|
|
80
80
|
}, [state.lineEnabled, state.pointsEnabled, axes, annotations, graph]);
|
|
81
81
|
|
|
82
82
|
// Call the custom hooks.
|
|
83
|
-
useChartState({
|
|
83
|
+
useChartState({
|
|
84
|
+
chartRef,
|
|
85
|
+
options,
|
|
86
|
+
state,
|
|
87
|
+
generatedDatasets,
|
|
88
|
+
dispatch,
|
|
89
|
+
persistenceId,
|
|
90
|
+
});
|
|
84
91
|
|
|
85
92
|
const { resetZoom, handleDownload, handleKeyDown, handleKeyUp } =
|
|
86
93
|
useChartFunctions({
|
|
@@ -75,26 +75,38 @@ const useUpdateAxesRanges = (range, dispatch) => {
|
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
|
-
*
|
|
78
|
+
* A custom hook to save the initial axes ranges of a chart when the generated datasets change.
|
|
79
79
|
*
|
|
80
|
-
* @param chartRef -
|
|
81
|
-
* @param axes -
|
|
82
|
-
* @param
|
|
80
|
+
* @param {Object} chartRef - A reference to the chart object.
|
|
81
|
+
* @param {Array} axes - An array of axes configurations.
|
|
82
|
+
* @param {Array} generatedDatasets - An array of generated datasets for the chart.
|
|
83
|
+
* @param {Function} dispatch - A dispatch function from the useContext hook for managing the state.
|
|
83
84
|
*/
|
|
84
|
-
const useSaveInitialAxesRanges = (
|
|
85
|
+
const useSaveInitialAxesRanges = (
|
|
86
|
+
chartRef,
|
|
87
|
+
axes,
|
|
88
|
+
generatedDatasets,
|
|
89
|
+
dispatch,
|
|
90
|
+
) => {
|
|
91
|
+
const prevGeneratedDatasets = useRef();
|
|
92
|
+
|
|
85
93
|
const saveInitialAxesRanges = useCallback(() => {
|
|
86
|
-
if (
|
|
94
|
+
if (
|
|
95
|
+
chartRef &&
|
|
96
|
+
!isEqual(generatedDatasets, prevGeneratedDatasets.current)
|
|
97
|
+
) {
|
|
87
98
|
const initialAxesRanges = getAxesRangesFromChart(chartRef, axes);
|
|
88
99
|
dispatch({
|
|
89
100
|
type: SAVE_INITIAL_AXES_RANGES,
|
|
90
101
|
payload: { initialAxesRanges },
|
|
91
102
|
});
|
|
103
|
+
prevGeneratedDatasets.current = generatedDatasets;
|
|
92
104
|
}
|
|
93
|
-
}, [chartRef]);
|
|
105
|
+
}, [chartRef, generatedDatasets]);
|
|
94
106
|
|
|
95
107
|
useEffect(() => {
|
|
96
108
|
saveInitialAxesRanges();
|
|
97
|
-
}, [saveInitialAxesRanges]);
|
|
109
|
+
}, [saveInitialAxesRanges, generatedDatasets]);
|
|
98
110
|
};
|
|
99
111
|
|
|
100
112
|
/**
|
|
@@ -103,6 +115,7 @@ const useSaveInitialAxesRanges = (chartRef, axes, dispatch) => {
|
|
|
103
115
|
* @param chartRef - The reference to the chart.
|
|
104
116
|
* @param options - The chart options.
|
|
105
117
|
* @param state - The chart state.
|
|
118
|
+
* @param {Array} generatedDatasets - An array of generated datasets for the chart.
|
|
106
119
|
* @param dispatch - The dispatch function for state management.
|
|
107
120
|
* @param persistenceId - The chart persistenceId.
|
|
108
121
|
*/
|
|
@@ -110,6 +123,7 @@ export const useChartState = ({
|
|
|
110
123
|
chartRef,
|
|
111
124
|
options,
|
|
112
125
|
state,
|
|
126
|
+
generatedDatasets,
|
|
113
127
|
dispatch,
|
|
114
128
|
persistenceId,
|
|
115
129
|
}) => {
|
|
@@ -123,5 +137,5 @@ export const useChartState = ({
|
|
|
123
137
|
useStoreChartStateInStorage(memoState, persistenceId);
|
|
124
138
|
useToggleCustomLegendVisibility(memoState, memoOptions);
|
|
125
139
|
useUpdateAxesRanges(range, dispatch);
|
|
126
|
-
useSaveInitialAxesRanges(chartRef, axes, dispatch);
|
|
140
|
+
useSaveInitialAxesRanges(chartRef, axes, generatedDatasets, dispatch);
|
|
127
141
|
};
|