Skip to content

Commit

Permalink
Fix bug on TopN weird behavior with zero values (elastic#74942) (elas…
Browse files Browse the repository at this point in the history
…tic#75048)

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
stratoula and elasticmachine authored Aug 17, 2020
1 parent 627b457 commit 883b704
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down

0 comments on commit 883b704

Please sign in to comment.