From 4b8993c1a5b86be419463c2b6123fdb5aac8338d Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Fri, 22 Oct 2021 02:34:45 +0100 Subject: [PATCH] Stat: Fixes an issue that could lead to browser crash with specific values (#40777) (#40789) (cherry picked from commit 80b4ef820a59543293600757526cce5b8f21e39b) Co-authored-by: Leon Sorokin --- .../grafana-ui/src/components/Sparkline/Sparkline.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/grafana-ui/src/components/Sparkline/Sparkline.tsx b/packages/grafana-ui/src/components/Sparkline/Sparkline.tsx index d089d949227..90f7aa89935 100755 --- a/packages/grafana-ui/src/components/Sparkline/Sparkline.tsx +++ b/packages/grafana-ui/src/components/Sparkline/Sparkline.tsx @@ -92,6 +92,15 @@ export class Sparkline extends PureComponent { getYRange(field: Field) { let { min, max } = this.state.alignedDataFrame.fields[1].state?.range!; + if (min === max) { + if (min === 0) { + max = 100; + } else { + min = 0; + max! *= 2; + } + } + return [ Math.max(min!, field.config.min ?? -Infinity), Math.min(max!, field.config.max ?? Infinity),