https://github.com/catdad/plain-text-box-plot
:chart_with_upwards_trend: boxes and whiskers
https://github.com/catdad/plain-text-box-plot
ascii boxplot npm
Last synced: about 2 months ago
JSON representation
:chart_with_upwards_trend: boxes and whiskers
- Host: GitHub
- URL: https://github.com/catdad/plain-text-box-plot
- Owner: catdad
- Created: 2016-06-05T21:39:03.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-06-21T00:35:35.000Z (almost 9 years ago)
- Last Synced: 2025-04-10T11:24:21.291Z (about 2 months ago)
- Topics: ascii, boxplot, npm
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# plain-text-box-plot
[![Build][1]][2]
[![Code Climate][5]][6]
[![Downloads][7]][8]
[![Version][9]][8]
[![ISC License][10]][11][1]: https://travis-ci.org/catdad/plain-text-box-plot.svg?branch=master
[2]: https://travis-ci.org/catdad/plain-text-box-plot[5]: https://codeclimate.com/github/catdad/plain-text-box-plot/badges/gpa.svg
[6]: https://codeclimate.com/github/catdad/plain-text-box-plot[7]: https://img.shields.io/npm/dm/plain-text-box-plot.svg
[8]: https://www.npmjs.com/package/plain-text-box-plot
[9]: https://img.shields.io/npm/v/plain-text-box-plot.svg[10]: https://img.shields.io/npm/l/is-gzip-stream.svg
[11]: http://opensource.org/licenses/ISCA small Node library that creates box plots in plain text. Great for outputting box plots from CLI tools.
## API
```javascript
var ptBox = require('plain-text-box-plot');var data = {
min: 1,
q1: 2,
q2: 3,
q3: 4,
max: 5
};var boxplotString = ptBox(data);
```Example output:
```
+--------+--------+
|--------| | |--------|
+--------+--------+
```By default, the width of the output will be at most 75 characters. (Note: sometimes it can be 74, depending on the data.) You can also set this value with an optional second parameter:
```javascript
var ptBox = require('plain-text-box-plot');var data = { ... };
var boxplotString = ptBox(data, 120);
```If you are going to `console.log` it, and would like to match the console width, you can figure that out as such:
```javascript
var tty = require('tty');
var isatty = tty.isatty(1) && tty.isatty(2);var width;
// if we are not in a tty session, you don't want to do this
if (isatty) {
width = process.stdout.getWindowSize ?
process.stdout.getWindowSize(1)[0] :
tty.getWindowSize()[1];
}var ptBox = require('plain-text-box-plot');
var data = { ... };
var boxplotString = ptBox(data, width);
```## License
[ISC](http://opensource.org/licenses/ISC)