DocsFrontend

Charts

Charts written as a plain-English sentence or a few lines of JavaScript, and the chart components behind them.

A chart is a sentence like mean total by category sorted, run over a collection’s rows as the viewer. For anything a sentence can’t say, write a few lines of JavaScript, and return rows or any chart the registry has. To chart a collection, write a sentence in a chart block:

count orders by category

Features include:

  • A chart language of measures, groupings, conditions and endings, parsed and never run
  • JavaScript in an isolated worker for anything a sentence can’t say
  • Charts that share their data on a page, and stay live through sync if you want
  • Every kind of chart as a registry component: bars and lines to treemaps, maps and 3D surfaces

Chart blocks

A chart block reads a collection’s rows (as the viewer) and shapes them in one of two ways:

  • A sentence like mean total by category sorted. It’s parsed, never run, so it’s safe and needs no worker. The language is described below.
  • A few lines of JavaScript for anything a sentence can’t say: return count(rows, "status"). It runs in an isolated worker with only the rows and some helpers (no page, no session), and is stopped after two seconds.

The block tells which one it is: text that starts with a measure and has no code punctuation is a sentence.

return groupBy(rows, "country").map(([label, list]) => ({ label, value: mean(list, "total") }));

The chart language

count orders by category
mean total from orders by category sorted
percent by status

# stacked, one series per status
count by month of date and by status
count by category top 5                           # the rest as "Other"
mean total by week of date rolling 4
sum (price * quantity) by month of date
values total against date where category = Books  # a scatter

# as of a past date
mean total by category as of 2026-06-30
PartForms
Measurescount percent sum mean median min max distinct values
Groupingsby field, by month|week|weekday|year of date, by n every 5; a second grouping after “and” makes series: by country and by category
Conditionswhere a = x and b >= 3 and roles has editor
Endingstop n, sorted (smallest first) or sorted desc, cumulative, rolling n, as of 2026-06-30

Relations are shown by name. Time axes span from the first to the last month with data, keeping empty months and bins: counts show 0, while an average over nothing is a gap in the line rather than a drop to 0. The language has its own unit tests, which run in Node without a build.

Live tables, shared charts

Editors can make a table Live from its toolbar. Live tables read rows through sync, so everyone’s changes appear in real time: what you want for a kanban board, trip planning or a sign-up sheet with several people editing. Small live tables (up to 2,000 rows) are also cached per user in IndexedDB, so reloads are instant; signing out clears the cache. Tables that aren’t live load once, when the page opens.

Charts on a page share data: each collection, or slice of one, is fetched once per page. A chart’s settings:

  • Only rows where filters the first source with the filter language (country = "BE"), so only that slice is fetched.
  • Live draws the chart again when the rows change anywhere, through sync. By default it’s off, since a chart that stays still is easier to read.

Try it

Type or pick a sentence to chart a year of a small shop’s orders (category, country, shipper, date, total, shipped), Northwind-style:

Every kind, as components

Every kind a chart block offers is a component of Sluurp’s registry, built on shadcn’s chart, in the same look as its bars and lines. To use them in your own pages, add them:

bunx shadcn add @sluurp/chart-plot @sluurp/chart-3d
app.tsx
import { BoxPlot } from "@/components/sluurp/chart-plot";
import { Surface } from "@/components/sluurp/chart-3d";

<BoxPlot groups={[{ name: "Books", values: [6, 7.5, 8, 5.5] }]} />
<Surface z={[[1, 2, 3], [2, 4, 3], [1, 3, 2]]} />
KindComponent (registry item)
Area, bar, line, dotChart (stacked, 100%, gradients, horizontal, negative, labels, interactive) (chart-basic)
Pie, donut, radar, radial, gaugePieChart, RadarChart, RadialChart (chart-basic)
Histogram, box, violinHistogram, BoxPlot (chart-plot)
Heatmap, 2D histogram, imageHeatmap (chart-field)
Candlestick, OHLC, waterfallCandlestick, Waterfall (chart-plot)
Funnel, funnel areaFunnel (chart-hierarchy)
Treemap, icicle, sunburstTreemap, Sunburst (chart-hierarchy)
Sankey, parallel categoriesSankey (chart-hierarchy)
Contour, splom, ternary, parallel coordinates, polar barsContour, Splom, Ternary, Parallel, PolarBars (chart-field)
Choropleth, places, street map, density mapGeoMap, TileMap (chart-map)
Scatter 3D, surface, meshScatter3D, Surface, Mesh3D (WebGL: drag to turn, wheel or pinch to zoom) (chart-3d)

A Chart with ranges gets a menu of spans of its data (the last 3 months, 30 days, 7 days); its lines and areas morph from one span to the next. Scatter points with a size are bubbles.

Custom charts

For a chart of your own, use shadcn’s chart (Recharts), on which the registry’s are built, or draw SVG in ChartSvg from @sluurp/chart-svg, which gives the same tooltip and key.

Charts from a script

When a sentence can’t say it, a JavaScript chart block can return any of these charts by name with its props, { chart: { type: "BoxPlot", groups } }, drawn in the page’s colours. These three use the shop’s orders:

View as Markdown