Remove a console.log, and colourize the world tree by utilized capacity.

This commit is contained in:
Herbert Wolverson
2024-07-17 15:41:55 -05:00
parent 8b3bd54271
commit 55c8fca3f3

View File

@@ -1,4 +1,5 @@
import { DashboardGraph } from "./graphs/dashboard_graph"; import { DashboardGraph } from "./graphs/dashboard_graph";
import {lerpGreenToRedViaOrange} from "./helpers/scaling";
class AllTreeSankey extends DashboardGraph { class AllTreeSankey extends DashboardGraph {
constructor(id) { constructor(id) {
@@ -26,18 +27,24 @@ class AllTreeSankey extends DashboardGraph {
function start() { function start() {
$.get("/local-api/networkTree", (data) => { $.get("/local-api/networkTree", (data) => {
console.log(data); //console.log(data);
let nodes = []; let nodes = [];
let links = []; let links = [];
for (let i=0; i<data.length; i++) { for (let i=0; i<data.length; i++) {
let bytes = data[i][1].current_throughput[0];
let bytesAsMegabits = bytes / 1000000;
let maxBytes = data[i][1].max_throughput[0] / 8;
let percent = Math.min(100, (bytesAsMegabits / maxBytes) * 100);
let capacityColor = lerpGreenToRedViaOrange(100 - percent, 100);
nodes.push({ nodes.push({
name: data[i][1].name, name: data[i][1].name,
label: { label: {
fontSize: 6, fontSize: 6,
color: "#999" color: "#999"
} },
}); });
if (i > 1) { if (i > 1) {
@@ -45,7 +52,10 @@ function start() {
links.push({ links.push({
source: data[immediateParent][1].name, source: data[immediateParent][1].name,
target: data[i][1].name, target: data[i][1].name,
value: data[i][1].current_throughput[0] + data[i][1].current_throughput[1] value: data[i][1].current_throughput[0] + data[i][1].current_throughput[1],
lineStyle: {
color: capacityColor,
}
}); });
} }
} }