Skip to content

Commit

Permalink
report(treemap): correct percentages when 0 bytes JS (#13382)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny authored Nov 16, 2021
1 parent b7f09e6 commit 5d7eee0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion treemap/app/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,8 @@ class TreemapViewer {
];

if (bytes !== undefined && total !== undefined) {
const percentStr = TreemapUtil.i18n.formatPercent(bytes / total);
const percent = total === 0 ? 1 : bytes / total;
const percentStr = TreemapUtil.i18n.formatPercent(percent);
let str = `${TreemapUtil.i18n.formatBytesWithBestUnit(bytes)} (${percentStr})`;
// Only add label for bytes on the root node.
if (node === this.currentTreemapRoot) {
Expand Down

0 comments on commit 5d7eee0

Please sign in to comment.