Skip to content

Commit

Permalink
Clarify asPercent behaviour with comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar committed Jun 23, 2020
1 parent 2d79710 commit b8d654e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions x-pack/plugins/apm/public/utils/formatters/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export function asPercent(

const decimal = numerator / denominator;

// 33.2 => 33%
// 3.32 => 3.3%
// 0 => 0%
if (Math.abs(decimal) >= 0.1 || decimal === 0) {
return numeral(decimal).format('0%');
}
Expand Down

0 comments on commit b8d654e

Please sign in to comment.