# bar-horizontal

> Create beautiful horizontal charts, that fit your terminal.

Latest version **0.5.1** (published 2021-11-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install bar-horizontal
pnpm add bar-horizontal
yarn add bar-horizontal
bun add bar-horizontal
```

Provides the command `bar-horizontal`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.1 |
| Published | 2021-11-20 |
| First published | 2015-06-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 4 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Siddharth Kannan |
| Maintainers | icyflame |
| Keywords | cli-app, cli, bar, graph, barchart, terminal, horizontal, overflow, avoided |

## Links

- npm: https://www.npmjs.com/package/bar-horizontal
- Repository: https://github.com/icyflame/bar-horizontal
- Homepage: https://github.com/icyflame/bar-horizontal#readme
- Issues: https://github.com/icyflame/bar-horizontal/issues
- npm.io page: https://npm.io/package/bar-horizontal

## Dependencies (4)

- [meow](https://npm.io/package/meow.md) 3.7.0
- [lodash](https://npm.io/package/lodash.md) >=4.17.12
- [figures](https://npm.io/package/figures.md) 1.7.0
- [window-size](https://npm.io/package/window-size.md) 0.1.4

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.5.1 (latest) — 2021-11-20
- 0.5.0 — 2020-04-04
- 0.4.0 — 2017-11-13
- 0.3.0 — 2016-05-22
- 0.2.1 — 2015-07-03
- 0.2.0 — 2015-06-26
- 0.1.0 — 2015-06-24
- 0.0.2 — 2015-06-24
- 0.0.1 — 2015-06-24

## README

# bar-horizontal [![Build Status](https://travis-ci.org/icyflame/bar-horizontal.svg?branch=master)](https://travis-ci.org/icyflame/bar-horizontal)

> Create beautiful horizontal charts, that fit your terminal.


## Install

```
$ npm install --save bar-horizontal
```


## Usage

```js
var barHorizontal = require('bar-horizontal');
barHorizontal([6, 5, 4, 3, 2]);
// => Prints this on the console :-
: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 30%
: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 25%
: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 20%
: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 15%
: ▇▇▇▇▇▇▇▇▇ 10%


input_obj = {
  'first task': 20,
  'second task': 40,
  'a really really long label!': 90,
  'short one': 20
};

barHorizontal(input_obj, {labels: true});
// => Prints this on the console :-
first task                  : ▇▇▇▇ 12%
second task                 : ▇▇▇▇▇▇▇▇▇ 24%
a really really long label! : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 53%
short one                   : ▇▇▇▇ 12%
```


## CLI

```
$ npm install --global bar-horizontal
```
```

  Create beautiful horizontal charts, that fit your terminal.

  Usage
    $ bar-horizontal input-array
    $ bar-horizontal input-array --values

  Examples
    $ bar-horizontal 1 2 3 4
     : ▇▇▇▇▇▇▇▇ 10%
     : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 20%
     : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 30%
     : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 40%

    $ bar-horizontal 1 2 3 4 --ascii 
     : ======  10.00%
     : =============  20.00%
     : ====================  30.00%
     : ===========================  40.00%
```


## API

### barHorizontal(input_obj, [options])

#### input_obj

*Required*  
Type: `Array of Numbers`  
The array whose bar chart will be created.

#### options

##### labels

*Optional*  
Type: `Boolean`  
Default: `false`  
Labels to be shown or not

##### warnings

*Optional*  
Type: `Boolean`  
Default: `false`  
Whether or not to show warnings (eg. 'missing/invalid input')

##### ascii

*Optional*  
Type: `Boolean`  
Default: `false`  
Whether or not to use the `=` when printing the bar graph(s) to stdout.

By default, this module will use the
[square](https://github.com/sindresorhus/figures/blob/dfeeb1c1733a9fe6f6b13d25f37c440ba6750c0e/index.js#L10)
character from [figures](https://www.npmjs.com/package/figures).

##### width

*Optional*  
Type: `Number`  
Default: The width of the present terminal  
If supplied, the printed bar graph will look good on a terminal of the supplied
width's length.


##### noPrint

*Optional*  
Type: `Boolean`  
Default: `false`  
Whether `barHorizontal` should print the results to the console or not. If
`noPrint` is set, then the function will return the string and print nothing to
the console

## Testing
This module uses the [mocha](https://mochajs.org/) test framework. The test suite can be run by invoking `npm test` from the root directory.

## License

MIT © [Siddharth Kannan](http://icyflame.github.io)

---
_Source: https://npm.io/package/bar-horizontal · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
