How to use force-graph - 2 common examples

To help you get started, we’ve selected a few force-graph 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 DefinitelyTyped / DefinitelyTyped / types / force-graph / force-graph-tests.ts View on Github external
import ForceGraph from 'force-graph';

const graph = ForceGraph();
graph(new HTMLElement());

graph
    .graphData({nodes: [], links: []})
    .nodeId('testNode')
    .linkSource('source')
    .linkTarget('target')
    .width(100)
    .height(100)
    .backgroundColor('#FFF')
    .nodeRelSize(4)
    .nodeVal(1)
    .nodeVal('val')
    .nodeVal((node) => node.val)
    .nodeLabel('name')
    .nodeLabel((node) => node.name)
github geut / discovery-swarm-webrtc / example / example.js View on Github external
const createGraph = require('ngraph.graph')
const ForceGraph = require('force-graph').default
const { addPeer: _addPeer, removePeer: _removePeer, findPeer } = require('../tests/helpers/peers')
const { nodesToArray } = require('../tests/helpers/graph')

const MAX_PEERS = 2
const TOPIC = Buffer.from('batman')

const graph = createGraph()
const peersTitle = document.getElementById('peers-title')
const connectionsTitle = document.getElementById('connections-title')
const addPeer = () => _addPeer(graph, TOPIC, {
  bootstrap: ['http://localhost:4000']
})
const removePeer = (id) => _removePeer(graph, id)
const addMany = n => [...Array(n).keys()].forEach(() => addPeer())
const deleteMany = n => [...Array(n).keys()].forEach(() => removePeer())

force-graph

2D force-directed graph rendered on HTML5 canvas

MIT
Latest version published 2 months ago

Package Health Score

73 / 100
Full package analysis

Popular force-graph functions