https://github.com/fengzilong/cli-barchart
Fancy and customizable bar chart in your terminal
https://github.com/fengzilong/cli-barchart
bar barchart chart nodejs terminal
Last synced: 3 months ago
JSON representation
Fancy and customizable bar chart in your terminal
- Host: GitHub
- URL: https://github.com/fengzilong/cli-barchart
- Owner: fengzilong
- License: mit
- Created: 2021-10-12T13:47:41.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-10-21T15:53:41.000Z (over 3 years ago)
- Last Synced: 2025-04-09T21:44:33.990Z (3 months ago)
- Topics: bar, barchart, chart, nodejs, terminal
- Language: TypeScript
- Homepage:
- Size: 102 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cli-barchart
Fancy and customizable bar chart in your terminal
# Installation
for npm users
```bash
npm i cli-barchart
```for yarn users
```bash
yarn add cli-barchart
```# Usage
```js
const bar = require( 'cli-barchart' )
const chalk = require( 'chalk' )const chartString = bar.default( [
{
key: 'foo',
value: 0.1,
},
{
key: 'bar',
value: 0.2
},
{
key: 'longtext',
value: 0.3
}
], {
// max width of bar, default is 1/3 of terminal columns
maxWidth: 10,// bar color, default is blue
colorize: ( item, index, items ) => chalk.green,// label after bar, default is percentage calculated from `item.value` / sum
renderLabel: ( item, index, items ) => chalk.green( item.value ),
} )console.log( chartString )
```# License
MIT