Tree Overview now supports a "max depth" control.

This commit is contained in:
Herbert Wolverson 2024-07-19 09:44:49 -05:00
parent 4ecf968acc
commit a5042220ce
2 changed files with 29 additions and 0 deletions

View File

@ -37,6 +37,10 @@ function start() {
let links = []; let links = [];
for (let i=0; i<data.length; i++) { for (let i=0; i<data.length; i++) {
let depth = data[i][1].parents.length;
if (depth > maxDepth) {
continue;
}
let name = data[i][1].name; let name = data[i][1].name;
let bytes = data[i][1].current_throughput[0]; let bytes = data[i][1].current_throughput[0];
let bytesAsMegabits = bytes / 1000000; let bytesAsMegabits = bytes / 1000000;
@ -84,6 +88,28 @@ function start() {
}); });
} }
function getMaxDepth() {
let maxDepth = 10;
let storedDepth = localStorage.getItem("atsDepth");
if (storedDepth !== null) {
maxDepth = parseInt(storedDepth);
} else {
localStorage.setItem("atsDepth", maxDepth.toString());
}
return maxDepth;
}
function bindMaxDepth() {
let d = document.getElementById("maxDepth");
d.value = maxDepth;
d.onclick = () => {
maxDepth = parseInt(d.value);
localStorage.setItem("atsDepth", maxDepth.toString());
};
}
let maxDepth = getMaxDepth();
bindMaxDepth();
let graph = new AllTreeSankey("sankey"); let graph = new AllTreeSankey("sankey");
start(); start();

View File

@ -1,4 +1,7 @@
<div class="row" style="height: 100%;"> <div class="row" style="height: 100%;">
<div class="col-12 small">
<label for="maxDepth">Max Depth:</label> <input type="number" min="2" max="10" id="maxDepth">
</div>
<div class="col-12" style="height: 100%;" id="sankey"></div> <div class="col-12" style="height: 100%;" id="sankey"></div>
</div> </div>
<script src="all_tree_sankey.js"></script> <script src="all_tree_sankey.js"></script>