Graph

キャンバス上のインタラクティブなネットワーク図。力学・クラスター・レイヤーの各レイアウト、パンとズーム、キーボード操作、ノード一覧に対応します。

対応フレームワーク
  • Angular: 対応
  • Vue: 対応
  • React: 対応
  • React Native: 未対応

使い方

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

インポート

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

API リファレンス

SoneGraphCanvasDirectiveディレクティブ

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.

セレクター
canvas[soneGraphCanvas]
エクスポート名
soneGraphCanvas
入力
名前型 デフォルト
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
出力
名前型
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

SoneGraphCardComponentコンポーネント

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.

セレクター
sone-graph-card
入力
名前型 デフォルト
anchorGraphSceneAnchor | nullnull
heading必須string—
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
出力
名前型
openvoid

SoneGraphCardTemplateDirectiveディレクティブ

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

セレクター
ng-template[soneGraphCard]

SoneGraphComponentコンポーネント

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.

セレクター
sone-graph
入力
名前型 デフォルト
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
selected双方向

The selected node id.

string | nullnull
showList双方向

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

booleanfalse
出力
名前型
nodeOpenstring
nodeHoverstring | null
zoomChange

Zoom in percent of the fitted view.

number

SoneGraphControlsComponentコンポーネント

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

セレクター
sone-graph-controls
入力
名前型 デフォルト
label必須

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>{}
出力
名前型
zoomInvoid
zoomOutvoid
fitvoid
listChangeboolean

SoneGraphLegendDirectiveディレクティブ

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

セレクター
[soneGraphLegend]