Skip to content

Components

GraphExplorer

ReactFlow-based interactive graph renderer. Best for small-to-medium graphs (up to ~500 nodes).

tsx
import { GraphExplorer } from '@trustin/txgraph'

Props

PropTypeDefaultDescription
nodesTxNode[]requiredArray of graph nodes
edgesTxEdge[]requiredArray of graph edges
statsTxGraphStatsOptional stats (shown in panel)
loadingbooleanfalseShow full-screen loading overlay
expandingNodestring | nullnullAddress of node currently being expanded (shows spinner)
selectedAddressstring | nullnullHighlight the path from root to this address
onNodeSelect(node: TxNode | null) => voidCalled when user clicks a node (or background)
onNodeExpand(address: string) => voidCalled when user clicks the + expand button
onNodeDelete(address: string) => voidCalled when user clicks the delete button

Layout

The graph uses Dagre for automatic left-to-right hierarchical layout. Nodes are arranged by transaction depth. Layout is recomputed whenever nodes or edges change.

Selection & Path Highlighting

When selectedAddress is set, the component:

  1. Finds all paths from the root node to the selected address (DFS with backtracking)
  2. Highlights nodes and edges on any path
  3. Dims all other nodes and edges (opacity 0.25)

Node Appearance

StateVisual
Root nodeBlue border + glow
High riskRed border + red background
Medium riskYellow border + yellow background
Low riskGreen border + green background
Unknown riskGray border
Stopped nodeDashed border + warning icon
SelectedBlue glow ring
Dimmed (not on path)25% opacity
ExpandingSpinner overlay

GraphExplorerSigma

Sigma.js + WebGL-based renderer. Best for large graphs (500+ nodes). Uses canvas for labels, WebGL for nodes/edges.

tsx
import { GraphExplorerSigma } from '@trustin/txgraph'

Props

Same props as GraphExplorer — both components implement GraphExplorerProps.

Interactions

ActionResult
Click nodeonNodeSelect(node)
Click backgroundonNodeSelect(null)
Double-click nodeonNodeExpand(address)
Right-click nodeonNodeDelete(address)
ScrollZoom in/out
DragPan

Built-in Controls

The Sigma renderer includes floating controls:

  • + / — Zoom in/out
  • — Fit all nodes in view

Layout

Uses a custom depth-based left-to-right layout:

  • X position = depth × 3.5 (graph coordinates)
  • Y position = evenly spaced within each depth level
  • No overlap guaranteed

Camera

On mount, the camera auto-fits to show all nodes at a comfortable ~38px radius. The camera ratio adapts to graph size.

Released under the MIT License.