From 618c51e193728817a240cfd95d88a945f0dd491b Mon Sep 17 00:00:00 2001 From: Ihor Yeromin Date: Tue, 4 Jun 2024 19:09:10 +0200 Subject: [PATCH] Stat: Cut the top of the chart issue (#88640) * fix(stat): update config on range change --- packages/grafana-ui/src/components/Sparkline/Sparkline.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/grafana-ui/src/components/Sparkline/Sparkline.tsx b/packages/grafana-ui/src/components/Sparkline/Sparkline.tsx index d56ecd4283b..245baabee7c 100644 --- a/packages/grafana-ui/src/components/Sparkline/Sparkline.tsx +++ b/packages/grafana-ui/src/components/Sparkline/Sparkline.tsx @@ -86,7 +86,12 @@ export class Sparkline extends PureComponent { let rebuildConfig = false; if (prevProps.sparkline !== this.props.sparkline) { - rebuildConfig = !compareDataFrameStructures(this.state.alignedDataFrame, prevState.alignedDataFrame); + const isStructureChanged = !compareDataFrameStructures(this.state.alignedDataFrame, prevState.alignedDataFrame); + const isRangeChanged = !isEqual( + alignedDataFrame.fields[1].state?.range, + prevState.alignedDataFrame.fields[1].state?.range + ); + rebuildConfig = isStructureChanged || isRangeChanged; } else { rebuildConfig = !isEqual(prevProps.config, this.props.config); }