Data directives
The four directives read the sources of the story's data: and are rendered at build time by
@recit/data. A report uses them, and so can a deck (the
report → deck bridge keeps them) or
in a site page. An unknown source, field or attribute is an
error with its line and the closest name:
Code
Value
:value{…} is inline: one number, in the words of the story's language, inside a <data> element
whose value keeps the exact number.
| Attribute | Values |
|---|---|
data | the source |
agg | required: sum, avg, min, max, count, first, last, growth |
field | the column, required unless agg=count |
by, period | for growth: the date column, and month, quarter or year |
where | equalities: where= |
format | number, currency, percent, compact, date |
currency, digits | an ISO 4217 code; the number of decimals |
growth compares the last complete period with the previous one, and shows a percentage. With daily
rows, the period of the last day is complete only when the next row, at the rhythm the rows already
keep (every day, working days, at most a week apart), would fall after its end: October up to the
15th is left out, never compared with all of September, while working days that stop on Friday the
30th still close October. The end is read on every row of the table, whatever where keeps, so all
the figures of a report count the same periods. first, last, min and max over a column of
years (see Table) write the year as it is, 2026, never 2,026, unless a format= is
given.
Each value of where must be held by at least one cell of its column: where= is an
error that suggests North, never an empty figure. A combination of values that no row holds stays
allowed and gives an empty result. A count (agg=count) checks the fields only: a value that no row
holds counts 0, an answer rather than a typo.
Chart
::chart{…} draws an SVG at build time, without a DOM: line, bar, area or dot, a heatmap,
a scatter plot, and two maps, choropleth and points. It names columns,
never values; facet=series draws small multiples. Series n takes the tint
--recit- of @recit/theme (8 tints, the first one the brand colour), each with a light and
a dark value, so the same chart follows the dark mode; a "Data" disclosure under it shows the table
of the points it plots.
| Attribute | Values |
|---|---|
data, type, x, y | the source, the kind, the x column, one or more y columns |
color | a column that splits the series (8 at most) |
stack | stacks the series of an area or bar chart |
where | equalities, as for :value |
title, alt | the caption; the alternative text (generated when absent) |
subtitle, source | the line under the title; the « Source: » line under the chart |
unit | the unit of the values, in the title of the value axis |
xLabel, yLabel | the titles of the x and value axes (line, area, dot, bar, scatter) |
format, currency | the format of the y axis |
roles | a colour role per series: roles= |
orientation | vertical (default) or horizontal (lying bars on type=bar) |
zero | false frees line, dot and unstacked area from 0; true holds 0 on linear scatter axes |
area | a light fill under each line of a line chart (3 at most) |
details | false omits the « Data » table (<title> and <desc> stay) |
The frame around the drawing is HTML, in the size of the text, never scaled with the SVG: the
subtitle under the title, the axis titles over and under the drawing, and a « Source: » line
before the "Data" disclosure. Over a table, the block gives them: subtitle=, source=, unit=,
xLabel= and yLabel= (when source= is omitted and the table carries meta, ::chart composes
Source: from publisher, title and license; source="" omits it); a ready chart brings them
from its file, and the same attributes of its block replace them. The value axis reads « Visits
(index) », the unit alone without a label, the label alone when it already names the unit; xLabel
also heads the x column of the "Data" table. The legend of a scale writes the unit once per class («
50 – 100 index »), numbers formatted in the language of the story. A scatter keeps its axis titles
in the drawing, the unit on y; xLabel and yLabel on a heatmap or a map are an error, never
ignored.
Markdown
Each point of a scatter, dot or bar chart carries data-row, the index of its row in the
"Data" table, so a script can pair a mark and its row without reading labels. In the browser,
@recit/ gives each chart one Tab stop, arrow keys across its values and a tooltip read
from the "Data" table without changing the server SVG, the PDF or image exports; a report turns this
off with interactive:.
In print (@media print and PDF), the "Data" disclosure prints open beneath the chart with its
summary rendered as a plain heading (details= still omits it). On a line chart, each curve
also takes a stroke pattern by series rank — solid, dashed, dotted, dash-dot, cycling from the fifth
series — which the legend repeats so the series stay legible in grey.
Colour roles
roles= gives a series the colour of what it means, so the same thing has the same colour on every
page. There are four roles, and a misspelt one is an error that names them:
| Role | For |
|---|---|
alert | what is over a limit, saturated, under strain |
solution | the alternative, the reserve, what is advised |
reference | the baseline a series is compared with |
context | the rest, in grey, behind the series that matter |
Each role is a token of @recit/theme (--recit-…) with a light and a dark value,
both at a contrast of 3:1 at least on the surfaces of their mode. The chart carries a class per
role, never a colour, so it follows the dark mode. A name that is not a series of the chart is an
error too: a misspelt series would otherwise stay uncoloured.
A role can also be a tint, 1 to 8, to fix a colour without a meaning:
roles=. A series without a role takes the next tint that no role took, so it
never shares the alert colour.
theme.chart in recit. (Colors) overrides these tokens for
a project or a story: roles sets reference, alert, solution and context (one colour for
both modes or { light, dark }, updating --recit- to -3 with the first three roles), and
sequential (5 steps) or diverging (7 steps) replaces the heatmap and choropleth scales. A colour
under 3:1 on --recit- of its mode raises a low- warning.
recit.config.ts
A ready chart
A chart already computed by a script is a source of its own: chart: names a JSON file, relative to
the story, that follows chart.json (recit schema chart
prints it). The file brings the type, the axes and the values, so ::chart needs no type, x or
y; its other attributes (title, alt, roles) apply over the file. A plain path to a JSON file
whose $schema is chart.json is read as a ready chart too.
Markdown
charts/trend.json
type is line, area, bar or dot, with one value per x in each series; null is an absent
value, a gap in a line. These cartesian specs also accept zero (boolean: false frees line,
dot and unstacked area from 0, while bar and stacked series always include 0), and bar
accepts orientation ("vertical", the default, or "horizontal", categories down the left and
values along the bottom). The schema also names heatmap (with rows, cols, values, scale,
midpoint, breaks, rowGroups and optional legendTitle above the colour scale),
scatter, kpi, choropleth and points. A wrong file is an error
with the line of its source in the front matter: an unknown type (with the closest one), a series
whose values do not match x, an unknown role.
Every ready chart may carry an axis, { "kind":, which says what its x axis runs
over. Récit computes it when it is absent: kind is day, month or year when every x is an
ISO date of that precision, month- when every x names a month (janv., February,
Août), labels (a line, area or dot chart) or categories (a bar chart, a heatmap, a kpi)
otherwise, xy for a scatter plot and map for a choropleth or points. Two charts can be compared
on the same frame only when their axes share the same key; the computed key is the kind (with
the base of a map), and an author who writes a key declares two axes equivalent. The pure helpers
that read it, align two charts and rescale them live in @recit/.
Overlay
data= can name several ready charts (*.chart.json declared under data: in the front matter),
separated by +, to draw them on the same frame at build time:
Markdown
Sources overlay when they share the same group (line with line or bar with bar, 8 series at
most; scatter with scatter or points with points, 3 groups at most) and a compatible axis.
On line and bar charts, sources must share the same axis (same months, same years, same labels;
an axis.key written in chart.json declares two axes equivalent): each series is named «
source · series », dates are united and sorted, the order of the first source wins for labels, and
a missing value stays empty.
Two scatter charts always overlay on their x and y axes (different x or y units are
refused with overlay-); two points maps overlay only when they share the same
base. Each point takes the group « source » when it has none, or « source · group » otherwise,
with 3 groups at most across all sources (overlay- beyond 3); on points, each
source's colour roles and highlight entries follow its renamed groups. Neither accepts
rescaling: scale=index and scale=max are refused (overlay-).
On line and bar overlays, scale=none (the default, where different units are refused),
scale=index (100 × value / over the common positions) or scale=max sets the scale; any
scale other than none appends « (derived) » to the title and to the value axis, while the table of
values under the chart keeps the original values. A refusal is an error at the line of the directive
that starts with its code: overlay-, overlay-,
overlay-, overlay-, or "x" is not a ready chart.
The same overlay can live in one file: a chart.json of type: carries its own layers,
at least two, each with a layers.name (its short name in the series names), a layers.chart (a
ready chart, never another overlay) and an optional layers. (the series or groups kept from
it). The file also takes title and scale (none, index, max), and is resolved when it is
read: ::chart{data= draws it as any ready chart, and a refusal is an error of the file that
starts with its code.
JSON
Part of a ready chart
One file can serve several blocks: the block keeps part of it, before the chart is drawn, so the
generated description and the table follow. series= keeps series of a line, area, bar or
dot chart, rows= and cols= rows and columns of a heatmap (its row groups follow), items=
figures of a kpi, groups= groups of a scatter or a map of points (points without a group are
left out, and the lines of a map to a point left out disappear). On a kpi, cols= stays the
number of tiles per row, 1 to 6. Each names its parts by label or by rank from 1, in the order
written. x= keeps categories or ranks, or a range of dates on a time axis (x=2020..2025, either
end may be left out). subtitle= replaces the one of the file, as title= does.
Markdown
The roles, the highlights and the x marks of the file follow what is kept. A selection only keeps
or reorders: a sum stays the work of the script that writes the file. An unknown name (with the
names expected and the closest one), a rank out of range, a name chosen twice, an empty range or a
range over labels is an error; so is an attribute of another type of chart, never ignored. The
choice belongs to the block, not to chart.json.
rename= shows kept names under another name (Old=New, comma-separated, split at the last =),
without touching the file: series of line, area, bar or dot, groups and point labels of
scatter or points, rows, columns and row groups of a heatmap, or key figures of a kpi. All
other attributes of the block (series=, groups=, roles=, highlight=, annotate=) read the
names of the file first; rename= runs last, and the colour roles, the legend, the generated
description, the point titles and the "Data" table follow the new name.
Markdown
Export a ready chart as an image
recit export -- exports a ready chart on its own, without a story, in
PNG (default, captured in Chromium) or standalone SVG (--image-, no browser needed),
with static: true so the « Data » disclosure is omitted while <title> and <desc> stay:
Bash
--preset picks the chart layout from the preset's ratio (9:16 → story, 4:5 → portrait,
1:1 → square, og-image → share) and writes <output>/ (or .svg). A PNG
captures the whole figure — HTML title, HTML legend and « Source: » line included — at the exact
pixel size of the preset, or the page figure at 2× (--scale) into <output>/
(default out/<name>/) without --preset. An SVG (--image-) writes only the <svg>
element, at the viewBox dimensions of that layout, without the HTML title, HTML legend or source.
Every PNG and every SVG is listed in exports.json with scene set to <name> and alt set to
the alt written in the file, or the generated <desc> (or the rendered key figures of a kpi)
when absent. An SVG entry has kind: "svg" and takes width and height from its viewBox. On a
story of any format (report, deck, webstory…), recit export <story> --
exports every ::chart block in source order as <story>-, <story>-… with the same
--preset, --image-, --scale and exports.json rules (scene set to the containing
scene's id, layout= on a block kept over the preset's).
Scatter
type=scatter places points by two numbers, x and y. Over a table, x and y name two columns
of numbers and color the groups; a row without a number is left out and counted in the generated
description. Three groups are coloured at most: the others, and the points without a group, are
drawn in grey as « Others » (the context role). roles= colours a group, marks= draws reference
lines.
Markdown
A ready chart brings more: a label per point, a size drawn as its area (with a legend of three
sizes and sizeLabel), xUnit and yUnit (axis units formatted with the x and y values and added
to xLabel and yLabel; yUnit falls back to unit when omitted), xScale and yScale
(linear, or log for values that span powers of ten, where a value of 0 or less is an error
naming the point), annotate (the labels written next to their points, placed so they cover neither
a point nor another label) and highlight (labels or groups drawn on top, larger and ringed, the
others lighter). A higher z is drawn on top; the large points go under the small ones. An unknown
name in annotate or highlight is an error with the closest one.
charts/cities.json
The format of a drawing
A chart is drawn for where it is shown, never zoomed: on a page by default, wide and low in a deck,
and at the width of a social format in a web story (story for 9:16, portrait for 4:5, square
for 1:1, chosen from the story's ratio), so that its labels read on a phone. layout= sets it on
one chart: page, slide, story, portrait, square, share (a link preview) or poster.
On story, portrait, square and share, textScale(layout) caps the value axis at four
graduations and thins category labels without overlap while always keeping the first and last
(spacedTicks), so the SVG text renders at 30 px on a 1080 px export (page, slide and poster
keep five value graduations). In a web story card, a chart past 6 bars or 3 series emits a
data- warning at its line.
recit validate also checks every ::chart of a web story against its target presets
(images. from front matter or recit.config, or else the preset of the card's ratio), with
presetChartWarnings of @recit/data. The widths of the chart's texts are measured in Chromium, in
the fonts of the theme, when Playwright's Chromium is installed, and estimated otherwise. It emits a
chart-preset warning at the ::chart line when the SVG text inside the card's content width would
scale under 24 px on a 9:16 story preset, 20 px on another social or share preset (instagram-,
square, og-image) or 10 px on a 1× web banner (mpu, leaderboard), when the estimated figure
height overflows the card's usable height, or when the drawn figure crosses a safeArea margin;
--strict raises chart-preset warnings to errors.
Markdown
On a narrow format, a chart keeps at most four ticks on its value axis and writes one category label
in two or three when they would overlap, the first and the last always written. A heatmap with more
columns than rows turns in a story or a portrait, so that its longer side runs down the card
(not when its rows are grouped); transpose= swaps rows and columns anywhere, and
transpose= keeps them as they are.
height= sets the height of the drawing in pixels (120 to 1200). On a web story card (story,
portrait, square, share) or a poster, height=fill gives the drawing the room left under a
title and stretches the figure to fill the remaining card space; if there is more text than the
title, the drawing shrinks to fit without distorting its proportions. On a page or a slide (or
on a kpi or map chart), height=fill keeps the default height and emits a warning.
When recit export -- captures a height=fill chart, of a story's charts (--charts, for
a card preset) or of a web story's cards, it measures in Chromium the room actually left by the
title, legend and source, and draws the chart again at that height before the capture; the
standalone SVG keeps the card's fixed share.
legend=side (legend=below by default) places the drawing on the left (~62 % of the format's
width, its height scaled on a map and unchanged on a series chart) and stacks the legend, caption
and source at the top on the right, keeping the "Data" disclosure across the full width below; under
20rem wide, the figure stacks again. Without legend=, a map (choropleth or points) in
layout= or layout=share puts the legend on the side by default so square and link-preview
maps stay legible without crowding their height; legend=below puts it back underneath:
Markdown
Small multiples
facet=series draws one small chart per series of a line or area chart, all on the same value
scale and the same x axis, each titled with its series. The other series stay in each panel as thin
grey lines, to compare; context= removes them (they are drawn up to 12 series by default,
context=true keeps them beyond). columns= sets 1 to 4 columns, chosen from the number of series
when absent; height= is shared between the rows. Over a table, color= splits the series; a ready
chart takes facet, columns and context as fields.
Markdown
Small multiples of bars, dots, stacked areas, scatter plots, heatmaps or maps are an error, and so
are columns= or context= without facet.
Maps
Two types draw a map, through @recit/geo: the build of a report composes it with @recit/data.
Their base is any GeoJSON FeatureCollection in longitude and latitude: base= names it relative
to the story (or base in a ready chart, relative to the chart file). It is never a URL and never
outside the project: the folder of its recit., else the story's folder, so one base can
serve every story of the project. TopoJSON and projected metres are refused.
type= colours each shape of the base by its value, in the classes of the heatmap
(scale= or diverging, midpoint=, breaks=), a shape without a value hatched « No
data ». key= names the property of the features that the values name (the feature's id when
absent). Over a table, x is the key column and y the value column, summed per key. highlight=
outlines and names shapes by their key. A ready choropleth chart (values mapping each key to a
number or null) also takes nameKey (the feature property that names each shape in tooltips, the
description and the "Data" table; "name" when absent, else its key) and legendTitle (the
heading above the colour-scale legend and of the value column in the "Data" table).
Markdown
An unknown key is an error with the closest property and the list of them; keys the base lacks are a warning with their number.
type=points places points in longitude and latitude, on a base or alone (the projection then fits
the points). Over a table, x is the longitude, y the latitude, label= the column that names a
point, color= the groups (three coloured, then « Others ») and value= the size, drawn as an
area. A ready chart adds highlight (drawn on top, larger, ringed), z, href (a link per point,
reached with the keyboard) and lines: each end is the label of a point or a [lon, lat] pair.
charts/sites.json
On the block, lines= names a GeoJSON file of LineString or MultiLineString features, named by
their name property, read like base=. Lines are drawn under the points; up to 8 carry their
label, beyond that, or when a line has none, a legend entry and a count in the description say them.
lines= on a choropleth, or on a chart that is not a map, is an error.
Markdown
A row without a longitude or a latitude is an error with its line; a point off the globe asks whether the two were swapped.
Table
::table{…} shows the rows of a source, formatted, with scope on its headers.
| Attribute | Values |
|---|---|
columns | "name,revenue,growth"; all by default |
sort | a column; -revenue sorts descending, texts in the story's alphabet |
limit | the number of rows |
where, caption | equalities; the caption |
format | percent for every number column, or "revenue= |
currency | ISO 4217, required by a currency column |
rename | headers under another name: "name= |
A boolean cell reads « Yes » or « No » in the story's language; a number column is formatted by
Intl (number by default), except a column of years, whose name ends in year or année
(year, fiscal_year) and whose cells are four-digit whole numbers: it is written as it is,
2026, never 2,026, unless a format= names it. A format= on a column of text, or on a column
absent from the source, is an error with its line.
Kpi
:::kpi holds a list: one key figure per item, its :value and its label. The first line of an
item is its label; the lines under it are a note, shown under the figure. The row is a <dl>: a
term per label, the figure and the note as its definitions.
Markdown
::source[…] (with an optional {id=…}) writes a small muted « Source: … » line (in the story's
language, with links, emphasis and inline code allowed) under a :::kpi, a ::table, a Markdown
table, a Mermaid diagram or an image (::chart and ::map take source= directly).
:::howto{caption= adds a visible caption and a folded reading guide beneath a chart, and
:::limits{visible= folds caveats past the first visible bullets (both unfold in
?print=1 and in PDF).
cols is the most tiles per row, 1 to 6, and 4 by default; a tile narrower than 9 rem wraps to the
next row, so a row of six in a slide becomes two rows instead of cutting its values. A figure never
breaks inside a word: when one value of the row is long (23 lorems), every figure of the row
shrinks with its tile, down to 1 rem, then wraps between two words. In a 16:9 slide, keep four
figures per row at most.
A ready chart of type: "kpi" is a row of key figures too: ::chart{data= draws it. A text value
is already formatted and shown as it is ("× 1.8"); a number is formatted in the story's language,
followed by the chart's unit, joined by a no-break space the way the language writes it (12% in
English, 12 % in French). Its title, subtitle and source frame the row.
charts/figures.json
size=large draws very large key figures in taller tiles, on both :::kpi and a ready kpi chart
(::chart{data=; on any other ready chart type size=large is an error; over a
scatter table size= still names a column). Without cols=, it lays out two columns (one when
there is a single figure); cols=1 or cols=2 is kept, and cols=3 to 6 is an error with its
line.
Markdown
In code
@recit/data also exports the React components Value, DataTable, Chart and Kpi (with
size="large" for very large key figures in one or two columns), which take data already computed,
for an MDX page or a story of the workshop, plus renderChart(spec, table) and
renderChartSpec(spec, options) (size: on a kpi spec), the pure functions that draw a
chart as hast. Passing static: true in RenderChartOptions (or in
dataDirectives(tables, { static:) omits the « Data » <details> disclosure for image
exports while keeping the <title> and <desc> of the SVG.