diff --git a/hugo-site/static/js/small-world-comparison.js b/hugo-site/static/js/small-world-comparison.js index d05dcf98..44a49a1b 100644 --- a/hugo-site/static/js/small-world-comparison.js +++ b/hugo-site/static/js/small-world-comparison.js @@ -258,10 +258,12 @@ waitForD3().then(() => { } statsSvg.selectAll('*').remove(); - // Create SVG with fixed dimensions + // Define dimensions first const margin = {top: 30, right: 60, bottom: 40, left: 60}; - const width = 245 - margin.left - margin.right; - const height = 245 - margin.top - margin.bottom; + const svgWidth = 245; + const svgHeight = 245; + const width = svgWidth - margin.left - margin.right; + const height = svgHeight - margin.top - margin.bottom; // Clear previous content if (statsSvg) { diff --git a/hugo-site/static/js/small-world-scale.js b/hugo-site/static/js/small-world-scale.js index 4c5d6aee..b85f1c23 100644 --- a/hugo-site/static/js/small-world-scale.js +++ b/hugo-site/static/js/small-world-scale.js @@ -209,7 +209,7 @@ waitForD3().then(() => { } // Use pre-computed adjacency list - const neighbors = adjacencyLists.get(node); + const neighbors = adjacencyLists.get(node) || []; for (const neighbor of neighbors) { if (!visited.has(neighbor.index)) { visited.add(neighbor.index); @@ -413,7 +413,9 @@ waitForD3().then(() => { const btn = document.getElementById('scalePlayPauseBtn'); const icon = btn.querySelector('i'); icon.className = 'fas fa-play'; - cancelAnimationFrame(animationFrameId); + if (animationFrame) { + cancelAnimationFrame(animationFrame); + } } }