mirror of
https://github.com/pi-hole/web.git
synced 2025-12-20 02:38:28 +00:00
Sort chart data by value, put OTHER always as last
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -24,6 +24,24 @@ function updateCachePie(data) {
|
||||
sum += data[item];
|
||||
});
|
||||
|
||||
// Sort data by value, put OTHER always as last
|
||||
var sorted = Object.keys(data).sort(function (a, b) {
|
||||
if (a === "OTHER") {
|
||||
return 1;
|
||||
} else if (b === "OTHER") {
|
||||
return -1;
|
||||
} else {
|
||||
return data[b] - data[a];
|
||||
}
|
||||
});
|
||||
|
||||
// Rebuild data object
|
||||
var tmp = {};
|
||||
sorted.forEach(function (item) {
|
||||
tmp[item] = data[item];
|
||||
});
|
||||
data = tmp;
|
||||
|
||||
// Add empty space to chart
|
||||
data.empty = cacheSize - sum;
|
||||
sum = cacheSize;
|
||||
|
||||
Reference in New Issue
Block a user