Explore: Re-initialize graph when number of series to show changes (#60499)

This commit is contained in:
Giordano Ricci 2022-12-21 14:01:26 +00:00 committed by GitHub
parent 838cbf22da
commit e723021e13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,10 +120,12 @@ export function ExploreGraph({
});
}, [fieldConfigRegistry, data, timeZone, theme, styledFieldConfig]);
const seriesToShow = showAllTimeSeries ? dataWithConfig : dataWithConfig.slice(0, MAX_NUMBER_OF_TIME_SERIES);
// We need to increment structureRev when the number of series changes.
// the function passed to useMemo runs during rendering, so when we get a different
// amount of data, structureRev is incremented before we render it
useMemo(inc, [dataWithConfig.length, styledFieldConfig, inc]);
useMemo(inc, [dataWithConfig.length, styledFieldConfig, seriesToShow.length, inc]);
useEffect(() => {
if (onHiddenSeriesChanged) {
@ -138,8 +140,6 @@ export function ExploreGraph({
}
}, [dataWithConfig, onHiddenSeriesChanged]);
const seriesToShow = showAllTimeSeries ? dataWithConfig : dataWithConfig.slice(0, MAX_NUMBER_OF_TIME_SERIES);
const panelContext: PanelContext = {
eventBus,
sync: () => DashboardCursorSync.Crosshair,