Relationship Graph
ProA network of nodes and links in two layouts — a deterministic force layout and a chord diagram — with neighbour highlighting, one-tab-stop keyboard roving and a link table. In-house layouts, no dependencies. Pure SVG.
import { SvRelationshipGraphComponent } from '@styloviz-pro/charts/relationship-graph';Demo & usage
Basic usage
Usage example — open the gallery for the full interactive demo.
An interactive demo for this component lives in the gallery.
Open live demoMore examples
Chord layout
Select a node
Async states
When to use
Who connects to whom: service dependencies, team collaboration, referral networks. Chord: the volume between a handful of groups, in both directions. For flow through ordered stages (budget → department → line), use a Sankey.
Async states
- loading
- empty
- error
- retry
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| loading | boolean | false | True while the graph is being fetched. |
| error | SvDataError | string | null | null | Load failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`. |
| emptyMessage | string | 'No data to plot' | Copy for the no-data state. |
| filtered | boolean | false | True when the emptiness is caused by a filter rather than an empty set. |
| nodes | readonly SvGraphNode[] | [] | Nodes: `{ id, label, group?, value? }`. |
| links | readonly SvGraphLink[] | [] | Relationships: `{ source, target, value?, label? }`. A missing value means 1. |
| layout | SvRelationshipGraphLayout | 'force' | `'force'` (deterministic force-directed) or `'chord'` (arcs and ribbons). |
| width | number | 560 | Drawing width in SVG units; the SVG scales to its container. |
| height | number | 360 | Drawing height in pixels. |
| title | string | '' | Chart title rendered above the drawing. |
| ariaLabel | string | '' | Accessible name override. Falls back to a generated summary. |
| customClass | string | '' | Extra CSS classes applied to the root wrapper. |
| locale | string | svLocale() | BCP 47 locale for numbers and plural forms. |
Outputs
| Event | Payload type | Description |
|---|---|---|
| retry | void | The host should re-run the failed load. |
| nodeSelect | SvGraphNodeSelectEvent | Emitted when a node is clicked or activated with Enter/Space: the node and its neighbours. |
Wire it to your API
This component is headless about transport: it renders what you give it and reports what the user asks for. Nothing below requires @styloviz/data — drive it from whatever you already use.
Template
Bound to the names this component actually exposes.
Host class
Drive the three async inputs from your own fetch.
This component does not emit a query, so it renders what you give it. Call `load()` on your own trigger and bind `nodes`, `loading` and `error`. Set `filtered` when a search or filter is active. It is the difference between "you have no orders" and "no orders match this filter" — telling a customer with 4,000 orders the first one reads as a bug. Normalize failures with `toSvDataError()` from `@styloviz/core`. It derives `retryable` from the status, so a 404 does not get a "Try again" button that can only fail again.
Full walkthrough: Connecting to a backend.
Customization & theming
`layout`: `force` (default) or `chord`. Node size from `value` (square-root scale); link width from `value` (a missing value counts as 1). `width` / `height` of the drawing. Links to unknown nodes, self-links and NaN, negative or zero values are left out and named in a notice under the plot.
Best practices
Do: Group nodes (`group`) — the legend and the chord layout both read it, and the colour is backed by the group name in every node’s label. Do: Keep it to tens of nodes. Past ~150 the force layout still runs (about 45 ms) but the picture stops being readable; filter first. Don't: Rely on a link to an id you did not send — it is dropped and named under the plot, never drawn to nowhere. Tip: The same input always draws the same picture, so server-rendered and browser views agree and screenshots are stable.
Accessibility
One tab stop; arrow keys move between nodes in label order, Home/End to the ends, Enter or Space emits `nodeSelect`, Escape clears the highlight. A hidden hint says so. Each node is named with its group and its connections: “Chen, Engineering: 3 connections — Ana, Dev, Eli”. Hover or focus dims everything but the node, its links and its neighbours — opacity only, no motion under reduced-motion. The data table lists every drawn link (“Source → Target”, value, relationship), and the chart a11y module can put it on screen.
Feedback on Relationship Graph
Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.