plain-text-box-plot
A small Node library that creates box plots in plain text. Great for outputting box plots from CLI tools.
API
var ptBox = ; var data = min: 1 q1: 2 q2: 3 q3: 4 max: 5; var boxplotString = ;
Example output:
+--------+--------+
|--------| | |--------|
+--------+--------+
By default, the width of the output will be at most 75 characters. (Note: sometimes it can e 74, depending on the data.) You can also set this value with an optional second parameter:
var ptBox = ; var data = ... ; var boxplotString = ;
If you are going to console.log
it, and would like to match the console width, you can figure that out as such:
var tty = ;var isatty = tty && tty; var width; // if we are not in a tty session, you don't want to do thisif isatty width = processstdoutgetWindowSize ? processstdout0 : tty1; var ptBox = ; var data = ... ;var boxplotString = ;