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.
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.
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.
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
let config = kittychart::ChartConfig::from_json(r#"{"type":"bar","data":{"labels":["a","b"],"datasets":[{"data":[3,5]}]}}"#)?;
// draw at the cursor, detecting what the terminal supports
kittychart::show::show(config.clone(), &Default::default())?;
// or a PNG
let png = kittychart::render(config, &kittychart::RenderOptions::new(800.0)).to_png();
// widgets: kittychart-ratatui (ChartWidget + ChartState)
import kittychart
chart = kittychart.Chart(
type="line",
data={"labels": ["Mon", "Tue", "Wed"], "datasets": [{"data": [120, 190, 170]}]},
)
chart.show() # draw at the cursor
chart.interact() # hover, legend, keys
chart.save("chart.png") # or .svg; Rich, Textual and IPython too
const fs = require('fs')
const { Chart } = require('kittychart')
const chart = new Chart({
type: 'bar',
data: { labels: ['Q1', 'Q2', 'Q3'], datasets: [{ label: 'Revenue', data: [12, 19, 7] }] },
})
chart.show() // draw at the cursor
fs.writeFileSync('chart.png', chart.toPng({ width: 800 }))
#include "kittychart.h"
kc_chart *chart = kc_chart_from_json(json);
if (!chart) { fprintf(stderr, "%s\n", kc_last_error()); return 1; }
kc_show(chart, NULL); /* draw in the terminal */
kc_chart_free(chart);