@pushwoosh/kit-charts 0.4.2 → 0.4.3
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/core/Chart/Chart.js +7 -9
- package/package.json +1 -1
package/core/Chart/Chart.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect, useMemo,
|
|
2
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { Grid, XAxis, XAxisLine, YAxis } from './Axes';
|
|
4
4
|
import { ChartErrorBoundary } from './ChartErrorBoundary';
|
|
5
5
|
import { Legend } from './Legend';
|
|
@@ -211,12 +211,10 @@ function ChartBody({
|
|
|
211
211
|
hidden
|
|
212
212
|
}) : null, [zoomed, canvas, registry, hidden]);
|
|
213
213
|
const anyShown = built?.series.some(series => !series.hidden) ?? false;
|
|
214
|
-
const lastShown =
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
}, [built, anyShown]);
|
|
214
|
+
const [lastShown, setLastShown] = useState(null);
|
|
215
|
+
if (built && anyShown && built !== lastShown) {
|
|
216
|
+
setLastShown(built);
|
|
217
|
+
}
|
|
220
218
|
// Switching off the last series must not reshape the axes under it: the plot
|
|
221
219
|
// holds the geometry of the last state that had something on show, so the series
|
|
222
220
|
// fades out where it stood instead of jumping to a rescaled axis first.
|
|
@@ -224,7 +222,7 @@ function ChartBody({
|
|
|
224
222
|
if (anyShown || !built) {
|
|
225
223
|
return built;
|
|
226
224
|
}
|
|
227
|
-
const frozen = lastShown
|
|
225
|
+
const frozen = lastShown;
|
|
228
226
|
if (!frozen) {
|
|
229
227
|
return built;
|
|
230
228
|
}
|
|
@@ -237,7 +235,7 @@ function ChartBody({
|
|
|
237
235
|
legend: built.legend,
|
|
238
236
|
titles: built.titles
|
|
239
237
|
};
|
|
240
|
-
}, [built, anyShown]);
|
|
238
|
+
}, [built, anyShown, lastShown]);
|
|
241
239
|
const contextFor = useCallback(series => {
|
|
242
240
|
if (!model) {
|
|
243
241
|
return null;
|