From e723021e138f691f24bb17bbf131920ab54e548d Mon Sep 17 00:00:00 2001 From: Giordano Ricci Date: Wed, 21 Dec 2022 14:01:26 +0000 Subject: [PATCH] Explore: Re-initialize graph when number of series to show changes (#60499) --- public/app/features/explore/Graph/ExploreGraph.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/app/features/explore/Graph/ExploreGraph.tsx b/public/app/features/explore/Graph/ExploreGraph.tsx index ce4ec43e2c3..97fff0f6134 100644 --- a/public/app/features/explore/Graph/ExploreGraph.tsx +++ b/public/app/features/explore/Graph/ExploreGraph.tsx @@ -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,