Skip to content

Commit

Permalink
Fix bug on TopN weird behavior with zero values (elastic#74942)
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Aug 14, 2020
1 parent ec5112b commit 458bf9f
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 458bf9f

Please sign in to comment.