Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
react-sigmajs
Advanced tools
React SigmaJS - React.JS flow-typed interface for SigmaJS library - fastest opensource rendering engine for linked graphs.
It makes easy to publish networks on Web pages, and allows developers to integrate network exploration in rich Web applications. Library is using JSX for graph configuration, including asynchronous graph loading, so no callback is needed. It's including ES modules supports, so resulting code should consist only of sigma functionality that you explicitly import. Easy to extend with additional components.
import {Sigma, SigmaEnableWebGL, EdgeShapes, NodeShapes, LoadGEXF, Filter, ForceAtlas2, RelativeSize} from 'react-sigmajs'
...
<SigmaEnableWebGL/>
<Sigma key="1"
onClickNode={ e => this.setState({filterNeighbours: e.data.node.id}) }
onClickStage={ e => this.setState({filterNeighbours: null}) } >
<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>
See storybook for more usage recipes.
All defined Sigma types stored under /types/sigma.js, can be used as a reference for objects and parameters. TODO: move to flow-typed
Sigma is the main component which reserves
<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>
Sigma callback receives Sigma Event with the following structure (see Sigma$Event type under /types/sigma.js):
.data
.captor -- information about event handler, for instance position on the page {clientX, clientY}
.node? -- for node events is sigma node data
.edge? -- for edge events is sigma edge data
To assign a shape renderer to an edge, simply set edge.type='shape-name' e.g. edge.type='dotted'. Note! this Component requires "canvas" renderer to work.
<Sigma renderer="canvas" graph={{nodes:["id0", "id1"], edges:[{id:"e0",source:"id0",target:"id1"}]}}>
<EdgeShapes default="dotted"/>
</Sigma>
Supported shapes
type Sigma$Edge$Shapes = "line" | "arrow" | "curve" | "curvedArrow" | "dashed" | "dotted" | "parallel" | "tapered";
See plugin page for more datails on implementation.
Parameters:
To assign a shape renderer to an edge, simply set node.type='shape-name' Note! this Component requires "canvas" renderer to work.
<Sigma renderer="canvas" graph={{nodes:["id0", "id1"], edges:[{id:"e0",source:"id0",target:"id1"}]}}>
<NodeShapes default="star"/>
</Sigma>
Extra node properties:
Supported shapes
type Sigma$Node$Shapes = "def" | "pacman" | "star" | "equilateral" | "cross" | "diamond" | "circle" | "square";
See plugin page for more datails on implementation.
Parameters:
Filter is hiding all nodes which do not apply to the provided nodesBy criteria.
Parameters:
type Nodes$Filter = (node: Sigma$Node) => boolean;
Running ForceAtlas2 algorythm on graph with progress animation.
It accepts all the parameters of ForceAtlas2 described on its github page:
see sigma plugin page for more details
Evenly distributes nodes in the grid. Applicable only to small graphs (<100 nodes)
It accepts all the parameters of sigma.layout.noverlap plugin described on its github page:
see sigma plugin page for more details
RandomizeNodePositions component, sets random positions to all nodes. Can be used within Sigma component with predefined graph or within graph loader component.
Sets nodes sizes corresponding its degree.
Parameters:
Component enables WebGL renderer, setting it as default renderer if WebGL is supported by browser.
<SigmaEnableWebGL />
<Sigma />
Parameters:
see sigma plugin page for more details
Parameters:
see sigma plugin page for more details
Load graph from Neo4j database via REST API
Parameters:
see sigma plugin page for more details
Sigma container will mount any child component with sigma instance under props.sigma. This way sigma functionality may be extended indefinitely:
call MyCustomSigma extends React.Component {
constructor(props) {
super(props)
props.sigma.graph.addNode({id:"n3", label:props.label});
}
}
...
return <Sigma>
<MyCustomSigma label="Label">
</Sigma>
Component which initializes asynchronously is supposed to mount its children only after initialized (for example LoadJSON), which makes possible to build sequential composition in the pure JSX without any callbacks or handlers. In the following example RelativeSize will be counted only after loading from arctic.json file.
<Sigma>
<LoadJSON url="/arctic.json">
<RelativeSize initialSize={8}/>
</LoadJSON>
</Sigma>
FAQs
Lightweight but powerful library for drawing network graphs built on top of SigmaJS
The npm package react-sigmajs receives a total of 2 weekly downloads. As such, react-sigmajs popularity was classified as not popular.
We found that react-sigmajs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.