mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 04:38:28 +00:00
@@ -104,14 +104,14 @@ function updateQueryTypesPie() {
|
||||
let sum = 0;
|
||||
|
||||
// Compute total number of queries
|
||||
for (const item of Object.keys(data.types)) {
|
||||
sum += data.types[item];
|
||||
for (const value of Object.values(data.types)) {
|
||||
sum += value;
|
||||
}
|
||||
|
||||
// Fill chart with data (only include query types which appeared recently)
|
||||
for (const item of Object.keys(data.types)) {
|
||||
if (data.types[item] > 0) {
|
||||
v.push((100 * data.types[item]) / sum);
|
||||
for (const [item, value] of Object.entries(data.types)) {
|
||||
if (value > 0) {
|
||||
v.push((100 * value) / sum);
|
||||
c.push(THEME_COLORS[i % THEME_COLORS.length]);
|
||||
k.push(item);
|
||||
}
|
||||
@@ -149,9 +149,9 @@ function updateClientsOverTime() {
|
||||
let numClients = 0;
|
||||
const labels = [];
|
||||
const clients = {};
|
||||
for (const ip of Object.keys(data.clients)) {
|
||||
for (const [ip, clientData] of Object.entries(data.clients)) {
|
||||
clients[ip] = numClients++;
|
||||
labels.push(data.clients[ip].name !== null ? data.clients[ip].name : ip);
|
||||
labels.push(clientData.name !== null ? clientData.name : ip);
|
||||
}
|
||||
|
||||
// Remove possibly already existing data
|
||||
@@ -176,15 +176,11 @@ function updateClientsOverTime() {
|
||||
|
||||
// Add data for each dataset that is available
|
||||
// We need to iterate over all time slots and fill in the data for each client
|
||||
for (const item of Object.keys(data.history)) {
|
||||
for (const client of Object.keys(clients)) {
|
||||
if (data.history[item].data[client] === undefined) {
|
||||
// If there is no data for this client in this timeslot, we push 0
|
||||
clientsChart.data.datasets[clients[client]].data.push(0);
|
||||
} else {
|
||||
// Otherwise, we push the data
|
||||
clientsChart.data.datasets[clients[client]].data.push(data.history[item].data[client]);
|
||||
}
|
||||
for (const item of Object.values(data.history)) {
|
||||
for (const [client, index] of Object.entries(clients)) {
|
||||
const clientData = item.data[client];
|
||||
// If there is no data for this client in this timeslot, we push 0, otherwise the data
|
||||
clientsChart.data.datasets[index].data.push(clientData === undefined ? 0 : clientData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user