npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lightning.js

v1.5.2

Published

Javascript (node + browser) client for the Lightning data visualization server.

Downloads

11

Readme

lightning.js

Javascript client (node + browser) for the Lightning data visualization server.

Install

$ npm install --save lightning.js

Usage

Plotting

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
    });

Plotting Options

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
    });

Updating Visualizations

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
    });

Available Methods

line(series)


// 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
    });

lineStreaming(series)

lightning
    .lineStreaming([1,1,2,3,5,8,13,21])
    .then(function(viz) {
        viz.append([34, 55]);
    });

matrix(mat)


var mat = _.map(_.range(100), function() {
    return _.map(_.range(100), function() {
        return Math.random();
    });
});

lightning
    .matrix(mat)
    .then(function(viz) {
    });

scatter(x,y)

var x = _.range(100);
var y = _.map(_.range(100), Math.random);

lightning
    .scatter(x, y)
    .then(function(viz) {
    });

scatterStreaming(x,y)

var x = _.range(100);
var y = _.map(_.range(100), Math.random);

lightning
    .scatterStreaming(x, y)
    .then(function(viz) {
    });

scatter3(x,y,z)

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) {
    });

adjacency(mat)

var mat = _.map(_.range(3), function(i) {
    return _.map(_.range(3), function(j) {
        return i * 3 + j;
    });
});

lightning
    .adjacency(mat)
    .then(function(viz) {

    });

force(mat)

var mat = _.map(_.range(13), function(i) {
    return _.map(_.range(13), function(j) {
        return i * 3 + j;
    });
});

lightning
    .force(mat)
    .then(function(viz) {

    });

graph(x, y, mat)

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) {

    });

map(regions, values)

var regions = ['NY', 'MI', 'NM'];
var values = [0.33, 0.6, 0.07];

lightning
    .map(regions, values)
    .then(function(viz) {
    });

image(image)

// with a single image
lightning.image(fs.createReadStream(__dirname + '/img/example.png'))
    .then(function(viz) {
    });

imagePoly(image)

// with a single image
lightning.imagePoly(fs.createReadStream(__dirname + '/img/example.png'))
    .then(function(viz) {
    });

gallery(images)

lightning.gallery([fs.createReadStream(__dirname + '/img/example.png'), fs.createReadStream(__dirname + '/img/example2.png')])
    .then(function(viz) {
    });

License

MIT © Matthew Conlen