Graph WebviewAn interactive dependency graph visualizer built for VS Code webviews. It renders a force-directed node-link diagram from a typed Features
Usage
Pass the return value directly to API
|
| Field | Type | Description |
|---|---|---|
nodes |
GraphNode[] |
List of nodes to render |
links |
GraphLink[] |
List of directed edges |
GraphNode
| Field | Type | Description |
|---|---|---|
id |
string |
Unique identifier — used to match link sources/targets |
label |
string |
Display text shown inside the node rect |
type |
string |
Controls colour and sidebar filter category (see below) |
GraphLink
| Field | Type | Description |
|---|---|---|
source |
string |
id of the source (importing) node |
target |
string |
id of the target (imported) node |
Links whose source or target don't match any node id are silently ignored.
Node Types & Colours
| Type | Colour |
|---|---|
component |
Blue |
handler |
Purple |
analytics |
Green |
datalayer |
Amber |
type |
Red |
util |
Sky |
| (anything else) | Grey |
Any string is accepted as a type — unknown values fall back to grey and won't appear in the sidebar filter list.
Relationship Colours
When a node is selected, connected nodes are highlighted by relationship:
| Relationship | Colour | Meaning |
|---|---|---|
| Parent | Purple | Nodes that import the selection |
| Sibling | Amber | Nodes that share a parent |
| Child | Green | Nodes the selection imports |
Content Security Policy
The webview uses this CSP:
default-src 'none';
script-src 'unsafe-inline' https://cdnjs.cloudflare.com;
style-src 'unsafe-inline';
D3 v7 is loaded from cdnjs.cloudflare.com. No other external resources are fetched.
Dependencies
| Library | Version | Source |
|---|---|---|
| D3.js | 7.8.5 | cdnjs.cloudflare.com (CDN) |
No build step required — everything is inlined into the returned HTML string.
How Arrows Work
Earlier versions drew link <line> elements between node centres, causing arrowheads to be hidden underneath the target rectangle. The current version uses rectEdgePoint() to compute where each line should start and end on the rectangle's boundary:
source centre ──► source rect edge ──────────────► target rect edge ──► arrowhead
A 4px gap is added between the arrowhead tip and the node border so arrows never appear to touch or clip.