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,