Code Monkey home page Code Monkey logo

graph-stream's Introduction

graph-stream

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

example

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);
graph.appendTo(document.body);

var JSONStream = require('JSONStream');
var parser = JSONStream.parse([ 'data', true, '17' ]);
parser.pipe(graph);

var request = require('request');
var u = 'http://' + window.location.host + '/data.json';
request(u).pipe(parser);

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/

methods

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.

Options:

  • 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

graph.appendTo(target)

Append the graph.element html element to target.

graph.resize(width, height)

graph.resize([ width, height ])

Resize the graph.

install

With npm do:

npm install graph-stream

license

MIT

graph-stream's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.