Text Charts
Generate text-based bar charts and histograms.
Usage - basic
Bar charts
TypeScript
; ;barChart.setData;console.logbarChart.render;/* apples | ■■■■■■■■■■■■■■■ 15oranges | ■■■ 3bananas | ■■■■■■■■■■■■ 12*/
Node.js
const TextChart = ;const barChart = ;barChart;console;/* apples | ■■■■■■■■■■■■■■■ 15oranges | ■■■ 3bananas | ■■■■■■■■■■■■ 12*/
Histograms
TypeScript
;;;for ; i < 1000; i++ for ; i < 1000; i++ histogramDefault.setDatahistogramDefaultData;console.loghistogramDefault.render;/* 0.01 - 6.51 | ■■■■■■ 106 6.51 - 13.01 | ■■■■■ 10313.01 - 19.51 | ■■■■■■ 11719.51 - 26.01 | ■■■■■ 102 26.01 - 32.5 | ■■■■■■■ 125 32.5 - 39 | ■■■■■ 101 39 - 45.5 | ■■■■■■■■■■■■■■■■■ 320 45.5 - 52 | ■■■■■■■■■■■■■■■■■■■ 353 52 - 58.5 | ■■■■■■■■■■■■■■■■■■■■ 381 58.5 - 64.99 | ■■■■■■■■■■■■■■■ 292*/
Node.js
const TextChart = ;const histogramDefault = ;const histogramDefaultData = ;for let i = 0; i < 1000; i++ histogramDefaultData;for let i = 0; i < 1000; i++ histogramDefaultData;histogramDefault;console;/* 0.21 - 6.69 | ■■■■■■ 110 6.69 - 13.17 | ■■■■■■ 10613.17 - 19.64 | ■■■■■■ 10719.64 - 26.12 | ■■■■■■ 116 26.12 - 32.6 | ■■■■■ 97 32.6 - 39.08 | ■■■■■■ 11439.08 - 45.56 | ■■■■■■■■■■■■■■■■■■■ 34845.56 - 52.04 | ■■■■■■■■■■■■■■■■■■■■ 37252.04 - 58.51 | ■■■■■■■■■■■■■■■■■■■ 35258.51 - 64.99 | ■■■■■■■■■■■■■■■ 278*/
Instance methods
setData(data: Array<[string, number]>): BarChart;
(BarChart) data
is an array of arrays with each sub-array's first element being the bar's label (string) and second element being the value of that bar.
setData(data: number[]): Histogram
(Histogram) data
is an array of numbers.
setProperties(properties): BarChart | Histogram
(Histogram, BarChart) properties.width
(optional):
Sets maximum width (number of characters) of chart. If not given, bars will be rendered according to values in setData
.
properties.barCharacter
(optional):
Character used to render bars.
properties.min
, properties.max
, properties.interval
(optional, histogram only): Set minimum, maximum and interval values for histogram. If left out, estimates will be calculated from the data.