All Projects → dunnock → React Sigma

dunnock / React Sigma

Licence: mit
Lightweight React library for drawing network graphs built on top of SigmaJS

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Sigma

Three Seed
A Three.js starter project with ES6 and Webpack
Stars: ✭ 213 (-1.84%)
Mutual labels:  webpack, webgl
Omil
📝Webpack loader for Omi.js React.js and Rax.js components 基于 Omi.js,React.js 和 Rax.js 单文件组件的webpack模块加载器
Stars: ✭ 140 (-35.48%)
Mutual labels:  webpack, jsx
Preact Minimal
🚀 Minimal preact structure
Stars: ✭ 136 (-37.33%)
Mutual labels:  webpack, jsx
Xdm
a modern MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins
Stars: ✭ 206 (-5.07%)
Mutual labels:  webpack, jsx
Wechart
Create all the [ch]arts by cax or three.js - Cax 和 three.js 创造一切图[表]
Stars: ✭ 152 (-29.95%)
Mutual labels:  webgl, svg
Svg Sprite Loader
Webpack loader for creating SVG sprites.
Stars: ✭ 1,822 (+739.63%)
Mutual labels:  webpack, svg
X0
Document & develop React components without breaking a sweat
Stars: ✭ 1,706 (+686.18%)
Mutual labels:  webpack, jsx
Knowledge
文档着重构建一个完整的「前端技术架构图谱」,方便 F2E(Front End Engineering又称FEE、F2E) 学习与进阶。
Stars: ✭ 1,620 (+646.54%)
Mutual labels:  webpack, webgl
Pixi Seed
Pixi.js project seed with ES6 and webpack
Stars: ✭ 149 (-31.34%)
Mutual labels:  webpack, webgl
Gantt
Gantt chart library using jsx support SVG, Canvas and SSR
Stars: ✭ 148 (-31.8%)
Mutual labels:  svg, jsx
Earthjs
D3 Earth JS
Stars: ✭ 128 (-41.01%)
Mutual labels:  webgl, svg
Svg Spritemap Webpack Plugin
SVG spritemap plugin for webpack
Stars: ✭ 160 (-26.27%)
Mutual labels:  webpack, svg
Elemental2
Type checked access to browser APIs for Java code.
Stars: ✭ 115 (-47%)
Mutual labels:  webgl, svg
Flowchart Vue
flowchart的vue版本
Stars: ✭ 136 (-37.33%)
Mutual labels:  webpack, svg
React Workshop
⚒ 🚧 This is a workshop for learning how to build React Applications
Stars: ✭ 114 (-47.47%)
Mutual labels:  webpack, jsx
Redux React Starter
DEPRECATED use the new https://github.com/didierfranc/react-webpack-4
Stars: ✭ 137 (-36.87%)
Mutual labels:  webpack, jsx
Conf
Landing page for event React Conf Brazil
Stars: ✭ 104 (-52.07%)
Mutual labels:  webpack, svg
Vue Svg Inline Loader
Webpack loader used for inline replacement of SVG images with actual content of SVG files in Vue projects.
Stars: ✭ 105 (-51.61%)
Mutual labels:  webpack, svg
Alien.js
Future web pattern
Stars: ✭ 141 (-35.02%)
Mutual labels:  webgl, svg
Terminal In React
👨‍💻 A component that renders a terminal
Stars: ✭ 1,939 (+793.55%)
Mutual labels:  webpack, svg

npm version Build Status

It makes easy to publish networks on Web pages and allows developers to integrate network exploration in rich Web applications. Use JSX for graph configuration, including asynchronous graph loading. Library is lightweight and modular, so you can bundle only what you use. Easy to extend with additional components.

Table of Contents

Usage

See storybook for working examples.

Please make sure to read CONTRIBUTION prerequisites section if you want to fork & change or contribute.

Install

npm install --save react-sigma

or

yarn add react-sigma

or

bower install https://unpkg.com/[email protected]/dist/react-sigma.min.js

If you don't want to use webpack or browserify, you could always reference the single file distribution, library will be available under global var ReactSigma:

<script src="https://unpkg.com/[email protected]/dist/react-sigma.min.js"/>

Simple use case with embedded graph

import {Sigma, RandomizeNodePositions, RelativeSize} from 'react-sigma';
...
let myGraph = {nodes:[{id:"n1", label:"Alice"}, {id:"n2", label:"Rabbit"}], edges:[{id:"e1",source:"n1",target:"n2",label:"SEES"}]};
...
<Sigma graph={myGraph} settings={{drawEdges: true, clone: false}}>
  <RelativeSize initialSize={15}/>
  <RandomizeNodePositions/>
</Sigma>

Note that graph nodes require x, y and size defined in order to be displayed, plugins like RelativeSize and RandomizeNodePositions might help to generate those. Sigma updates graph positions, therefore if to keep track of nodes in this example we use <Sigma settings={{clone: false}}>

Simple use case with graph loaded from external file

import {Sigma, LoadJSON} from 'react-sigma'
...
<Sigma style={{width:"200px", height:"200px"}}>
  <LoadJSON path="/public/data.json" />
</Sigma>

Advanced use case

...
<Sigma renderer="canvas">
	<EdgeShapes default="tapered"/>
	<NodeShapes default="star"/>
	<LoadGEXF path={String(process.env.PUBLIC_URL) + "/arctic.gexf"}>
		<Filter neighborsOf={ this.state.filterNeighbours } />
		<ForceAtlas2 worker barnesHutOptimize barnesHutTheta={0.6} iterationsPerRender={10} linLogMode timeout={3000}/>
		<RelativeSize initialSize={15}/>
	</LoadGEXF>
</Sigma>

Components reference

Please see react-sigma reference for details. Below is a brief concept.

Sigma

Sigma is the main component which reserves

area with a given style (default is full width, 500px height), initializes renderer and camera in the given area and starts rendering graph. be composed with sigma plugins using JSX syntax, e.g.:
<Sigma renderer="webgl" style={{maxWidth:"inherit", height:"400px"}}
		settings={{drawEdges:false}}
		onOverNode={e => console.log("Mouse over node: " + e.data.node.label)}
		graph={{nodes:["id0", "id1"], edges:[{id:"e0",source:"id0",target:"id1"}]}}>
	<RelativeSize initialSize={8} />
</Sigma>

SigmaEnableWebGL

By default sigma package includes only canvas rendering functions with webpack2, though it can be easily extended with WebGL or SVG (see next topic). Importing SigmaEnableWebGL enables WebGL renderer, setting it as default renderer if WebGL is supported by browser.

import { Sigma, SigmaEnableWebGL } from 'react-sigma'
...
<Sigma /> // will use webgl renderer if supported by browser

SigmaEnableSVG

Sigma can be easily extended with SVG renderer. Importing SigmaEnableSVG enables SVG renderer, though it does not set it as default so renderer should be explicitly specified in sigma options.

import { Sigma, SigmaEnableSVG } from 'react-sigma'
...
<Sigma renderer="svg" /> 

Extending sigma components

Sigma container will mount any child component with sigma instance under props.sigma. This way you can write custom sigma-aware components:

class MyCustomSigma extends React.Component {
	constructor(props) {
		super(props)
		props.sigma.graph.addNode({id:"n3", label:props.label})
	}
}
...
return  <Sigma>
	<MyCustomSigma label="Label">
</Sigma>

Components composition

Component which initialize or provide graph changes asynchronously are supposed to mount children after initialized. For instance LoadJSON will render child subcomponents only after loading. This makes possible to build sequential composition in the pure JSX without any callbacks or handlers. In the following example RelativeSize will be instantiated only after loading from arctic.json file.

<Sigma>
	<LoadJSON url="/arctic.json">
		<RelativeSize initialSize={8}/>
	</LoadJSON>
</Sigma>

Types

All defined Sigma types stored under /types/sigma.js, can be used as a reference for objects and parameters. TODO: move to flow-typed

Attributions

  • this project is a React wrapper around excellent Sigma.JS library built by @jacomyal and @Yomguithereal
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].