Graph
Interaktywny diagram sieci na kanwie — układy siłowy, klastrowy i warstwowy, przesuwanie i powiększanie, obsługa klawiaturą oraz lista węzłów.
Angular: dostępny Vue: dostępny React: dostępny React Native: jeszcze niedostępny
Użycie
<div class="demo-stack" style="width: 100%">
<sone-segmented [options]="layouts" [(value)]="mode" ariaLabel="Graph layout" />
<sone-graph
style="--sone-graph-height: 460px"
[data]="data"
[layout]="layout()"
[layerLabels]="kinds"
[describe]="describe"
[(selected)]="selected"
(nodeOpen)="opened.set($event)"
>
<span soneGraphLegend class="graph-demo-key">
@for (k of kinds; track k; let i = $index) {
<span><i [style.background]="'var(--graph-' + tones[i] + ')'"></i>{{ k }}</span>
}
</span>
</sone-graph>
<span style="color: var(--text-secondary); font-size: var(--font-size-sm)">
Selected: {{ selected() ?? "none" }} · Opened: {{ opened() ?? "none" }}
</span>
</div>Import
import {
SoneGraphCanvasDirective,
SoneGraphCardComponent,
SoneGraphCardTemplateDirective,
SoneGraphComponent,
SoneGraphControlsComponent,
SoneGraphLegendDirective,
} from "@surface-one/angular/graph";Dokumentacja API
SoneGraphCanvasDirectiveDyrektywa
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.
| Nazwa | Typ | Domyślnie |
|---|---|---|
sceneThe positioned nodes, edges, columns and clusters to draw. | GraphScene | EMPTY_GRAPH_SCENE |
tonesTone name → custom property (or `"--a, --b"` fallback chain). | Readonly<Record<string, string>> | {} |
selectedKey | string | null | null |
| Nazwa | Typ |
|---|---|
nodePickThe user picked a node with the pointer or keyboard; `null` clears. | string | null |
nodeOpenDouble-click, or Enter on the picked node. | string |
nodeHover | string | null |
zoomChangeZoom in percent of the fitted view. | number |
anchorScreen position of the hovered (else the picked) node, for a floating card. | GraphSceneAnchor | null |
SoneGraphCardComponentKomponent
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.
| Nazwa | Typ | Domyślnie |
|---|---|---|
anchor | GraphSceneAnchor | null | null |
headingwymagane | string | — |
meta | string | "" |
toneAny CSS colour for the swatch, e.g. `var(--graph-note)`. | string | "var(--graph-ink)" |
square | boolean | false |
pinned | boolean | false |
openLabelThe text of the open action of a pinned card; `null` hides it. | string | null | null |
bodyReplaces the heading and meta lines. | TemplateRef<unknown> | null | null |
bodyContext | unknown | null |
| Nazwa | Typ |
|---|---|
open | void |
SoneGraphCardTemplateDirectiveDyrektywa
`<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.
SoneGraphComponentKomponent
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.
| Nazwa | Typ | Domyślnie |
|---|---|---|
data | SoneGraphData | null | null |
layout | SoneGraphLayout | "force" |
tonesExtra or overriding tones: tone name → custom property, or a `"--a, --b"` fallback chain. | SoneGraphTones | {} |
sizingThe radius range node sizes are mapped onto. | SoneGraphSizing | SONE_GRAPH_SIZING |
layerLabelsColumn titles of the `layers` layout, by `layer`. | Readonly<Record<number, string>> | {} |
clusterLabelThe title of a `clusters` community; return `""` for none. | (cluster: SoneGraphCluster) => string | soneGraphClusterLabel |
describeThe meta line of a node's card, its list entry and its announcement. | (node: SoneGraphNode, info: SoneGraphNodeInfo) => string | soneGraphDescribe |
labelThe canvas's accessible name; defaults to the node and link counts. | string | null | null |
summaryThe counts in the controls panel; `""` hides them. | string | null | null |
labels | Partial<SoneGraphLabels> | {} |
layoutStrategyComputes the layout elsewhere (a Web Worker); `null` lays out on the main thread. | SoneGraphLayoutStrategy | null | null |
listToggleShows the List button in the controls. | boolean | true |
selecteddwukierunkoweThe selected node id. | string | null | null |
showListdwukierunkoweRenders the nodes as a list of buttons under the canvas. | boolean | false |
| Nazwa | Typ |
|---|---|
nodeOpen | string |
nodeHover | string | null |
zoomChangeZoom in percent of the fitted view. | number |
SoneGraphControlsComponentKomponent
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).
| Nazwa | Typ | Domyślnie |
|---|---|---|
labelwymaganeAccessible name of the toolbar. | string | — |
zoomPctThe zoom readout, in percent of the fitted view. | number | 100 |
list`true` / `false` shows the list toggle pressed / not pressed; `null` hides it. | boolean | null | null |
labels | Partial<SoneGraphControlsLabels> | {} |
| Nazwa | Typ |
|---|---|
zoomIn | void |
zoomOut | void |
fit | void |
listChange | boolean |
SoneGraphLegendDirectiveDyrektywa
Marks content projected into the controls' info panel (a legend, counts).