node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



Pipe a stream of data into a graph in the browser.


Pull down a static json file from the server with request, parse it with JSONStream, then pipe the records you want to graph to graph-stream:

var graph = require('graph-stream')(400, 300);
var JSONStream = require('JSONStream');
var parser = JSONStream.parse([ 'data', true, '17' ]);
var request = require('request');
var u = 'http://' + + '/data.json';

browserify this file:

$ browserify main.js -o bundle.js

then view it in a web browser:

graph output

as new data arrives, the graph updates automatically.

Your stream need not even end to be graphable. There's an example of a never-ending stream in example/


var graphStream = require('graph-stream')

var graph = graphStream(width, height, opts)

var graph = graphStream([ width, height ], opts)

Create a new readable stream graph that you can .pipe() data into.

When you pipe data it will be rendered as a simple bar graph.

The bar graph counts the number of times each string of data has been seen.


  • opts.sort - Set an ordering algorithm to rank the bars in the graph. Set as a string value of 'ascend' or 'descend'. If true, uses 'descend'. If false, doesn't sort. Default value: false.

  • opts.axisSize.x - Set the size of the x axis.

  • opts.axisSize.y - Set the size of the y axis.

  • opts.limit - how many bars to show

  • opts.other - whether to show a bar with the sum of all the bars not shown


Append the graph.element html element to target.

graph.resize(width, height)

graph.resize([ width, height ])

Resize the graph.


With npm do:

npm install graph-stream