From 80b4ef820a59543293600757526cce5b8f21e39b Mon Sep 17 00:00:00 2001 From: Leon Sorokin Date: Thu, 21 Oct 2021 20:08:26 -0500 Subject: [PATCH] Stat: Fixes an issue that could lead to browser crash with specific values (#40777) --- .../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),