Add rounding to 1 decimal place for ease of viewing

master
RKBoss6 2025-07-22 14:22:50 -04:00 committed by GitHub
parent 816ce67598
commit 3732c027b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 6 deletions

View File

@ -61,7 +61,9 @@
drawTable(); drawTable();
}); });
} }
function roundDecimal(num){
return Math.round(num * 10) / 10;
}
function drawTable() { function drawTable() {
document.getElementById("storageTable").innerHTML = ` document.getElementById("storageTable").innerHTML = `
<table class="table table-striped"> <table class="table table-striped">
@ -77,7 +79,7 @@
${globalApps.map(app => ` ${globalApps.map(app => `
<tr> <tr>
<td>${app[0]}</td> <td>${app[0]}</td>
<td>${(app[1]/1000).toFixed(1)}</td> <td>${(app[1]/1000).toFixed(1}</td>
<td>${(app[2]/1000).toFixed(1)}</td> <td>${(app[2]/1000).toFixed(1)}</td>
<td>${((app[1]+app[2])/1000).toFixed(1)}</td> <td>${((app[1]+app[2])/1000).toFixed(1)}</td>
</tr>`).join("")} </tr>`).join("")}
@ -91,7 +93,7 @@
// App-specific chart // App-specific chart
const chartData = [ const chartData = [
['App', 'Total Size (KB)'] ['App', 'Total Size (KB)']
].concat(globalApps.map(app => [app[0], (app[1] + app[2])/1000])); ].concat(globalApps.map(app => [app[0], roundDecimal((app[1] + app[2])/1000)]));
const data = google.visualization.arrayToDataTable(chartData); const data = google.visualization.arrayToDataTable(chartData);
@ -106,9 +108,9 @@
// Total storage chart // Total storage chart
if (storageStats) { if (storageStats) {
const usedKB = storageStats.fileBytes / 1000; const usedKB = roundDecimal(storageStats.fileBytes / 1000);
const freeKB = storageStats.freeBytes / 1000; const freeKB = roundDecimal(storageStats.freeBytes / 1000);
const trashKB = storageStats.trashBytes / 1000; const trashKB = roundDecimal(storageStats.trashBytes / 1000);
const totalData = google.visualization.arrayToDataTable([ const totalData = google.visualization.arrayToDataTable([
['Type', 'KB'], ['Type', 'KB'],
['Used', usedKB], ['Used', usedKB],