From f841f309a21fe3bc1070b15cd3ff4c2be1687dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Thu, 17 Nov 2022 14:29:20 +0100 Subject: [PATCH] Fix doughnutTooltip if total percentage of shown slices is less than 0.1% MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- scripts/pi-hole/js/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index b9ccf2fe..430385ae 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -732,7 +732,7 @@ function doughnutTooltip(tooltipLabel) { // in case the item share is really small it could be rounded to 0.0 // we compensate for this var itemPercentage = - tooltipLabel.parsed.toFixed(1) === 0 ? "< 0.1" : tooltipLabel.parsed.toFixed(1); + tooltipLabel.parsed.toFixed(1) === "0.0" ? "< 0.1" : tooltipLabel.parsed.toFixed(1); // even if no doughnut slice is hidden, sometimes percentageTotalShown is slightly less then 100 // we therefore use 99.9 to decide if slices are hidden (we only show with 0.1 precision) @@ -740,6 +740,9 @@ function doughnutTooltip(tooltipLabel) { // All items shown return label + ": " + itemPercentage + "%"; } else { + // set percentageTotalShown again without rounding to account + // for cases where the total shown percentage would be <0.1% of all + percentageTotalShown = tooltipLabel.chart._metasets[0].total; return ( label + ":
• " +