cli-barchart
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

cli-barchart

Fancy and customizable bar chart in your terminal

screenshot-of-blue-bar

screenshot-of-green-bar

Installation

for npm users

npm i cli-barchart

for yarn users

yarn add cli-barchart

Usage

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

Readme

Keywords

none

Package Sidebar

Install

npm i cli-barchart

Weekly Downloads

321

Version

0.2.3

License

MIT

Unpacked Size

18.1 kB

Total Files

6

Last publish

Collaborators

  • fengzilong