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

This commit is contained in:
Leon Sorokin 2021-10-21 20:08:26 -05:00 committed by GitHub
parent dfeb69dc17
commit 80b4ef820a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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),