Graph

Um diagrama de rede interativo em um canvas: layouts de forças, em grupos e em camadas, panorâmica e zoom, navegação por teclado e uma lista de nós.

Disponível em
  • Angular: disponível
  • Vue: disponível
  • React: disponível
  • React Native: ainda não disponível

Uso

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

Importação

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

Referência da API

SoneGraphCanvasDirectiveDiretiva

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.

Seletor
canvas[soneGraphCanvas]
Exportado como
soneGraphCanvas
Inputs
NomeTipo Padrão
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
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.

Seletor
sone-graph-card
Inputs
NomeTipo Padrão
anchorGraphSceneAnchor | nullnull
headingobrigatóriostring—
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
NomeTipo
openvoid

SoneGraphCardTemplateDirectiveDiretiva

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

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

Seletor
sone-graph
Inputs
NomeTipo Padrão
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
selectedbidirecional

The selected node id.

string | nullnull
showListbidirecional

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

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

Seletor
sone-graph-controls
Inputs
NomeTipo Padrão
labelobrigatório

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

SoneGraphLegendDirectiveDiretiva

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

Seletor
[soneGraphLegend]