Fix bug on TopN weird behavior with zero values (#74942)

This commit is contained in:
Stratoula Kalafateli 2020-08-14 17:57:08 +03:00 committed by GitHub
parent ec5112b9cc
commit 458bf9fb0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -110,7 +110,9 @@ export class TopN extends Component {
const isPositiveValue = lastValue >= 0;
const intervalLength = TopN.calcDomain(renderMode, min, max);
const width = 100 * (Math.abs(lastValue) / intervalLength);
// if both are 0, the division returns NaN causing unexpected behavior.
// For this it defaults to 0
const width = 100 * (Math.abs(lastValue) / intervalLength) || 0;
const styles = reactcss(
{