Graphire is a declarative and unopinionated graph visualization library for React. It supports different layouts to visualize large dynamic networks of nodes and links in both 2D and 3D.
How does it work?
Internally it stores the graph using a bidirectional adjacency list that allows fast insertion, deletion, and iteration. It then exposes a Graph wrapper and two essential hooks: useNode and useLink. Those will help you to update the node and links position in an unopinionated way.
Unopinionated?
It means that you can choose nodes and links to be anything you like: a <circle>/<line> (SVGs), <div>, <canvas>, <mesh>/instanced mesh (ThreeJS with R3F). The exposed hooks will only care for positioning. It will be up to you to decide how to display and style the nodes and links.
Why?
Some graph/network visualization libraries like D3.js are not made to work with React, hence uncomfortable to use. Other libraries are made for React but do not decouple styling from positioning, making it hard to customize. Graphire solves that. And it's fast.
import{useRef}from'react'import{useLink}from'graphire'// Link constLink=(props)=>{const{ source, target, color ='black', ...rest}=propsconstref=useRef()useLink(([x1,y1],[x2,y2])=>{ref.current.setAttribute('x1',x1)ref.current.setAttribute('y1',y1)ref.current.setAttribute('x2',x2)ref.current.setAttribute('y2',y2)},source,target,rest)return(<lineref={ref}x1='0'y1='0'x2='0'y2='0'stroke={color}strokeWidth={1}/>)}
flavioschneider/graphire
What is it?
Graphire is a declarative and unopinionated graph visualization library for React. It supports different layouts to visualize large dynamic networks of nodes and links in both 2D and 3D.
How does it work?
Internally it stores the graph using a bidirectional adjacency list that allows fast insertion, deletion, and iteration. It then exposes a
Graph
wrapper and two essential hooks:useNode
anduseLink
. Those will help you to update the node and links position in an unopinionated way.Unopinionated?
It means that you can choose nodes and links to be anything you like: a
<circle>
/<line>
(SVGs),<div>
,<canvas>
,<mesh>
/instanced mesh (ThreeJS with R3F). The exposed hooks will only care for positioning. It will be up to you to decide how to display and style the nodes and links.Why?
Some graph/network visualization libraries like D3.js are not made to work with React, hence uncomfortable to use. Other libraries are made for React but do not decouple styling from positioning, making it hard to customize. Graphire solves that. And it's fast.
Documentation
Examples
Basic Usage:
Node
andLink
components (defined in step 2 and 3) inside an svg by using theGraph
wrapper.Node
component using theuseNode
hook.Link
component using theuseLink
hook.Goals:
Short-term:
Medium-term:
Long-term: