Javascript client (node + browser) for the Lightning data visualization server.
$ npm install --save lightning.js
var Lightning = require('lightning.js');
var lightning = new Lightning();
lightning.line([1,1,2,3,5,8,13,21])
.then(function(viz) {
viz.open(); // opens in web browser
});
var Lightning = require('lightning.js');
var myOpts = {
color: [255,0,0] // changes the color of the line from default to red
};
var lightning = new Lightning();
lightning.line([1,1,2,3,5,8,13,21], myOpts) // optional argument for plotting options
.then(function(viz) {
viz.open(); // opens in web browser
});
var Lightning = require('lightning.js');
var lightning = new Lightning();
lightning.lineStreaming([1,1,2,3,5,8,13,21])
.then(function(viz) {
setInterval(function() {
viz.appendData([Math.random()]); // appends to existing data
// or
// viz.updateData([Math.random()]); // replaces existing data
});
});
// with an image gallery
lightning.gallery([fs.createReadStream(__dirname + '/img/example.png'), fs.createReadStream(__dirname + '/img/example2.png')])
.then(function(viz) {
viz.appendImage(/* another image */); // adds another image
});
// with a single image
lightning.gallery(fs.createReadStream(__dirname + '/img/example.png'))
.then(function(viz) {
viz.updateImage(fs.createReadStream(__dirname + '/img/example2.png')); // replaces existing image
});
// single line
lightning
.line([1,1,2,3,5,8,13,21])
.then(function(viz) {
viz.open(); // opens in web browser
});
// multiple lines
lightning
.line([[0,1,2], [3,4,5], [6,7,8]])
.then(function(viz) {
viz.open(); // opens in web browser
});
lightning
.lineStreaming([1,1,2,3,5,8,13,21])
.then(function(viz) {
viz.append([34, 55]);
});
var mat = _.map(_.range(100), function() {
return _.map(_.range(100), function() {
return Math.random();
});
});
lightning
.matrix(mat)
.then(function(viz) {
});
var x = _.range(100);
var y = _.map(_.range(100), Math.random);
lightning
.scatter(x, y)
.then(function(viz) {
});
var x = _.range(100);
var y = _.map(_.range(100), Math.random);
lightning
.scatterStreaming(x, y)
.then(function(viz) {
});
var x = _.range(100);
var y = _.map(_.range(100), function() {
return Math.random() * 100;
});
var z = _.map(_.range(100), function() {
return Math.random() * 100;
});
lightning
.scatter3(x, y, z)
.then(function(viz) {
});
var mat = _.map(_.range(3), function(i) {
return _.map(_.range(3), function(j) {
return i * 3 + j;
});
});
lightning
.adjacency(mat)
.then(function(viz) {
});
var mat = _.map(_.range(13), function(i) {
return _.map(_.range(13), function(j) {
return i * 3 + j;
});
});
lightning
.force(mat)
.then(function(viz) {
});
var mat = _.map(_.range(10), function(i) {
return _.map(_.range(10), function(j) {
return i * 3 + j;
});
});
var x = _.range(10);
var y = _.map(_.range(10), Math.random);
lightning
.graph(x, y, mat)
.then(function(viz) {
});
var regions = ['NY', 'MI', 'NM'];
var values = [0.33, 0.6, 0.07];
lightning
.map(regions, values)
.then(function(viz) {
});
// with a single image
lightning.image(fs.createReadStream(__dirname + '/img/example.png'))
.then(function(viz) {
});
// with a single image
lightning.imagePoly(fs.createReadStream(__dirname + '/img/example.png'))
.then(function(viz) {
});
lightning.gallery([fs.createReadStream(__dirname + '/img/example.png'), fs.createReadStream(__dirname + '/img/example2.png')])
.then(function(viz) {
});
MIT © Matthew Conlen