Skip to content

Commit 4cf5939

Browse files
committed
fix: search zoom coordinates, rewrite matrix as directory-level drill-down
Search fix: - Use sigma.getNodeDisplayData() + viewportToGraph() for camera zoom instead of raw graph attributes. The ForceAtlas2 coordinates don't map directly to sigma's camera space. - Also fixed double-click zoom using same approach - 100ms delay before camera animate so reducer applies first Matrix rewrite: - Default view now shows directory-to-directory relationships (~15 dirs) instead of 239 files. Actually readable and useful. - Each cell shows the number of imports between directories - Click a directory row to drill into file-level within that directory - Back button to return to directory overview - Cell sizes scale with matrix size for readability - Numbers visible in cells for non-zero values - Hover tooltip shows full paths and import count - Circular dependency detection at both directory and file level
1 parent 9b6f21f commit 4cf5939

4 files changed

Lines changed: 339 additions & 228 deletions

File tree

frontend/src/components/DependencyGraph/GraphView/SearchBar.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,19 @@ export function SearchBar({ onFocusNode }: SearchBarProps) {
4949
// pin this node (parent handles highlight via reducers)
5050
onFocusNode(nodeId)
5151

52-
// zoom camera to node using graph coordinates
53-
const attrs = graph.getNodeAttributes(nodeId)
54-
// small delay so the reducer applies before camera moves
52+
// zoom: get the node's position in sigma's coordinate system
53+
// nodeDisplayData gives us the rendered position which we can use directly
5554
setTimeout(() => {
56-
sigma.getCamera().animate(
57-
{ x: attrs.x as number, y: attrs.y as number, ratio: 0.2 },
58-
{ duration: 500 }
59-
)
60-
}, 50)
55+
const displayData = sigma.getNodeDisplayData(nodeId)
56+
if (displayData) {
57+
// convert viewport pixel coords to graph coords for the camera
58+
const graphCoords = sigma.viewportToGraph({ x: displayData.x, y: displayData.y })
59+
sigma.getCamera().animate(
60+
{ x: graphCoords.x, y: graphCoords.y, ratio: 0.2 },
61+
{ duration: 500 }
62+
)
63+
}
64+
}, 100)
6165

6266
setQuery('')
6367
setResults([])

frontend/src/components/DependencyGraph/GraphView/index.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,14 @@ function Interactions({
107107
onSelectFile?.(node)
108108
},
109109
doubleClickNode: ({ node }) => {
110-
const graph = sigma.getGraph()
111-
if (!graph.hasNode(node)) return
112-
const attrs = graph.getNodeAttributes(node)
113-
sigma.getCamera().animate(
114-
{ x: attrs.x as number, y: attrs.y as number, ratio: 0.12 },
115-
{ duration: 400 }
116-
)
110+
const displayData = sigma.getNodeDisplayData(node)
111+
if (displayData) {
112+
const graphCoords = sigma.viewportToGraph({ x: displayData.x, y: displayData.y })
113+
sigma.getCamera().animate(
114+
{ x: graphCoords.x, y: graphCoords.y, ratio: 0.12 },
115+
{ duration: 400 }
116+
)
117+
}
117118
},
118119
clickStage: () => {
119120
// clear pinned state when clicking empty space

0 commit comments

Comments
 (0)