Needs graph view

VS Code Stable

ubCode includes a graph view feature that visualizes the relationships between needs in your project. This view helps you understand how different needs are connected and can assist in navigating complex projects. Each need is a card with its id, title and fields. The graph is interactive: you can zoom and pan, click a need to centre the graph on it, and right-click a need to centre on it or go to its source. A need that links to needs the graph does not show carries a +N pill (Links to needs not shown).

To open the Needs graph view, either:

  • use the command palette in your editor (Ctrl+Shift+P) and select “ubCode: Open needs graph view”, then enter your desired need ID to center the graph on.

  • click the eye icon, for a need in the ubCode needs index tree view.

  • Right click on the id option of a need in an RST file and select “Show ubcode need ID in the graph view”.

Depth

The graph shows the needs within a number of links of the need it is centred on, following links in both directions. The ▼ and ▲ buttons in the toolbar set that depth, from 0 (the need alone) to 5; it starts at 1, and the choice is remembered for the workspace. Every link between two needs on the graph is drawn, not only the links followed from the centre to reach them, with three exceptions: a link of a summary link type (Link types) is drawn only where it touches the centre, a link to a part of a need is not drawn, and a :need: reference in an imported need’s content is drawn only where the graph followed it from the need it names.

Large graphs

A need with many links can reach thousands of needs within the depth. The graph then shows only the nearest ones (by number of links from the centre, then by id), up to the ubcode.needViewer.maxNeeds setting (200 by default, from 1 to 2000), and a note under the graph says how many it shows of how many. The needs the limit left out are counted on the needs they link to (see Links to needs not shown). Changing the setting redraws the graph on screen.

Layout and zoom

The graph is laid out top to bottom or left to right, whichever shows the whole graph larger in the pane: links into a need mostly come from above it (or from its left), links out of it mostly go below it (or to its right); a cycle of links needs one of them the other way. Resizing the pane chooses again, until you pan, zoom or drag a card; after that the graph stays as you left it until you press Fit. A card you dragged stays where you put it: no new layout undoes it, not after Fit either.

A need with more than 6 needs linked to it by one link type, in one direction, and to nothing else on the graph, draws those needs as a block of columns, in id order, rather than as one long row, when that shows the graph larger (on a graph of more than 400 links, not counting a need’s links to itself, as far as an estimate can tell): their links share one line from the need to the block, which branches to each of them, and the link type is written once, on that line. A resize to a pane of another shape decides this again for that pane, until you pan, zoom or drag a card. A need linked to it by two link types, or to a second need on the graph, keeps its own place and its own link; so do the need at the centre and a dead link’s “no such need” card, which are never put in a block.

The graph opens fitted to the pane, unless its titles would then be smaller than 7 pixels on screen: it then opens at a readable zoom, centred on the need at the centre. The Fit all to view button in the toolbar shows the whole graph, however small, in the direction that fits the pane at that moment (unless you dragged a card); a click on the toolbar never reaches the card beneath it.

Each link is drawn around the cards between its two needs, with its link type where the layout left room for it. While you drag a card (or a dead link’s card) away from its place, its links are drawn straight. The same graph is laid out the same way however you reach it: opened, clicked, through the back and forward arrows, or when VS Code restores the panel.

Change requests

A change request links to every need its impact analysis reached, so it would appear next to each of them and bury the trace. The graph therefore does not, by default, reach change requests back from the needs they name: a change request is on the graph only where a need on it links to it, and then its links to the other needs there are drawn. The CR button in the toolbar, next to the back and forward arrows, turns them on; while they are hidden, its tooltip names the change requests it skipped while following links back from the needs it shows. The choice is remembered for the workspace, like the depth.

While change requests are hidden, opening one shows the need it is anchored on instead, and a note under the graph names both (on its own line, above the note on a large graph, when both apply); turning CR on then shows the change request itself. A change request with no anchor, or anchored only on other change requests or on needs that no longer exist, gives an empty graph that says it has no anchor need to show instead.

Needs Graph View

Needs Graph View