From 794b8f7caaf7aca9c6ce58702e605263e3bdc171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=9B=E4=BA=A5?= Date: Thu, 18 Jun 2026 16:58:17 +0800 Subject: [PATCH] fix(visualization): use #graph-svg selector instead of bare svg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit d3.select("svg") returns the first in document order, which is a 16px legend icon — not the main graph canvas. This caused the entire force graph to render inside the tiny legend swatch while the full-screen canvas stayed empty. Fix: target #graph-svg by id in both template copies. Add id="graph-svg" to the aggregated-view template's element (it was missing). Regression tests verify both full and community templates use the id selector and contain no bare d3.select("svg"). Closes #523 --- code_review_graph/visualization.py | 6 ++--- tests/test_visualization.py | 36 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/code_review_graph/visualization.py b/code_review_graph/visualization.py index c78b5735..7ca5bd13 100644 --- a/code_review_graph/visualization.py +++ b/code_review_graph/visualization.py @@ -856,7 +856,7 @@ def generate_html( } function hideTooltip() { tooltip.classList.remove("visible"); } var W = innerWidth, H = innerHeight; -var svg = d3.select("svg").attr("viewBox", [0, 0, W, H]); +var svg = d3.select("#graph-svg").attr("viewBox", [0, 0, W, H]); var gRoot = svg.append("g"); var currentTransform = d3.zoomIdentity; var zoomBehavior = d3.zoom() @@ -1605,7 +1605,7 @@ def generate_html(
- +