Graph

Un diagramme de réseau interactif sur un canevas : dispositions par forces, par groupes et en couches, déplacement et zoom, navigation au clavier et liste des nœuds.

Disponible pour
  • Angular: disponible
  • Vue: disponible
  • React: disponible
  • React Native: pas encore disponible

Utilisation

PeopleMeetingsNotesDocuments48 nodes · 70 links
Arrow keys move to the nearest node, Page Up and Page Down step through all of them, Enter opens the selected one, Escape clears the selection. Plus and minus zoom, 0 fits the view.
Selected: none · Opened: none

Importation

ts
import {
  SoneGraphCanvasDirective,
  SoneGraphCardComponent,
  SoneGraphCardTemplateDirective,
  SoneGraphComponent,
  SoneGraphControlsComponent,
  SoneGraphLegendDirective,
} from "@surface-one/angular/graph";

Référence de l’API

SoneGraphCanvasDirectiveDirective

The canvas part of `<sone-graph>`: binds a `GraphScene` to the framework-free `SoneGraphEngine`. The engine (and with it `getContext`, `matchMedia` and the observers) is created after the first render, so the directive is SSR-safe. Use it on its own when you build the scene yourself.

Sélecteur
canvas[soneGraphCanvas]
Exporté sous
soneGraphCanvas
Inputs
NomType Par défaut
scene

The positioned nodes, edges, columns and clusters to draw.

GraphSceneEMPTY_GRAPH_SCENE
tones

Tone name → custom property (or `"--a, --b"` fallback chain).

Readonly<Record<string, string>>{}
selectedKeystring | nullnull
Outputs
NomType
nodePick

The user picked a node with the pointer or keyboard; `null` clears.

string | null
nodeOpen

Double-click, or Enter on the picked node.

string
nodeHoverstring | null
zoomChange

Zoom in percent of the fitted view.

number
anchor

Screen position of the hovered (else the picked) node, for a floating card.

GraphSceneAnchor | null

SoneGraphCardComponentComposant

The node card of a graph. Floating, it sits above (or below, near the top edge) the node at `anchor` and ignores the pointer; `pinned`, it docks to the bottom-left corner and offers the `openLabel` action. `data-node-x` / `data-node-y` expose the node's on-screen position for tests.

Sélecteur
sone-graph-card
Inputs
NomType Par défaut
anchorGraphSceneAnchor | nullnull
headingobligatoirestring—
metastring""
tone

Any CSS colour for the swatch, e.g. `var(--graph-note)`.

string"var(--graph-ink)"
squarebooleanfalse
pinnedbooleanfalse
openLabel

The text of the open action of a pinned card; `null` hides it.

string | nullnull
body

Replaces the heading and meta lines.

TemplateRef<unknown> | nullnull
bodyContextunknownnull
Outputs
NomType
openvoid

SoneGraphCardTemplateDirectiveDirective

`<ng-template soneGraphCard let-node let-pinned="pinned">` replaces the body of the node card (title + meta); the card's position and its Open action stay.

Sélecteur
ng-template[soneGraphCard]

SoneGraphComponentComposant

An interactive network diagram on a Canvas 2D: `force`, `clusters` (communities with hulls) or `layers` (one column per `layer`) layouts; drag to pan, wheel to zoom at the cursor, click to select and highlight the neighbourhood, double-click or Enter to open; full keyboard support with spoken selections, an optional node list, and colours read from the theme tokens.

Sélecteur
sone-graph
Inputs
NomType Par défaut
dataSoneGraphData | nullnull
layoutSoneGraphLayout"force"
tones

Extra or overriding tones: tone name → custom property, or a `"--a, --b"` fallback chain.

SoneGraphTones{}
sizing

The radius range node sizes are mapped onto.

SoneGraphSizingSONE_GRAPH_SIZING
layerLabels

Column titles of the `layers` layout, by `layer`.

Readonly<Record<number, string>>{}
clusterLabel

The title of a `clusters` community; return `""` for none.

(cluster: SoneGraphCluster) => stringsoneGraphClusterLabel
describe

The meta line of a node's card, its list entry and its announcement.

(node: SoneGraphNode, info: SoneGraphNodeInfo) => stringsoneGraphDescribe
label

The canvas's accessible name; defaults to the node and link counts.

string | nullnull
summary

The counts in the controls panel; `""` hides them.

string | nullnull
labelsPartial<SoneGraphLabels>{}
layoutStrategy

Computes the layout elsewhere (a Web Worker); `null` lays out on the main thread.

SoneGraphLayoutStrategy | nullnull
listToggle

Shows the List button in the controls.

booleantrue
selectedbidirectionnel

The selected node id.

string | nullnull
showListbidirectionnel

Renders the nodes as a list of buttons under the canvas.

booleanfalse
Outputs
NomType
nodeOpenstring
nodeHoverstring | null
zoomChange

Zoom in percent of the fitted view.

number

SoneGraphControlsComponentComposant

The overlay toolbar of a graph: an info panel (legend, counts — projected) and Fit / zoom out / zoom readout / zoom in, plus an optional list toggle. One tab stop; arrow keys, Home and End move between the buttons (WAI-ARIA toolbar).

Sélecteur
sone-graph-controls
Inputs
NomType Par défaut
labelobligatoire

Accessible name of the toolbar.

string—
zoomPct

The zoom readout, in percent of the fitted view.

number100
list

`true` / `false` shows the list toggle pressed / not pressed; `null` hides it.

boolean | nullnull
labelsPartial<SoneGraphControlsLabels>{}
Outputs
NomType
zoomInvoid
zoomOutvoid
fitvoid
listChangeboolean

SoneGraphLegendDirectiveDirective

Marks content projected into the controls' info panel (a legend, counts).

Sélecteur
[soneGraphLegend]