Skip to content

Commit

Permalink
fix: Preserve node colors and handle initial color display in drawPie
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Nov 30, 2024
1 parent c4f03d4 commit 0219f22
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions hugo-site/static/html/eventual_convergence_viz.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,19 @@ <h1 class="title">Freenet Eventual Convergence Simulation</h1>
.sort(null); // Do not sort, keep original order

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);
// For the initial color and non-global colors, show them all
let displayColors;
if (allColors.length === 1 && allColors[0] === "#87cefa") {
displayColors = allColors;
} else {
// For propagated colors, show only the most recent MAX_COLORS from global tracking
const visibleColors = allColors.filter(color => globalColors.includes(color));
displayColors = visibleColors.slice(-MAX_COLORS);
// If no colors would be shown, keep the node's existing colors
if (displayColors.length === 0) {
displayColors = allColors;
}
}

const arcs = pieGenerator(displayColors);
nodeGroup.selectAll("path").remove(); // Clear existing paths before drawing
Expand Down

0 comments on commit 0219f22

Please sign in to comment.