Skip to content

Commit

Permalink
refactor: Modify color rendering to preserve full node color history
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Nov 30, 2024
1 parent f76b440 commit c4f03d4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions hugo-site/static/html/eventual_convergence_viz.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,18 @@ <h1 class="title">Freenet Eventual Convergence Simulation</h1>
.value(1) // Each segment has equal weight
.sort(null); // Do not sort, keep original order

function drawPie(nodeGroup, colors) {
const arcs = pieGenerator(colors);
function drawPie(nodeGroup, allColors) {
// Only show the most recent MAX_COLORS from the global tracking
const visibleColors = allColors.filter(color => globalColors.includes(color));
const displayColors = visibleColors.slice(-MAX_COLORS);

const arcs = pieGenerator(displayColors);
nodeGroup.selectAll("path").remove(); // Clear existing paths before drawing
arcs.forEach((arc, i) => {
nodeGroup
.append("path")
.attr("d", arcGenerator(arc))
.attr("fill", colors[i])
.attr("fill", displayColors[i])
.attr("stroke", "#5f9ea0")
.attr("stroke-width", 0.5);
});
Expand Down Expand Up @@ -211,10 +215,6 @@ <h1 class="title">Freenet Eventual Convergence Simulation</h1>
});

if (colorsAdded) {
// Only trim to MAX_COLORS if we exceed it
if (target.data.receivedColors.length > MAX_COLORS) {
target.data.receivedColors = target.data.receivedColors.slice(-MAX_COLORS);
}
updateNodeColors(target);
}
} finally {
Expand Down

0 comments on commit c4f03d4

Please sign in to comment.