How to use the sigma function in sigma

To help you get started, we’ve selected a few sigma examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphology / graphology / examples / highlight-neighbors.js View on Github external
* Highlight Neighbors Example
 * ============================
 *
 * @Yomguithereal
 *
 * Highlighting neighbors of the clicked node using a rendering engine such
 * as sigma.
 */
import Graph from 'graph';
import sigma from 'sigma';

// Creating our graph (we'll assume it's hydrated with external data)
const graph = new Graph(data);

// Instantiating sigma
const sigInst = new sigma(graph, {
  settings: {
    edgeColor: 'source'
  }
});

// Click handler
function clickHandler({data: {node}}) {

  // Creating a set of the node & its neighbors
  const nodesToHighlight = new Set([node].concat(graph.neighbors(node)));

  // Iterating through nodes
  graph.forEachNode(node => {
    const color = nodesToHighlight.has(node) ?
      graph.getNodeAttribute(node, 'originalColor') :
      '#ccc';
github LiskHQ / lisk-explorer / src / components / activity-graph / activity-graph.service.js View on Github external
this.renderer = {
		container: 'sigma-canvas',
		type: 'canvas',
	};

	this.settings = {
		sideMargin: 1,
		singleHover: true,
		minNodeSize: 0.5,
		maxNodeSize: 16,
		drawLabels: false,
		defaultEdgeType: 'arrow',
	};

	this.sigma = new Sigma({
		renderer: this.renderer,
		settings: this.settings,
	});

	function NodeSelect(sigma) {
		this.sigma = sigma;
		this.color = '#5bc0de';

		this.add = function (event) {
			this.remove(event);
			this.node = event.data.node;
			this.prevColor = this.node.color;
			this.node.color = this.color;
			this.sigma.refresh();
		};

sigma

A JavaScript library aimed at visualizing graphs of thousands of nodes and edges.

MIT
Latest version published 18 days ago

Package Health Score

89 / 100
Full package analysis