Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

barcli

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

barcli

A simple tool for displaying real time bar graphs in the console

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by60%
Maintainers
1
Weekly downloads
 
Created
Source

barcli [bahrk-lee]

Barcli is a simple tool for displaying real time bar graphs in the console.

Screenshot of Leap Motion Controller example![screen shot 2015-04-05 at 10 46 51 pm](https://cloud.githubusercontent.com/assets/854911/7000356/ad911400-dbe5-11e4-8cf0-4e485c84aae9.png)

I needed a way to visualize Johnny-Five sensor data quickly and easily. console.log is lame and hard to read if you have more than one datapoint to track.

Multiple instances of barcli can be stacked to show multiple axes, sensors or other data sources in an easy to read horizontal bar graph.

Installation

npm install barcli

Usage

This example uses all of barcli's default values.

var Barcli = require("barcli");

var graph = new Barcli();

graph.update(0.25); // Sets bar to 25%
graph.update(1.0); // Sets bar to 100%

Optionally, you can pass configuration parameters in an object.

var Barcli = require("barcli");

var graph = new Barcli({
  label: "My Graph",
  range: [0, 100],
});

graph.update(25); // Sets bar to 25%
graph.update(100); // Sets bar to 100%

Configuration Options

label (String) - Label for the bar graph. Any length is fine, but make sure it will fit in your terminal window along with the bar graph.

inputRange (Array) - The upper and lower limits for input values. This will be mapped to your bar length.

width (Integer) - The length of the bar in terminal characters.

color (String) - Colors will be assigned automatically, but you can override with your preference. Valid values are "red", "green", "yellow", "blue", "magenta", "cyan" or "white".

Examples

Johnny-Five Sensor Input
var five = require("johnny-five");
var Barcli = require("barcli");

var board = new five.Board().on("ready", function() {

  var sensor = new five.Sensor({
    pin: "A0",
    freq: 250
  });

  var graph = new Barcli({
    label: "Sensor",
    range: [0, 100]
  });

  sensor.scale([0, 100]);

  sensor.on("data", function() {
    graph.update(this.value);
  });
});

Leap Motion Controller Input
var Leap = require("leapjs");
var Barcli = require("barcli");

var palmX = new Barcli({label: "Palm X", range: [-500, 500]});
var palmY = new Barcli({label: "Palm Y", range: [50, 400]});
var palmZ = new Barcli({label: "Palm Z", range: [-500, 500]});

Leap.loop({enableGestures: true}, function(frame) {

  if (frame.hands.length === 1) {
    palmX.update(frame.hands[0].palmPosition[1]);
    palmY.update(frame.hands[0].palmPosition[0]);
    palmZ.update(frame.hands[0].palmPosition[2]);
  }

});

A Barcli Clock
var Barcli = require("barcli");

var hours = new Barcli({ label: "Hour", range: [0, 23]});
var minutes = new Barcli({ label: "Minute", range: [0, 59]});
var seconds = new Barcli({ label: "Second", range: [0, 59]});
var milliseconds = new Barcli({ label: "Millisecond", range: [0, 999]});

var intervalID = GLOBAL.setInterval(function() {

  var now = new Date();

  hours.update(now.getHours());
  minutes.update(now.getMinutes());
  seconds.update(now.getSeconds());
  milliseconds.update(now.getMilliseconds());

}, 12);

Keywords

FAQs

Package last updated on 06 Apr 2015

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