KittyChart

A Rust port of Chart.js

Chart.js charts, in your terminal.

Same config, same library, two outputs. On the left, KittyChart draws into a browser <canvas>. On the right, the very same code runs kittychart view inside a real terminal emulator and speaks kitty graphics escape codes to it. Both halves are this page's WebAssembly. No Chart.js on the page.

browser <canvas> · tiny-skia in WebAssembly
Chart.js's default colors here; the terminal's theme on the right
~/demo — kittychart

Hover either chart; the other follows. Click a legend item. Click the terminal, then try ← → 1–9 r s q.

Change the data. Both animate. Edit revenue.json (plain Chart.js JSON) and both views animate to it, the way kittychart view revenue.json --watch follows a file.
configvalid

How it works

One renderer, two ways out. Nothing on the terminal side is special-cased for the browser: it is the CLI's code path, and its output would work unchanged over SSH into kitty, Ghostty or WezTerm.

A Chart.js config goes into KittyChart. Its pixels go to a canvas via putImageData; its escape codes go to the terminal, whose pointer and key reports come back. Chart.js config{ type, data, options } KittyChart · Rust → WebAssemblylayout · scales · elements · tooltipsanimation · hit-testing · legendtiny-skia rasterizer · fonts built in <canvas>RGBA → putImageData terminal (restty)kitty graphics · ANSI text pixels \e_Ga=T,f=32,… \e[<35;x;yM · keys

The canvas

WebChart lays the chart out, rasterizes it with tiny-skia into RGBA in WebAssembly memory, and the page copies those pixels to the canvas. Hover and legend clicks call the same hit-testing the terminal uses.

The terminal

restty is Ghostty's terminal core compiled to WebAssembly. KittyChart asks it what it supports (the same queries as on a real TTY), then Session sends each frame as a kitty graphics image and reads pointer and key reports back through its input parser.

The wire

The column between the panes logs what crosses the terminal boundary: frames going down, pointer and key reports coming up. When you hover the canvas, the page asks KittyChart for the pointer report a terminal would send for the same bar, and feeds it in.

Use it

Any Chart.js config. In the terminal it picks kitty graphics, then sixel, then block and Braille text, and takes its colors from your terminal theme. Off the terminal it renders PNG and SVG.

# draw in the terminal (kitty → sixel → text)
kittychart chart.json
# explore it: hover, legend, keys; follow the file as it changes
kittychart view chart.json --watch
# or render files
kittychart chart.json --out chart.png
kittychart chart.json --out chart.svg
cat chart.json | kittychart --protocol braille --cols 80