Skip to Content
Docs📚 ⏐ APIGraphCanvas

API

GraphCanvas

PropDescriptionDefault
themeTheme to use for the graph.
Theme
{ canvas: { background: '#fff' }, no...
cameraModeType of camera interaction.
CameraMode
pan
maxDistanceThe maximum distance for the camera. Default is 50000.
number
minDistanceThe minimum distance for the camera. Default is 1000.
number
lassoTypeThe type of lasso selection.
LassoType
none
childrenChildren to render in the canvas. Useful for things like lights.
ReactNode
glOptionsAbility to extend Cavas gl options. For example { preserveDrawingBuffer: true }
Object
{}
onLassoWhen the canvas had a lasso selection.
(selections: string[]) => void
onLassoEndWhen the canvas had a lasso selection end.
(selections: string[]) => void
onCanvasClickWhen the canvas was clicked but didn't hit a node/edge.
(event: MouseEvent) => void
aggregateEdgesWhether to aggregate edges with the same source and target.
boolean
layoutTypeType of layout.
LayoutTypes
forceDirected2d
selectionsList of ids that are selected.
string[]
activesList of ids that are active.
string[]
collapsedNodeIdsList of node ids that are collapsed.
string[]
animatedAnimate or not the graph positions.
boolean
true
nodes *Nodes to pass to the graph.
GraphNode[]
edges *Edges to pass to the graph.
GraphEdge[]
contextMenuContext menu element.
(event: ContextMenuEvent) => ReactNode
sizingTypeType of sizing for nodes.
SizingType
default
labelTypeType of visibility for labels.
LabelVisibilityType
auto
edgeLabelPositionPlace of visibility for edge labels.
EdgeLabelPosition
edgeArrowPositionPlacement of edge arrows.
EdgeArrowPosition
edgeInterpolationShape of edge.
EdgeInterpolation
labelFontUrlFont 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) Default: The Roboto font loaded from Google Fonts CDN
string
sizingAttributeAttribute based sizing property.
string
defaultNodeSizeThe default size to size nodes to. Default is 7.
number
7
minNodeSizeWhen using sizing attributes, the min size a node can be.
number
5
maxNodeSizeWhen using sizing attributes, the max size a node can be.
number
15
clusterAttributeAttribute used for clustering.
string
disabledDisable interactions or not.
boolean
draggableAllow dragging of nodes.
boolean
constrainDraggingConstrain dragging to the cluster bounds. Default is `false`.
boolean
renderNodeRender a custom node
NodeRenderer
onRenderClusterRender a custom cluster
ClusterRenderer
layoutOverridesAdvanced overrides for the layout.
LayoutOverrides
onNodeClickWhen a node was clicked.
(node: InternalGraphNode, props?: CollapseProps, event?: ThreeEvent<MouseEvent>) => void
onNodeDoubleClickWhen a node was double clicked.
(node: InternalGraphNode, event: ThreeEvent<MouseEvent>) => void
onNodeContextMenuWhen a node context menu happened.
(node: InternalGraphNode, props?: NodeContextMenuProps) => void
onNodePointerOverWhen node got a pointer over.
(node: InternalGraphNode, event: ThreeEvent<PointerEvent>) => void
onNodePointerOutWhen node lost pointer over.
(node: InternalGraphNode, event: ThreeEvent<PointerEvent>) => void
onNodeDraggedTriggered after a node was dragged.
(node: InternalGraphNode) => void
onClusterDraggedTriggered after a cluster was dragged.
(cluster: ClusterEventArgs) => void
onEdgeContextMenuWhen a edge context menu happened.
(edge?: InternalGraphEdge) => void
onEdgeClickWhen an edge was clicked.
(edge: InternalGraphEdge, event?: ThreeEvent<MouseEvent>) => void
onEdgePointerOverWhen edge got a pointer over.
(edge: InternalGraphEdge, event?: ThreeEvent<PointerEvent>) => void
onEdgePointerOutWhen edge lost pointer over.
(edge: InternalGraphEdge, event?: ThreeEvent<PointerEvent>) => void
onClusterClickWhen a cluster was clicked.
(cluster: ClusterEventArgs, event: ThreeEvent<MouseEvent>) => void
onClusterPointerOverWhen a cluster receives a pointer over event.
(cluster: ClusterEventArgs, event: ThreeEvent<PointerEvent>) => void
onClusterPointerOutWhen cluster receives a pointer leave event.
(cluster: ClusterEventArgs, event: ThreeEvent<PointerEvent>) => void
ref
Ref<GraphCanvasRef>
Last updated on