Graph

Un diagramma di rete interattivo su canvas: layout a forze, a cluster e a livelli, panoramica e zoom, navigazione da tastiera e un elenco dei nodi.

Disponibile in
  • Angular: disponibile
  • Vue: disponibile
  • React: disponibile
  • React Native: non ancora disponibile

Utilizzo

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

Importazione

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

Riferimento API

SoneGraphCanvasDirectiveDirettiva

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.

Selettore
canvas[soneGraphCanvas]
Esporta come
soneGraphCanvas
Input
NomeTipo Predefinito
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
Output
NomeTipo
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

SoneGraphCardComponentComponente

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.

Selettore
sone-graph-card
Input
NomeTipo Predefinito
anchorGraphSceneAnchor | nullnull
headingobbligatoriostring—
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
Output
NomeTipo
openvoid

SoneGraphCardTemplateDirectiveDirettiva

`<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.

Selettore
ng-template[soneGraphCard]

SoneGraphComponentComponente

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.

Selettore
sone-graph
Input
NomeTipo Predefinito
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
selectedbidirezionale

The selected node id.

string | nullnull
showListbidirezionale

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

booleanfalse
Output
NomeTipo
nodeOpenstring
nodeHoverstring | null
zoomChange

Zoom in percent of the fitted view.

number

SoneGraphControlsComponentComponente

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).

Selettore
sone-graph-controls
Input
NomeTipo Predefinito
labelobbligatorio

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>{}
Output
NomeTipo
zoomInvoid
zoomOutvoid
fitvoid
listChangeboolean

SoneGraphLegendDirectiveDirettiva

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

Selettore
[soneGraphLegend]