Skip to content

Commit

Permalink
Indicate item share is less than 0.1%
Browse files Browse the repository at this point in the history
Signed-off-by: Christian König <ckoenig@posteo.de>
  • Loading branch information
yubiuser committed Oct 14, 2022
1 parent 8762248 commit 776f6df
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/pi-hole/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,17 +729,21 @@ function doughnutTooltip(tooltipLabel) {
// to compensate rounding errors we round to two one decimal

var label = " " + tooltipLabel.label;
// 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);

// 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)
if (percentageTotalShown > 99.9) {
// All items shown
return label + ": " + tooltipLabel.parsed.toFixed(1) + "%";
return label + ": " + itemPercentage + "%";
} else {
return (
label +
":<br>&bull; " +
tooltipLabel.parsed.toFixed(1) +
itemPercentage +
"% of all queries<br>&bull; " +
((tooltipLabel.parsed * 100) / percentageTotalShown).toFixed(1) +
"% of shown items"
Expand Down

0 comments on commit 776f6df

Please sign in to comment.