From 7e3cb1c778eccdf8b435e2ae641defa954f8dfca Mon Sep 17 00:00:00 2001 From: Brendan Kenny Date: Tue, 16 Nov 2021 11:47:14 -0600 Subject: [PATCH] report(treemap): correct percentages when 0 bytes JS --- treemap/app/src/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/treemap/app/src/main.js b/treemap/app/src/main.js index a4176e59d830..ffb4c1951d44 100644 --- a/treemap/app/src/main.js +++ b/treemap/app/src/main.js @@ -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) {