Zibar
Pretty graphs for the terminal

Inspired from babar and sparkline. This actually mixes features of both.
Installation
npm install zibar -g
If you don't know what npm is, read this.
Usage
zibar [-c config-file] [ - ] [ value1 [value2..]]
Data can be read from stdin

Configuration allows fancy rendering

{
"height": 5,
"min": 0,
"high": 40,
"marks": [ 0, "?", 0, 0, { "symbol": "â–Ľ", "color": "red,bold" } ],
"color": "green",
"colors": {
"5": "magenta,bold"
},
"vlines": [null, null, "cyan"],
"yAxis": {
"decimals": 0
},
"xAxis": {
"interval": 2,
"color": "yellow,bold"
}
}
Or minimal sparkline style

{
"height": 1,
"min": 0,
"color": "yellow,bold",
"yAxis": {
"display": false
},
"xAxis": {
"display": false
}
}
Configuration
{
"height": 5,
"color": "green",
"background": "blue",
"min": 0,
"max": 10,
"low": 3,
"high": 6.
"chars": " ⡀⡀⡄⡄⡆⡆⡇⡇⡇",
"marks": [ 0,
"?",
null,
0,
{ "symbol": "â–Ľ",
"color": "red" }
],
"colors": {
"5": "magenta,bold"
},
"vlines":
[null, null, "cyan"],
"yAxis": {
"display": true,
"color": "yellow",
"ticks": true,
"decimals": 0
},
"xAxis": {
"display": true,
"color": "yellow",
"interval": 2,
"origin": 10,
"factor": 2,
"offset": 3
}
}
Rendering glitches
The terminal and its font must support unicode. Ensure you have one, e.g. Source Code Pro.
If some blocks looks weird, try the following config options.
"badBlock": true,
"fixFull": true
Using as a library
npm install zibar --save
var zibar = require('zibar');
var graph = zibar(data, config);
Example
var graph = zibar([30, 12, 9.8, 31, 14, 31.5, 4, 6, 22, 33, 4, 22],
{
"height": 1,
"min": 0,
"color": "yellow,bold",
"yAxis": {
"display": false
},
"xAxis": {
"display": false
}
});
process.stdout.write(graph);
Formatting
When using as a library, you can pass a function for formatting x and y axis labels.
format: function(x) { return require('roman-numerals').toRoman(x); }
Scale Transform
For non-linear y scale, you can pass a function and its inverse to transform the scale.
tranform: function(x) { return Math.log(x)/Math.log(10); }
inverse: function(x) { return Math.pow(10,x); }