All Projects → flavioschneider → graphire

flavioschneider / graphire

Licence: MIT License
An unopinionated react graph visualization library.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
CSS
56736 projects

Projects that are alternatives of or similar to graphire

agda
The theory of algebraic graphs formalised in Agda
Stars: ✭ 67 (-73.83%)
Mutual labels:  graph
RT7-example
Code for the React Table 7 article
Stars: ✭ 32 (-87.5%)
Mutual labels:  hooks
revery-graphql-hooks
A library for easy handling of GraphQL with hooks for Revery
Stars: ✭ 34 (-86.72%)
Mutual labels:  hooks
gun-scape
GunDB Cytoscape Graph Visualizer + Live Editor
Stars: ✭ 49 (-80.86%)
Mutual labels:  graph
arrowic
Quick and dirty directed graph viewer for REPL explorations.
Stars: ✭ 15 (-94.14%)
Mutual labels:  graph
document-title
React hook for updating the document-title
Stars: ✭ 60 (-76.56%)
Mutual labels:  hooks
purescript-d3-tagless-II
Tagless final style interpreter / wrapper for D3 in PureScript, latest of many re-writes
Stars: ✭ 28 (-89.06%)
Mutual labels:  graph
Subway
Out-of-GPU-Memory Graph Processing with Minimal Data Transfer
Stars: ✭ 30 (-88.28%)
Mutual labels:  graph
Data-structures
Data Structures in Java
Stars: ✭ 13 (-94.92%)
Mutual labels:  graph
tRakt-shiny
Using trakt to graph show data and such. The on-it's-way-out incarnation of trakt.jemu.name
Stars: ✭ 17 (-93.36%)
Mutual labels:  graph
React-Combine-Provider
combine react providers in ease
Stars: ✭ 29 (-88.67%)
Mutual labels:  hooks
nodify
High performance and modular controls for node-based editors designed for data-binding and MVVM.
Stars: ✭ 282 (+10.16%)
Mutual labels:  graph
react-native-aria
A library of React Hooks for React-Native (Android/iOS/web) to provide accessible UI primitives for a design system.
Stars: ✭ 164 (-35.94%)
Mutual labels:  hooks
parallel-dfs-dag
A parallel implementation of DFS for Directed Acyclic Graphs (https://research.nvidia.com/publication/parallel-depth-first-search-directed-acyclic-graphs)
Stars: ✭ 29 (-88.67%)
Mutual labels:  graph
hookr
PHP action and filter hook system
Stars: ✭ 39 (-84.77%)
Mutual labels:  hooks
ux-charts
Simple, responsive, modern Charts with zero dependencies
Stars: ✭ 22 (-91.41%)
Mutual labels:  graph
profdump
Processes profiling output of the D compiler
Stars: ✭ 15 (-94.14%)
Mutual labels:  graph
use-tiny-state-machine
A tiny (~700 bytes) react hook to help you write finite state machines
Stars: ✭ 37 (-85.55%)
Mutual labels:  hooks
LGCN
Tensorflow Implementation of Large-Scale Learnable Graph Convolutional Networks (LGCN) KDD18
Stars: ✭ 45 (-82.42%)
Mutual labels:  graph
Oxide.Patcher
IL patcher for use with adding Oxide support to .NET games
Stars: ✭ 27 (-89.45%)
Mutual labels:  hooks

NPM NPM Downloads

npm install 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 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.

Documentation

Examples

Simple example using SVGs (no layout). Bubble example using SVGs (layout force).
Graph example in 3D with react-three-fiber (Three.js) using very efficient node instancing and segments (layout force). Drag and drop nodes with @use-gesture and react-three-fiber (no layout).

Basic Usage:

  1. Use Node and Linkcomponents (defined in step 2 and 3) inside an svg by using the Graph wrapper.
import { Graph } from 'graphire'
const MyComponent = (
  return (
    <svg>
      <Graph>
        <Node uid={0} x={110} y={300} color='red'/>
        <Node uid={1} x={50} y={30} color='orange' />
        <Node uid={2} x={150} y={80} color='green' />
        <Node uid='k' x={200} y={200} color='blue' />
        <Node uid={3} x={400} y={100} color='yellow' />

        <Link source={0} target={1} />
        <Link source={1} target={2} />
        <Link source={1} target='k' />
        <Link source={3} target='k' />
      </Graph>
    </svg>
  )
)
  1. Build the Node component using the useNode hook.
import { useRef } from 'react'
import { useNode } from 'graphire'

const Node = (props) => {
  const { color='black', radius=5, ...rest } = props
  const ref = useRef()
  useNode(([cx, cy]) => {
    ref.current.setAttribute('cx', cx)  
    ref.current.setAttribute('cy', cy)  
  }, rest) 
  return <circle ref={ref} cx='0' cy='0' r={radius} fill={color} />
}
  1. Build the Link component using the useLink hook.
import { useRef } from 'react'
import { useLink } from 'graphire'
// Link 
const Link = (props) => {
  const { source, target, color = 'black', ...rest } = props
  const ref = 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 (
    <line ref={ref} x1='0' y1='0' x2='0' y2='0' stroke={color} strokeWidth={1} />
  )
}

Goals:

Short-term:

  • -

Medium-term:

  • Convert to typescript (50% done)

Long-term:

  • Layout circular
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].