Wrong percent calculation in pie chart - still exists

Please follow the below template, it will help us to help you!

Hi,
I'm referring to my first Thread, where the percent calculation did not work (link below).
Meanwhile this was fixed, but today I found out that the issue still seems to exist. Even if it's not that extrem anymore... maybe this is typicall german behaviour :wink: , but the overall percentage does not match 100%. So I think there must be something wrong.

Expected Behaviour:

Pie Chart: Sum of all single elements should be 100%

Actual Behaviour:


Left Chart: 90 + 6,2 + 2,6 + 1 = 99,8 %
Right Chart: 34 + 15,9 + 34,4 + 17,4 = 101,7 %

I know, I know, I know... shame on my head. This must be very picky and neglectable (what I want to say in german: mega pingelig und zu vernachlässigen) but from my perspective, It's wrong. So there must be an error. It's absolutely not dramatically, but does not show the reality.

Regards,
V.

Please upload a debug log and post just the token that is generated after the log is uploaded by running the following command from the Pi-hole host terminal:

pihole -d

or do it through the Web interface:

Tools > Generate Debug Log

sorry, I forgot :see_no_evil:

Token#: zsp6hg8164

Output of the following from the Pi terminal:

echo ">stats >quit" | nc localhost 4711

You need to look at the raw data, the chart already does some rounding.

You can access it via http://pi.hole/admin/api.php?getQueryTypes

e.g. my PTR is 0.85%

Below the output:

~# echo ">stats >quit" | nc localhost 4711
domains_being_blocked 3800857
dns_queries_today 26909
ads_blocked_today 10294
ads_percentage_today 38.254860
unique_domains 8697
queries_forwarded 11579
queries_cached 4269
clients_ever_seen 22
unique_clients 21
dns_queries_all_types 26909
reply_NODATA 549
reply_NXDOMAIN 932
reply_CNAME 5520
reply_IP 17433
privacy_level 0
status enabled

So is it working as designed?
For me it just looks strange all the time if you see that there should be 50% for example, but the pie does not show a half pie chart.

Could you provide the output of

? Note that you need to be logged in to the dashboard to be able to access this resource.

The difference comes from

which cuts away all the digits after the first one without rounding. We could use round to one digit, however, hacks are needed to do this as Javascript doesn't support rounding to a specific digit itself. Something like

(Math.round(num * 10) / 10).toFixed(1)

could be used. The extra toFixed would be needed to avoid rounding results like 50.0000000032.

I'm not convinced it's worth the effort. I wouldn't want to show more than one digit. For instance, one out of 7 queries could result in 14.285714285714286% which is obviously useless.

sure, here we go:

output is:

{"querytypes":{"A (IPv4)":91.18,"AAAA (IPv6)":7.27,"ANY":0,"SRV":0.02,"SOA":0,"PTR":1.49,"TXT":0,"NAPTR":0.03,"MX":0,"DS":0,"RRSIG":0,"DNSKEY":0,"NS":0,"OTHER":0,"SVCB":0,"HTTPS":0}}

and here is a screenshot from the same moment:

right chart: 48,8 + 19,3 + 34,8 + 1,0 = 103,9 %

.
.

I'm not convinced it's worth the effort. I wouldn't want to show more than one digit. For instance, one out of 7 queries could result in 14.285714285714286% which is obviously useless.

I fully agree with you. But I had the thought that there is maybe something bigger what is "defective".
That#s why I wanted to mention it.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.