Stat: Fixes an issue that could lead to browser crash with specific values (#40777) (#40789)

(cherry picked from commit 80b4ef820a)

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2021-10-22 03:34:45 +02:00
committed by GitHub
co-authored by Leon Sorokin
parent d3f9ec7231
commit 4b8993c1a5
@@ -92,6 +92,15 @@ export class Sparkline extends PureComponent<SparklineProps, State> {
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),