mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 20:55:28 +00:00
Indicate item share is less than 0.1%
Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
@@ -726,20 +726,24 @@ function updateSummaryData(runOnce) {
|
||||
function doughnutTooltip(tooltipLabel) {
|
||||
var percentageTotalShown = tooltipLabel.chart._metasets[0].total.toFixed(1);
|
||||
// tooltipLabel.chart._metasets[0].total returns the total percentage of the shown slices
|
||||
// to compensate rounding errors we round to two one decimal
|
||||
// to compensate rounding errors we round to 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>• " +
|
||||
tooltipLabel.parsed.toFixed(1) +
|
||||
itemPercentage +
|
||||
"% of all queries<br>• " +
|
||||
((tooltipLabel.parsed * 100) / percentageTotalShown).toFixed(1) +
|
||||
"% of shown items"
|
||||
|
||||
Reference in New Issue
Block a user