Skip to content

Chart

Terminal charts for Ink 5 — sparklines, bar charts, and line charts using Unicode block characters.

Install

Terminal window
npm install @matthesketh/ink-chart

Components

Sparkline

Single-row visualization using Unicode block characters (▁▂▃▄▅▆▇█).

import { Sparkline } from '@matthesketh/ink-chart';
<Sparkline data={[1, 5, 2, 8, 3, 7]} color="green" />
PropTypeDefaultDescription
datanumber[]requiredValues to plot
widthnumberdata.lengthCharacter width
colorstring'green'Text color
minnumberautoMinimum scale value
maxnumberautoMaximum scale value

BarChart

Vertical bar chart with labels and values.

import { BarChart } from '@matthesketh/ink-chart';
<BarChart
data={[
{ label: 'Mon', value: 12 },
{ label: 'Tue', value: 8, color: 'red' },
{ label: 'Wed', value: 15 },
]}
height={10}
/>
PropTypeDefaultDescription
data{ label: string; value: number; color?: string }[]requiredBar data
heightnumber10Chart height in rows
widthnumberautoTotal width
showValuesbooleantrueShow value above bars

LineChart

Multi-row line chart with optional axes.

import { LineChart } from '@matthesketh/ink-chart';
<LineChart data={[1, 3, 2, 5, 4, 7, 6]} width={40} height={10} />
PropTypeDefaultDescription
datanumber[]requiredValues to plot
widthnumber40Chart width
heightnumber10Chart height
colorstring'cyan'Line color
showAxisbooleantrueShow axes
labelstringnoneY-axis label

License

MIT