@crafter/charts
v0.2.4
Published
Recharts for your terminal. Line, bar, scatter, candlestick, sparkline, heatmap, histogram, gauge — braille rendering, composable API, deterministic snapshots, zero deps, TypeScript.
Keywords
Readme
@crafter/charts
Recharts for your terminal. 15 chart types, zero deps, TypeScript.
cpu ▄▅▆▇███▇▆▅▃▂▁▂▃▄
mem ▁▃▅▇█████▇▅▃▁
err ▁ ▁ ▃█▂▁
│ ⢀⠔⠊⠉⠉⠑⢄
80┤ ⢀⠎ ⠱⡀
│ ⡰⠁ ⠘⢄
60┤ ⡰⠁ ⢣
│ ⠱⡀
40┤ ⠘⢄
│ ⠑⠢⢄⣀⣀⠔⠉Install
bun add @crafter/chartsQuick Start
import { plot, sparkline, chart, renderToAnsi } from "@crafter/charts";
// One-liner
console.log(plot([1, 5, 3, 7, 2, 8]));
// Sparkline
console.log(sparkline([10, 15, 12, 18, 14, 20], { color: "green" }));
// Full chart
const c = chart({ width: 60, height: 14 })
.data(rows, { xKey: "x" })
.yAxis({ format: (v) => "$" + v.toFixed(0) })
.line({ key: "price", color: "green", label: "Price" });
console.log(renderToAnsi(c));Chart Types
| Type | Function | Inline? |
|------|----------|---------|
| Line (braille) | chart().line() | No |
| Line (box) | chart({ charset: "box" }).line() | No |
| Bar | chart().bar() | No |
| Scatter | chart().scatter() | No |
| Candlestick | chart().candlestick() | No |
| Plot | plot(data) | No |
| Sparkline | sparkline() | Yes |
| Column | sparkColumn() | Yes |
| Bar | sparkBar() | Yes |
| Win/Loss | sparkWinLoss() | Yes |
| Area | sparkArea() | Multi-line |
| Heatmap | sparkHeatmap() | Multi-line |
| Histogram | sparkHistogram() | Multi-line |
| Gauge | sparkGauge() | Yes |
| Donut | sparkDonut() | Yes |
Features
- Zero dependencies
- TypeScript strict with exported types
- Braille rendering (4x2 sub-pixel per character)
- 4 charsets: braille, box (╭╮╰╯─│), block, ascii
- 3 render targets:
renderToAnsi(),renderToString(),renderToHtml() - Deterministic snapshots for CI (
toMatchSnapshot()) - Auto-sized to terminal width
- Fixed domain via
.yDomain([min, max]) - Multi-series with colored legend
Links
License
MIT
