Skip to content

Commit 3732c02

Browse files
authored
Add rounding to 1 decimal place for ease of viewing
1 parent 816ce67 commit 3732c02

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

apps/storageanalyzer/custom.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@
6161
drawTable();
6262
});
6363
}
64-
64+
function roundDecimal(num){
65+
return Math.round(num * 10) / 10;
66+
}
6567
function drawTable() {
6668
document.getElementById("storageTable").innerHTML = `
6769
<table class="table table-striped">
@@ -77,7 +79,7 @@
7779
${globalApps.map(app => `
7880
<tr>
7981
<td>${app[0]}</td>
80-
<td>${(app[1]/1000).toFixed(1)}</td>
82+
<td>${(app[1]/1000).toFixed(1}</td>
8183
<td>${(app[2]/1000).toFixed(1)}</td>
8284
<td>${((app[1]+app[2])/1000).toFixed(1)}</td>
8385
</tr>`).join("")}
@@ -91,7 +93,7 @@
9193
// App-specific chart
9294
const chartData = [
9395
['App', 'Total Size (KB)']
94-
].concat(globalApps.map(app => [app[0], (app[1] + app[2])/1000]));
96+
].concat(globalApps.map(app => [app[0], roundDecimal((app[1] + app[2])/1000)]));
9597

9698
const data = google.visualization.arrayToDataTable(chartData);
9799

@@ -106,9 +108,9 @@
106108

107109
// Total storage chart
108110
if (storageStats) {
109-
const usedKB = storageStats.fileBytes / 1000;
110-
const freeKB = storageStats.freeBytes / 1000;
111-
const trashKB = storageStats.trashBytes / 1000;
111+
const usedKB = roundDecimal(storageStats.fileBytes / 1000);
112+
const freeKB = roundDecimal(storageStats.freeBytes / 1000);
113+
const trashKB = roundDecimal(storageStats.trashBytes / 1000);
112114
const totalData = google.visualization.arrayToDataTable([
113115
['Type', 'KB'],
114116
['Used', usedKB],

0 commit comments

Comments
 (0)