New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

js-network-vis

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-network-vis

visualization tool for network simulations

  • 0.0.1
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

js-network-vis

Tool for visualizing network simulation

Use with browserify or use pre-browserified in dist/

var data = require('./graph_data.json')
var draw = require('js-network-vis')

var network = draw(data.nodes, data.edges, {
  width: 500
, height: 900
  
  /* configure visualization with values or functions */
, node_color: 'pink'
, node_size: function (node) {
    return node.requests.length > 0 ? '15' : '10'
  }  
})

/* updates network with event */
network.update({
  type: 'request'
, node: 837
})

api

js-network-vis exposes a single function

draw(nodes, edges, opts)

nodes is an array of node objects:

{
  name: ?
, group: ?
, type: ?
}

edges is an array of edge objects:

{
  source: node1.name
, target: node2.name
, value: ?
}

opts has the following optional configurations:

{
  width: ? // canvas width
, height: ? // canvas height
, node_color: // color or function(node) that returns color
, node_size: ? // size or function(node) that returns size
, tick // function to call on force tick
, charge // charge for force layout
, linkDistance // linkDistance for force layout
}

network

a network object is returned by draw:

{
  update: function(ev) // updates graph according to an event object
, opts: { ... } // reference to opts object passed to draw
, canvas: d3 svg selection // reference to graph canvas 
, edges: d3 line selection // reference to graph lines
, nodes: d3 circle selection // reference to graph nodes
}

network.update(event)

updates network according to one of the following events:

request

creates a request on the specified node

{
  type: 'request'
, node: node.name
}

request_hop

moves a request from the from_node to the to_node

{
  type: 'request_hop'
, from_node: node1.name
, to_node: node2.name
}

FAQs

Package last updated on 03 Apr 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc