Skip to Content
DocsπŸ“š ⏐ APIGraphCanvas

API

GraphCanvasΒ 

NameTypeDefault
themeTheme

Theme to use for the graph.

lightTheme
cameraModeCameraMode

Type of camera interaction.

'pan'
maxDistancenumber

The maximum distance for the camera.

50000
minDistancenumber

The minimum distance for the camera.

1000
minZoomnumber

The minimum zoom level for the camera.

1
maxZoomnumber

The maximum zoom level for the camera.

100
lassoTypeLassoType

The type of lasso selection.

'none'
childrenReactNode

Children to render in the canvas. Useful for things like lights.

glOptionsobject

Ability to extend Canvas gl options. For example { preserveDrawingBuffer: true }

{}
onLasso(selections: string[]) => void

When the canvas had a lasso selection.

onLassoEnd(selections: string[]) => void

When the canvas had a lasso selection end.

onCanvasClick(event: MouseEvent) => void

When the canvas was clicked but didn’t hit a node/edge.

aggregateEdgesboolean

Whether to aggregate edges with the same source and target.

layoutTypeLayoutTypes

Type of layout.

'forceDirected2d'
selectionsstring[]

List of ids that are selected.

[]
activesstring[]

List of ids that are active.

[]
collapsedNodeIdsstring[]

List of node ids that are collapsed.

[]
animatedboolean

Animate or not the graph positions.

true
nodesGraphNode[]

Nodes to pass to the graph.

edgesGraphEdge[]

Edges to pass to the graph.

contextMenu(event: ContextMenuEvent) => ReactNode

Context menu element.

sizingTypeSizingType

Type of sizing for nodes.

'default'
labelTypeLabelVisibilityType

Type of visibility for labels.

'auto'
edgeLabelPositionEdgeLabelPosition

Place of visibility for edge labels.

'inline'
edgeArrowPositionEdgeArrowPosition

Placement of edge arrows.

'end'
edgeInterpolationEdgeInterpolation

Shape of edge.

'linear'
labelFontUrlstring

Font of label, same as troika-three-text. The URL of a custom font file to be used. Supported font formats are: .ttf, .otf, .woff (.woff2 is not supported). If not provided, the Roboto font is loaded from the Google Fonts CDN.

sizingAttributestring

Attribute based sizing property.

defaultNodeSizenumber

The default size to size nodes to.

7
minNodeSizenumber

When using sizing attributes, the min size a node can be.

5
maxNodeSizenumber

When using sizing attributes, the max size a node can be.

15
clusterAttributestring

Attribute used for clustering.

disabledboolean

Disable interactions or not.

draggableboolean

Allow dragging of nodes.

false
constrainDraggingboolean

Constrain dragging to the cluster bounds.

false
renderNodeNodeRenderer

Render a custom node

onRenderClusterClusterRenderer

Render a custom cluster

layoutOverridesLayoutOverrides

Advanced overrides for the layout.

onNodeClick(node: InternalGraphNode, props?: CollapseProps | undefined, event?: ThreeEvent<MouseEvent> | undefined) => void

When a node was clicked.

onNodeDoubleClick(node: InternalGraphNode, event: ThreeEvent<MouseEvent>) => void

When a node was double clicked.

onNodeContextMenu(node: InternalGraphNode, props?: NodeContextMenuProps | undefined) => void

When a node context menu happened.

onNodePointerOver(node: InternalGraphNode, event: ThreeEvent<PointerEvent>) => void

When node got a pointer over.

onNodePointerOut(node: InternalGraphNode, event: ThreeEvent<PointerEvent>) => void

When node lost pointer over.

onNodeDragged(node: InternalGraphNode) => void

Triggered after a node was dragged.

onClusterDragged(cluster: ClusterEventArgs) => void

Triggered after a cluster was dragged.

onEdgeContextMenu(edge?: InternalGraphEdge | undefined) => void

When a edge context menu happened.

onEdgeClick(edge: InternalGraphEdge, event?: ThreeEvent<MouseEvent> | undefined) => void

When an edge was clicked.

onEdgePointerOver(edge: InternalGraphEdge, event?: ThreeEvent<PointerEvent> | undefined) => void

When edge got a pointer over.

onEdgePointerOut(edge: InternalGraphEdge, event?: ThreeEvent<PointerEvent> | undefined) => void

When edge lost pointer over.

onClusterClick(cluster: ClusterEventArgs, event: ThreeEvent<MouseEvent>) => void

When a cluster was clicked.

onClusterPointerOver(cluster: ClusterEventArgs, event: ThreeEvent<PointerEvent>) => void

When a cluster receives a pointer over event.

onClusterPointerOut(cluster: ClusterEventArgs, event: ThreeEvent<PointerEvent>) => void

When cluster receives a pointer leave event.

Last updated on