Ga naar hoofdinhoud

CnRelationshipGraph

Lightweight SVG relationship graph. For surfacing entity-to-entity links — related terms, dependency chains, account → contacts. Two built-in layouts (radial, grid) plus manual for when consumers compose a layout engine externally.

Not a force-directed graph layout engine — pulling in a real layout solver is a non-goal. For dense graphs that need force-directed positioning, run a layout engine (e.g. d3-force, dagre) and pass the resulting x/y per node under layout="manual".

Try it

<CnRelationshipGraph
title="Related terms"
:nodes="[
{ id: 'core', label: 'Sociology', isRoot: true },
{ id: 'a', label: 'Sociometry' },
{ id: 'b', label: 'Demography' },
{ id: 'c', label: 'Anthropology' },
]"
:edges="[
{ source: 'core', target: 'a', label: 'subfield' },
{ source: 'core', target: 'b' },
{ source: 'core', target: 'c' },
]"
@node-click="openTerm" />

Layouts

layoutPositioning
radialRoot in centre, others evenly on the perimeter.
gridNxN grid by input order.
manualHonour each node's x / y.

Props

PropTypeDefaultDescription
nodesArray<{id,label?,isRoot?,colour?,radius?,x?,y?}>[]Node list.
edgesArray<{id?,source,target,label?,colour?,dashed?}>[]Edge list. Unknown source/target ids drop silently.
layout'radial'|'grid'|'manual''radial'Layout strategy.
sizeNumber400SVG viewBox size (square).
nodeRadiusNumber18Default node radius (px).
nodeColor / rootColorStringbrand defaultsDefault circle fills.
edgeColorString'#999'Default edge stroke colour.
edgeWidthNumber1.5Edge stroke width.
strokeColorString'#fff'Node stroke colour.
title / descriptionString''Optional header.
ariaLabelString'Relationship graph'SVG aria-label.
legendArray<{label,colour}>[]Optional legend rendered below the SVG.

Events

EventPayloadDescription
node-clickoriginal nodeClicked node row. Resolved (positioned) coords are dropped from the payload.