10 November 2026, brought up to date on 14 November

Designing tabelline 0.2

tabelline 0.2: summing up, rows and columns, more formats, every locale, pictures in cells, cells with more than one value, the tails, and what the stories and the book asked for before the tag. Each group from zero, simplest first, with the choices behind it and how it is built.

0.1 had the parts of a table, from the title to the footer, and the formats for single values. 0.2 was going to add rows and merges; on the day 0.1 shipped, it grew to hold every format, every locale and pictures in cells too, then cells that hold more than one value, and the tails of what was still partial. Last, before the tag, came what two stories and the book could not write yet: shapes in a cell, a preview that picks its rows, summary labels in Italian, and 29 things the book's chapters had worked around. That is eight groups of features, each built in its own pull request and explained here, from the simplest idea up. Every name they add is in the Reference, and A reference in our own style tells how that page was made.

Eight groups

Each group needs the ones before it: summing up comes first because summary columns, in the second group, reuse its aggregates; pictures come late because nanoplots need the formats and the options of the groups before them, and lists and records come after them because they feed the pictures. The tails finish what the others began. The last group is what using 0.2 found: a story and a book are written with the release, and what they need goes in before the tag.

0.2 in eight groups
what it addsnow
1 · Summing upsummary rows for each group and for the whole table; aggregatesbuilt
2 · Rows and columnsmerged columns, added columns and rows, summary columns, hidden rows, stub indent, decimal alignmentbuilt
3 · More formatsunits, fractions, chemistry, bins, automatic formats, country namesbuilt
4 · Every localenumbers, currencies and dates from CLDR; rotated labels, more options, extract, preview, body styles, datasetsbuilt
5 · Pictures in cellsicons, images and nanoplots, all inlinedbuilt
6 · More than one valuelists and records in a cell, the dot (v.x, it.mass), nanoplots of x and ybuilt
7 · The tailsa stub of several columns, groups as a column, the other options, images anywhere, font stacks, gt's datasetsbuilt
8 · What the stories and the book asked forshapes in a cell, rows from the middle in a preview, summary labels in another language, the book's 29 gapsbuilt

1 · Summing up

One number for a group

The simplest summary is one number: the moons of each kind of planet. summaryRows adds a row under each group, labelled in the stub, for each pair of a label and an aggregate:

let moons = tabella(planets(), rownameCol = "planet", groupnameCol = "type"):
  colsHide ["mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "rings"]
  summaryRows:
    total: agg.sum
  optCssTheme()
nbTable moons
moons
Terrestrial
Mercury0
Venus0
Earth1
Mars2
total3
Gas giant
Jupiter95
Saturn146
total241
Ice giant
Uranus28
Neptune16
total44

Under summaryRows: each line is a pair: the label of the row and how to sum up a column. It is the same call as summaryRows fns = {"total": agg.sum}, the list of pairs gt calls fns. columns is not given, so every numeric column is summed up, here only moons.

And one for the whole table

grandSummaryRows does the same for every row of the table, whatever its group, after a double rule. Several aggregates give several rows:

let allMoons = tabella(planets(), rownameCol = "planet", groupnameCol = "type"):
  colsHide ["mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "rings"]
  summaryRows:
    total: agg.sum
  grandSummaryRows:
    "all moons": agg.sum
    most: agg.max
    planets: agg.count
  optCssTheme()
nbTable allMoons
moons
Terrestrial
Mercury0
Venus0
Earth1
Mars2
total3
Gas giant
Jupiter95
Saturn146
total241
Ice giant
Uranus28
Neptune16
total44
all moons288
most146
planets8

The aggregates are agg.sum, agg.mean, agg.median, agg.min, agg.max, agg.count and agg.std. aggregate(proc) makes one from any proc of the column's values, such as the middle value: aggregate((vs: seq[Value]) => vs[vs.len div 2]).

Formatted like their column

A summary cell is a number like the others in its column, so it takes the column's format: the masses keep their three decimals, the diameters their thousands separator. A count is a count of rows, not a mass, so it is always an integer; fmt gives the rows of one call a format of their own:

let sizes = tabella(planets(), rownameCol = "planet", groupnameCol = "type"):
  colsHide ["density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "rings", "moons"]
  fmtNumber "mass", decimals = 3, dropTrailingZeros = true
  fmtInteger "diameter"
  summaryRows:
    total: agg.sum
    columns = "mass"
    missingText = ""
  grandSummaryRows:
    mean: agg.mean
    fmtNumber(decimals = 0)
  optCssTheme()
nbTable sizes
massdiameter
Terrestrial
Mercury0.334,879
Venus4.8712,104
Earth5.9712,756
Mars0.6426,792
total11.812
Gas giant
Jupiter1,898142,984
Saturn568120,536
total2,466
Ice giant
Uranus86.851,118
Neptune10249,528
total188.8
mean33350,087

missingText = "" leaves the cells of the columns that are not summed up empty (gt writes a dash, and so does tabelline by default). A line name = value in a block is a named argument. The grand mean is formatted by the line fmtNumber(decimals = 0): in a summary block it stands for fmt = (x: float) => formatNumber(x, decimals = 0), a proc of a float, like Great Tables' vals.fmt_*.

Choices

Each choice says what gt (R) and Great Tables (Python) do.

2 · Rows and columns

Two columns in one cell

The simplest merge puts two values in one cell: a range, from the start to the end. The end column is hidden, and an empty end leaves just the start:

let missions = tableData:
  mission: ["Voyager 1", "Galileo", "Cassini", "Juno"]
  launch: [1977, 1989, 1997, 2011]
  ended: [nil, 2003, 2017, nil]
  target: ["Jupiter, Saturn", "Jupiter", "Saturn", "Jupiter"]
  moon: [nil, "Io", "Titan", nil]
let merged = tabella(missions, rownameCol = "mission"):
  colsMergeRange "launch", "ended"
  colsMerge ["target", "moon"], pattern = "{1}<< and {2}>>"
  optCssTheme()
nbTable merged
launchtarget
Voyager 11977Jupiter, Saturn
Galileo1989–2003Jupiter and Io
Cassini1997–2017Saturn and Titan
Juno2011Jupiter

colsMerge writes the cells with a pattern: {1} and {2} are the columns, and the part between << and >> is left out when a value it names is missing (Voyager has no moon). Three merges are ready-made: colsMergeRange (1989–2003), colsMergeUncert (12.3 ± 0.4) and colsMergeNPct (12 (4.5%)). Each joins the formatted values, so formats still apply.

Columns and rows of your own

A table can grow beyond its data: colsAdd adds a column, from values or from a proc of each row, and rowsAdd adds rows, into a group when they name one. rowsHide takes rows out of view:

let grown = tabella(planets(), rownameCol = "planet", groupnameCol = "type"):
  colsHide everything()
  colsAdd "moons per Earth mass", (r: Row) => toValue(r.moons.toFloat / r.mass.toFloat * 5.97)
  fmtNumber "moons per Earth mass", decimals = 1
  rowsHide where(it["type"] == "Terrestrial")
  rowsAdd [(planet: "Pluto", `type`: "Dwarf planet", moons: 5, mass: 0.0130)]
  optCssTheme()
nbTable grown
moons per Earth mass
Gas giant
Jupiter0.3
Saturn1.5
Ice giant
Uranus1.9
Neptune0.9
Dwarf planet
Pluto

Pluto is added with only the columns it needs; the proc of colsAdd ran on the data before it, so its cell is missing (add the row first to have it computed). The data the table started from is never changed: a verb that adds a row or a column makes a new one, so other tables made from the same data stay as they were.

Totals across a row

Summary rows sum up down a column; summaryColumns sums up across a row, with the same aggregates. Together they make the table of totals, where the corner is the grand total:

let medals = tableData:
  country: ["Norway", "Germany", "Italy", "United States"]
  gold: [16, 12, 7, 9]
  silver: [8, 10, 8, 10]
  bronze: [13, 5, 9, 6]
let totals = tabella(medals, rownameCol = "country"):
  summaryColumns:
    total: agg.sum
  grandSummaryRows:
    all: agg.sum
  optCssTheme()
nbTable totals
goldsilverbronzetotal
Norway1681337
Germany1210527
Italy78924
United States910625
all443633113

Indents and decimal marks

Two small things make long tables read better. tabStubIndent indents row labels, for items inside items; colsAlignDecimal lines numbers up on their decimal mark, whatever their number of decimals:

let budget = tableData:
  item: ["Hardware", "Laptops", "Screens", "Travel", "Trains", "Hotels"]
  eur: [5200.0, 4000.0, 1200.0, 900.0, 312.5, 587.25]
let aligned = tabella(budget, rownameCol = "item"):
  tabStubIndent [1, 2, 4, 5], "increase"
  fmtNumber "eur", decimals = 2, dropTrailingZeros = true
  colsAlignDecimal "eur"
  optCssTheme()
nbTable aligned
eur
Hardware5,200   
Laptops4,000   
Screens1,200   
Travel900   
Trains312.5 
Hotels587.25

The alignment pads each number on the right with figure spaces, which are as wide as a digit (and a punctuation space where there is no mark): it needs no CSS, so it works in the text and Markdown outputs too.

Choices

3 · More formats

A unit in a label

The simplest unit is in a column label: a density in kilograms per cubic metre. Between {{ and }}, a label is written in gt's units notation, where ^ starts a power:

let labelled = tabella(planets(), rownameCol = "planet"):
  colsHide everything()
  colsUnhide ["density", "gravity"]
  colsLabel:
    density: "density, {{kg/m^3}}"
    gravity: "gravity, {{m s^-2}}"
  optCssTheme()
nbTable labelled
density, kg/m3gravity, m s−2
Mercury54293.7
Venus52438.9
Earth55149.8
Mars39343.7
Jupiter132623.1
Saturn6879.0
Uranus12708.7
Neptune163811.0

colsUnits({"density": "kg/m^3"}) does the same without touching the label, with a pattern for where the units go (unitsPattern = "{1} ({2})"). Units work in spanners and in the stubhead too.

Units in cells

When the units differ from row to row, they go in a column of their own, and fmtUnits reads each cell. The notation has a few more signs: _ starts a subscript, a unit after a lone / is a power −1, :mu: and other names between colons are symbols, degC is °C:

let constants = tableData:
  constant: ["speed of light", "gravity", "Boltzmann", "vacuum permeability", "room"]
  value: [299792458.0, 9.80665, 1.380649e-23, 1.25663706e-6, 20.0]
  units: ["m /s", "m s^-2", "J /K", "N A^-2", "degC"]
let physics = tabella(constants, rownameCol = "constant"):
  fmtAuto "value"
  fmtUnits "units"
  optCssTheme()
nbTable physics
valueunits
speed of light2.998 × 108m s−1
gravity9.807m s−2
Boltzmann1.381 × 10−23J K−1
vacuum permeability1.257 × 10−6N A−2
room20°C

fmtAuto picked a format for the values: scientific notation for the very large and the very small, up to three decimals for the others. It looks at each column's values, and formats a currency when the column's name ends with its code (price_eur).

Chemistry

Chemical formulas are units with their own rules: a digit after an element is a subscript, a number before a formula is a count, a charge follows a caret, and arrows join the two sides of a reaction:

let reactions = tableData:
  name: ["water", "rust", "photosynthesis", "ammonia"]
  reaction: ["2H2 + O2 -> 2H2O", "4Fe + 3O2 -> 2Fe2O3", "6CO2 + 6H2O -> C6H12O6 + 6O2", "N2 + 3H2 <=> 2NH3"]
  ion: ["OH-", "Fe^3+", "HCO3-", "NH4+"]
let chemistry = tabella(reactions, rownameCol = "name"):
  fmtChem ["reaction", "ion"]
  optCssTheme()
nbTable chemistry
reactionion
water2 H2 + O2 → 2 H2OOH−
rust4 Fe + 3 O2 → 2 Fe2O3Fe3+
photosynthesis6 CO2 + 6 H2O → C6H12O6 + 6 O2HCO3−
ammoniaN2 + 3 H2 ⇌ 2 NH3NH4+

Fractions

A recipe reads better in fractions. fmtFraction finds the closest fraction with a small denominator (up to 9, 99 or 999), or with a denominator you give, and writes it inline or diagonal:

let flour = tableData:
  ingredient: ["flour", "sugar", "butter", "salt"]
  cups: [2.25, 0.333, 0.5, 0.0625]
let recipe = tabella(flour, rownameCol = "ingredient"):
  colsAdd "diagonal", flour["cups"].values
  colsAdd "in sixteenths", flour["cups"].values
  fmtFraction "cups"
  fmtFraction "diagonal", layout = "diagonal"
  fmtFraction "in sixteenths", denominator = 16, simplify = false
  optCssTheme()
nbTable recipe
cupsdiagonalin sixteenths
flour2 1/421⁄42 4/16
sugar1/31⁄35/16
butter1/21⁄28/16
salt1/91⁄91/16

Bins and country names

Two formats turn codes into words. fmtBins reads intervals as R's cut() and pandas' cut write them, [10,20), and shows a range; fmtCountry reads country codes and shows their names, from the Unicode CLDR:

let visitors = tableData:
  country: ["IT", "FRA", "DE", "JP"]
  stay: ["[1,3)", "[3,7)", "[7,14)", "[14,28)"]
  visits: [1200, 830, 610, 95]
let visits = tabella(visitors):
  colsAdd "flag", visitors["country"].values, before = "country"
  fmtFlag "flag"
  fmtCountry "country"
  fmtBins "stay", fmt = x => formatNumber(x, 0)
  colsLabel:
    flag: ""
    stay: "nights"
  optCssTheme()
nbTable visits
countrynightsvisits
🇮🇹Italy1–31200
🇫🇷France3–7830
🇩🇪Germany7–14610
🇯🇵Japan14–2895

fmt formats each end of an interval, here as an integer. fmtCountry takes two- and three-letter codes, in any case. fmtPassthrough is the last of the group: it shows a value as it is, in a pattern.

Choices

4 · Every locale

A number in another language

The simplest thing a locale changes is the marks of a number: which character groups the thousands, which one starts the decimals. A table takes a locale, and every format follows it:

let amounts = tableData:
  n: [1234567.891, 0.5]
  share: [0.256, 0.5]
let italian = tabella(amounts, locale = "it"):
  fmtNumber "n", decimals = 2
  fmtPercent "share"
  optCssTheme()
nbTable italian
nshare
1.234.567,8925,6%
0,5050,0%

A format can also take a locale of its own, which wins over the table's. That is how one table can show the same number in four languages, one column each:

let marks = tabella(amounts):
  colsHide "share"
  colsAdd "it", amounts["n"].values
  colsAdd "de_CH", amounts["n"].values
  colsAdd "fr", amounts["n"].values
  fmtNumber "n", decimals = 2
  fmtNumber "it", decimals = 2, locale = "it"
  fmtNumber "de_CH", decimals = 2, locale = "de-CH"
  fmtNumber "fr", decimals = 2, locale = "fr"
  colsLabel:
    n: "en"
  optCssTheme()
nbTable marks
enitde_CHfr
1,234,567.891.234.567,891'234'567.891 234 567,89
0.500,500.500,50

locale is a tag of Unicode CLDR, in any case, with - or _. An unknown region falls back to its language ("it-XX" is "it") and an unknown language to English. The French group mark is a narrow no-break space, as CLDR has it.

Money

A currency adds a symbol, a number of decimals and a place for the symbol, which depends on the language, not on the currency: the euro goes before the amount in English and after it in Italian. Every code of ISO 4217 that CLDR knows (305 of them) has its symbol and its decimals:

let prices = tableData:
  item: ["espresso", "pizza", "refund"]
  eur: [1.3, 7.04, -2.5]
  jpy: [480, 1600, -300]
  bhd: [0.6, 2.9, -0.8]
let money = tabella(prices, rownameCol = "item", locale = "it"):
  fmtCurrency "eur", currency = "EUR"
  fmtCurrency "jpy", currency = "JPY", accounting = true
  fmtCurrency "bhd", currency = "BHD", placement = "left"
  optCssTheme()
nbTable money
eurjpybhd
espresso1,30 €480 ¥BHD 0,600
pizza7,04 €1.600 ¥BHD 2,900
refund−2,50 €(300 ¥)−BHD 0,800

The yen has no decimals and the Bahraini dinar three, as CLDR says. accounting = true writes a negative amount in brackets; placement = "left" puts the symbol first whatever the locale.

Dates in their own words

A date needs more: the names of months and days, and an order. gt has two kinds of date style: fixed ones, with an order of their own and the names in the locale's language ("day_month_year"), and flexible ones, named by the parts they show ("yMMMd": year, short month, day), which each language writes in its own order:

type Way = object
  locale, fixed, flexible, time: string
var ways: seq[Way]
for l in ["en", "it", "de", "ja", "ru"]:
  ways.add Way(locale: l, fixed: formatDate("2026-11-07", "wday_day_month_year", l),
               flexible: formatDate("2026-11-07", "yMMMEd", l), time: formatTime("14:35", "hm", l))
let dates = tabella(ways, rownameCol = "locale"):
  colsLabel:
    fixed: "wday_day_month_year"
    flexible: "yMMMEd"
    time: "hm"
  optCssTheme()
nbTable dates
wday_day_month_yearyMMMEdhm
enSaturday 7 November 2026Sat, Nov 7, 20262:35 PM
itsabato 7 novembre 2026sab 7 nov 20262:35 PM
deSamstag 7 November 2026Sa., 7. Nov. 20262:35 PM
ja土曜日 7 11月 20262026年11月7日(土)午後2:35
ruсуббота 7 ноября 2026сб, 7 нояб. 2026 г.2:35 PM

formatDate and formatTime are the plain functions under fmtDate and fmtTime; a table's locale reaches them through the verbs. The fixed style keeps its order in every language (so Japanese reads oddly); the flexible one is CLDR's own pattern for each locale.

Big tables, and tables as data

The rest of the group is small tools that gt has and 0.1 did not. A long table can be previewed, its first and last rows with a row that names the rows left out; and a style can come from the data:

let islands = tabellaPreview(isole(), topN = 5, bottomN = 1):
  colsHide "city"
  fmtInteger ["area", "population"]
  tabStyleBody style.text(weight = "bold"), columns = "country", values = ["Italy"], targets = "row"
  optCssTheme()
nbTable islands
islandcountryareapopulation
1SicilyItaly25,8345,010,001
2SardiniaItaly24,1001,656,000
3CyprusCyprus9,251
4CorsicaFrance8,681322,000
5CreteGreece8,312622,871
6..193
194PetalasGreece60

tabellaPreview takes a body of verbs, as tabella does. tabStyleBody styles the cells whose value is one of values (or contains a pattern, or makes a proc true), or here their whole row. fromColumn("colour") inside any style takes the value from another column of the same row: style.fill(fromColumn("colour")).

A label can lie on its side where many narrow columns have long names: a column of check marks needs one character, its label a word or two.

let traits = tabella(planets(), rownameCol = "planet"):
  colsAdd "rocky", proc (r: Row): Value = toValue(r["type"].s == "Terrestrial")
  colsAdd "has moons", proc (r: Row): Value = toValue(r.moons.i > 0)
  colsAdd "has rings", proc (r: Row): Value = r.rings
  colsHide ["type", "mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "moons", "rings"]
  fmtTf ["rocky", "has moons", "has rings"]
  colsAlign alCenter, ["rocky", "has moons", "has rings"]
  colsLabelRotate ["rocky", "has moons", "has rings"]
  optCssTheme()
nbTable traits
rockyhas moonshas rings
Mercury✓✗✗
Venus✓✗✗
Earth✓✓✗
Mars✓✓✗
Jupiter✗✓✓
Saturn✗✓✓
Uranus✗✓✓
Neptune✗✓✓

Once built, a table can be read back as data: extractCells gives the shown text of some cells, extractBody the whole body and extractSummary the summary rows, each as a TableData:

let back = tabella(extractSummary(sizes)):
  optCssTheme()
nbTable back
grouplabelmassdiameter
Terrestrialtotal11.812
Gas gianttotal2,466
Ice gianttotal188.8
mean33350,087

The group also adds 72 of gt's options (142 in all: every rule of the heading, the labels, the groups, the body, the stub and the footer, with its style, width and colour), two datasets (isole(), the islands of the Mediterranean, and citta(), the cities of the European Union, from Rethinking tabelline's datasets), and renames agg.sd to agg.std.

Choices

5 · Pictures in cells

An icon for a word

The simplest picture is an icon: a cell says its name, and the table draws it. gt and Great Tables both take the icons of Font Awesome, and so does tabelline, all 2,163 free ones:

let outputs = tableData:
  output: ["HTML", "text", "Markdown"]
  icon: ["globe", "terminal", "fab fa-markdown"]
  verb: ["toHtml", "toText", "toMarkdown"]
let goes = tabella(outputs, rownameCol = "output"):
  fmtIcon "icon", height = "1.5em"
  optCssTheme()
nbTable goes
iconverb
HTMLtoHtml
texttoText
MarkdowntoMarkdown

A name is a short name ("globe": the regular style when there are two), a full one ("fab fa-markdown", the brands style) or an older name ("user-large" is "user"). An icon takes the colour of the text unless fillColor says otherwise; fillColors colours each name its own way. In a text table the names stay.

A picture of your own

A file is a picture too. fmtImage reads it when the verb is called and puts it in the page as a data URL, so the page still needs nothing else:

let pictures = tableData:
  what: ["la tavola pitagorica, to 3"]
  picture: ["tavola"]
let own = tabella(pictures, rownameCol = "what"):
  fmtImage "picture", path = "docs/devlog/data/designing-0-2", filePattern = "{x}.svg", height = "3em"
  optCssTheme()
nbTable own
picture
la tavola pitagorica, to 3tavola

path and filePattern turn the cell "tavola" into the file docs/devlog/data/designing-0-2/tavola.svg. An address (https://...) is left as it is: tabelline loads nothing remote.

A plot as small as a word

A nanoplot is a plot in a cell. With one number per row it is a bar, and the bars of a column share their zero line, so they can be compared up and down the column. Here the five largest cities of the EU, by people:

let big = tabellaPreview(citta(), topN = 5, bottomN = 0, inclRownums = false):
  colsHide "counted"
  colsAdd "bar", proc (r: Row): Value = r.population
  fmtInteger "population"
  fmtNanoplot "bar", plotType = "bar",
    options = nanoplotOptions(dataBarFillColor = "var(--primary)", dataBarStrokeColor = "var(--primary)")
  colsLabel:
    bar: ""
  optCssTheme()
nbTable big
citystatepopulation
BerlinGER3,913,6443.91M
MadridESP3,506,7303.51M
RomeITA2,745,0622.75M
ParisFRA2,047,6022.05M
ViennaAUT2,044,3662.04M
6..95

fmtNanoplot on a column of numbers draws one bar per row. The bar shows its value when the pointer is over it (or a finger taps it): the SVG carries the text, and the table's CSS shows it on :hover, without JavaScript.

Many values in a cell

A cell can hold many values, "1 4 2 8", and then a nanoplot is a line, a bar or a box plot of them. The box plot is the one that says most about a group: here the people of the large cities of each country, in thousands. The box holds the middle half, the whiskers the rest, and each dot far away is a capital:

type Country = object
  state: string
  cities: int
  people: string
var byState: OrderedTable[string, seq[string]]
let eu = citta()
for i in 0 ..< eu.nrows:
  byState.mgetOrPut(eu["state", i].s, @[]).add $(eu["population", i].toFloat / 1000)
var countries: seq[Country]
for state, people in byState:
  if people.len >= 4: countries.add Country(state: state, cities: people.len, people: people.join(" "))
countries.sort((a, b) => cmp(b.cities, a.cities))
let boxes = tabella(countries, rownameCol = "state"):
  fmtNanoplot "people", plotType = "boxplot",
    options = nanoplotOptions(dataBarStrokeColor = "var(--primary)")
  colsLabel:
    people: "people, thousands"
  optCssTheme()
nbTable boxes
echo boxes
citiespeople, thousands
GER23301344565616756
ESP13303366479693841
ITA93163916269051.36K
POL9321384534673817
FRA7313345523709891
NLD4378522622742946
┌─────┬────────┬───────────────────────────┐
│     │ cities │ people, thousands         │
╞═════╪════════╪═══════════════════════════╡
│ GER │     23 │ 301 ┤344 │565│ 616├ 756   │
│ ESP │     13 │ 303 ┤366 │479│ 693├ 841   │
│ ITA │      9 │ 316 ┤391 │626│ 905├ 1.36K │
│ POL │      9 │ 321 ┤384 │534│ 673├ 817   │
│ FRA │      7 │ 313 ┤345 │523│ 709├ 891   │
│ NLD │      4 │ 378 ┤522 │622│ 742├ 946   │
└─────┴────────┴───────────────────────────┘

A cell of nanoplot values is a text of numbers separated by spaces, commas or semicolons, with NA for a missing one (or, since group 6, a list of numbers). The box plots of a column share their scale. echo prints the table as text, where a box plot is its five numbers: whisker, quartile, median, quartile, whisker.

colsNanoplot makes such a cell from several columns of a row, and hides them; a line or bar plot can have a reference line (a number, or "mean", "median", "q1" ...) and a reference area, and with autoscale every plot of the column shares its y axis. The guide draws the times table that way.

Choices

6 · More than one value

A list in a cell

Until now a cell held one value: a number, a text, a date. Nanoplots needed several, and read them from a text, "1 4 2 8". Now a cell can hold a list, made from any seq:

let sistema = tableData:
  planet: ["Earth", "Mars", "Jupiter"]
  moons: [@["Moon"], @["Phobos", "Deimos"], @["Io", "Europa", "Ganymede", "Callisto"]]
echo tabella(sistema, rownameCol = "planet")
echo sistema["moons", 2][0], " ", sistema["moons", 2].len
┌─────────┬────────────────────────────────┐
│         │ moons                          │
╞═════════╪════════════════════════════════╡
│ Earth   │ Moon                           │
│ Mars    │ Phobos, Deimos                 │
│ Jupiter │ Io, Europa, Ganymede, Callisto │
└─────────┴────────────────────────────────┘
Io 4

A list is shown as its items, separated by commas. v[0] is its first item and v.len how many it has. A list is not a number: numeric() leaves a list column out, and toFloat refuses a list.

A format applied to a list works on each item, and the verbs that take several names (icons, images, flags) take a list as they take names separated by commas.

A record, and the dot

A record is a cell with named fields, made from an object or a named tuple, as a row of toTableData is. Its fields are read by name, with brackets or with a dot:

let sensors = tableData:
  sensor: ["north", "south"]
  span: [(lo: 0.82, hi: 1.56), (lo: 9.13, hi: 12.71)]
let ranges = tabella(sensors, rownameCol = "sensor"):
  fmtNumber "span", decimals = 1
echo ranges
echo sensors["span", 0].hi, " ", sensors["span", 0]["lo"]
┌───────┬───────────────────┐
│       │ span              │
╞═══════╪═══════════════════╡
│ north │ lo: 0.8, hi: 1.6  │
│ south │ lo: 9.1, hi: 12.7 │
└───────┴───────────────────┘
1.56 0.82

fmtNumber formats each field of the record. .hi reads a field by name; on a row, the same dot reads a column, so where(it.mass > 1) is the way to write a row predicate from now on.

"lo: 0.8, hi: 1.6" says what each number is, but a range reads better as "0.8–1.6". A merge pattern reads the fields of a record by name, so one column of records is enough:

let spans = tabella(sensors, rownameCol = "sensor"):
  fmtNumber "span", decimals = 1
  colsMerge ["span"], pattern = "{lo}–{hi}"
echo spans
┌───────┬──────────┐
│       │ span     │
╞═══════╪══════════╡
│ north │ 0.8–1.6  │
│ south │ 9.1–12.7 │
└───────┴──────────┘

In a colsMerge pattern, {lo} is the field lo of the first column and {2.lo} of the second; each is formatted as its column is, and a missing field drops its <<...>> part. A field that is not in every record fails when the verb is called.

A plot of x and y

A record of two lists, x and y, is what Great Tables takes for a nanoplot whose points are not evenly spaced: each value is drawn at its place on the x axis. Two runners and their lap times, measured at different laps:

let laps = tableData:
  runner: ["Anna", "Bruno"]
  times: [(x: @[0.0, 1, 2, 5], y: @[62.0, 60, 61, 58]), (x: @[0.0, 3, 4, 5], y: @[65.0, 63, 66, 59])]
let race = tabella(laps, rownameCol = "runner"):
  fmtNanoplot "times", autoscale = true,
    options = nanoplotOptions(dataLineStrokeColor = "var(--primary)", dataPointFillColor = "var(--primary)")
  colsLabel:
    times: "lap times, seconds"
  optCssTheme()
nbTable race
echo race
lap times, seconds
Anna665862606158
Bruno665865636659
┌───────┬────────────────────┐
│       │ lap times, seconds │
╞═══════╪════════════════════╡
│ Anna  │ ▅▃▄▁ 58–62         │
│ Bruno │ ▇▅█▂ 59–66         │
└───────┴────────────────────┘

autoscale gives both plots the same axes, x and y. In text, the sparkline follows the order of x and leaves out its spacing.

Choices

7 · The tails

A stub of several columns

The stub held one column, the row names. Now it can hold a few, the highest level first, and a value equal to the one above it is drawn once, over all the rows that repeat it:

let garage = tableData:
  maker: ["Ferrari", "Ferrari", "Fiat", "Fiat", "Lancia"]
  model: ["Roma", "Purosangue", "500e", "Panda", "Ypsilon"]
  hp: [612, 725, 118, 70, 156]
let cars = tabella(garage, rownameCol = ["maker", "model"]):
  optCssTheme()
nbTable cars
hp
FerrariRoma612
Purosangue725
Fiat500e118
Panda70
LanciaYpsilon156

rownameCol takes a list instead of a name. loc.stub(cols = "maker") styles one level; stubColumns(cars) is @["maker", "model"]. In text the repeated value is left blank.

Groups as a column

A group's label can be a column of the stub too, beside its rows, instead of a row above them:

let fleet = tableData:
  model: ["Roma", "Purosangue", "500e", "Panda"]
  kind: ["sport", "sport", "city", "city"]
  hp: [612, 725, 118, 70]
let byKind = tabella(fleet, rownameCol = "model", groupnameCol = "kind", rowGroupAsColumn = true):
  summaryRows:
    most: agg.max
  optCssTheme()
nbTable byKind
hp
sportRoma612
Purosangue725
most725
city500e118
Panda70
most118

rowGroupAsColumn = true when the table is made, or tabOptions(rowGroupAsColumn = true) later. The label spans the group's rows and its summary rows.

The other options, images and fonts

tabOptions now has 164 options (165 with the one of group 8), 160 of gt's 196: hidden column labels, a units pattern for all columns, a label for the rows outside any group, notes on one line, a message for a table with no rows, the indent of a level, stripes in the stub. An image can go in a title or a label (localImage, webImage), a font stack has a name (systemFonts("old-style")), and a nanoplot can give each point its own colour. gt's gtcars, countrypops, illness and metro are in tabelline/datasets.

Choices

8 · What the stories and the book asked for

Two stories were written with 0.2, FOSDEM, twenty-six times and Islands of the Mediterranean, and the book ported 25 chapters of gt and Great Tables. What they could not write yet went into 0.2 before the tag.

A label in the reader's language

The islands story is in English and in Italian. Its tables sum up a sea with a row named total, and the Italian page wants totale. textTransform changes the text of any part, but on the label of a summary row it did nothing. Now it does:

let three = tableData:
  island: ["Sicily", "Sardinia", "Cyprus"]
  km2: [25834, 24100, 9251]
let inItalian = {"total": "totale"}.toTable
let sums = tabella(three, rownameCol = "island"):
  grandSummaryRows:
    total: agg.sum
  textTransform (s: string) => inItalian.getOrDefault(s, s), loc.grandSummaryStub()
  optCssTheme()
nbTable sums
km2
Sicily25834
Sardinia24100
Cyprus9251
totale59185

The label changes as shown text only: a location that names the row, loc.grandSummary(rows = "total"), still finds it.

Rows from the middle

tabellaPreview shows the first rows and the last, as gt's gt_preview() does. The islands of isole() are 194, from the largest down, and the story wanted Malta, in the middle. moreRows adds any rows, by index, range or condition, and a shaded row stands for each run left out:

let peek = tabellaPreview(isole(), topN = 2, bottomN = 1,
                          moreRows = where(it.island == "Malta")):
  colsHide ["population", "city"]
  optCssTheme()
nbTable peek
islandcountryarea
1SicilyItaly25834.0
2SardiniaItaly24100.0
3..33
34MaltaMalta246.0
35..193
194PetalasGreece5.5

An island's outline

The islands story wanted each island's shape beside its name, as small as a word. A nanoplot draws numbers, and a shape is numbers too: the corners of its outline, x east and y north. plotType = "shape" joins them in their order and closes the line; with autoscale every shape of the column is at the scale of the largest, so a small island looks small:

let plots = tableData:
  field: ["square", "strip", "corner"]
  outline: [toValue((x: @[0, 2, 2, 0], y: @[0, 0, 2, 2])),
            toValue((x: @[0, 4, 4, 0], y: @[0, 0, 1, 1])),
            toValue((x: @[0, 3, 3, 1, 1, 0], y: @[0, 0, 1, 1, 3, 3]))]
let shapes = tabella(plots, rownameCol = "field"):
  fmtNanoplot "outline", plotType = "shape", autoscale = true
  optCssTheme()
nbTable shapes
outline
square
strip
corner

The story draws every island this way, with their holes (a lake is a ring of its own), and lines up the nanoplots of a column of years on one x axis, with referenceX marking the places on it.

What the book still found

The book ported its second round of chapters, 17 of them, two days before the tag. They needed 29 more things, each small: tabStub for a table already made, columns by kind (ofKind(vkBool)) or by a test of the name (named(...)), rows from the end (-1), significant figures and accounting, gt's six optStylize styles, R's colour names, a mask for each cell, and a stub that stays in view while a wide table scrolls (stubSticky). Each is told, with a table, in What the book found for 0.2.

Choices

Next to gt and Great Tables

tabelline began on a Saturday night, a week before this release, as a port of gt and Great Tables. With 0.2 it is worth counting again, against the newest of each: Great Tables 1.1 and gt 1.4, by their references. The feature map has every group.

Feature by feature

tabelline 0.2 and Great Tables 1.1
what it has
only tabellinerowsAdd, rowsHide, rowOrder, colsAdd, summaryColumns; fmtSpelledNum, fmtBins, fmtAuto, fmtCountry (31 formats to 28); shape nanoplots; tabellaPreview with rows from the middle, tabCaption, extractCells, optTableLines; a stub that stays in view; 657 CLDR locales to 574; text and Markdown output, nimib
bothsummary rows, nanoplots, icons, images, units, chemistry, fractions, merged columns, stub indent, a stub of several columns, body styles, colour by value, every location, gt's six premade styles, a mask for each cell, about as many options (165 to 175), tables from a data frame (nanuq's in tabelline, Pandas and Polars in Great Tables)
only Great Tablesinteractive tables, LaTeX, PNG and PDF, Google fonts, Shiny, 16 datasets (tabelline has 9, four of them gt's)

So, feature by feature, tabelline 0.2 does more to a table than Great Tables does; Great Tables still takes a table to more places. gt is still ahead of both in features: it has the first two rows above, all but the text, Markdown and nimib output, and also LaTeX, RTF and Word, groups of tables, and 36 options tabelline does not have yet. Those outputs are the next release, Out of the browser. tabelline has two things of Great Tables that gt does not: rotated labels (colsLabelRotate) and any CSS in a style (style.css).

Where it goes its own way

Some things are in neither of them. They came from writing these pages, and they make tabelline a little different, not only a port:

Not in gt or Great Tables
tabellinegt and Great Tables
many tables on a pageone stylesheet, tabellaCss, written once; each table writes only the options it changes, as CSS variables, and a page can set an option for all its tableseach table carries its whole stylesheet in a style element scoped to its id (gt compiles it with sass for every table); as_raw_html(inline_css = TRUE) writes styles on every element
a table in a terminalecho t prints it as text, toMarkdown for a README; units, formulas and fractions in Unicode, nanoplots as sparklinesHTML (and LaTeX, RTF, Word in gt)
a table that follows the pageoptCssTheme(): colours and font from the page's CSS variablesopt_stylize() and tab_options(), with fixed colours
several values in a celllists and records (@[1, 4, 2], (lo: 0.8, hi: 1.6)), formatted item by item, read with the dot (v.hi), named in merge patterns ({lo}–{hi})list columns for nanoplots; cols_merge names columns only
the format of a summary cellits column's format and locale, unless summaryRows gives a fmtgt uses fmt_number(); Great Tables leaves the value as it is
what it needsthe core needs Nim's standard library, nothing else; nimib and nanuq only for their own optional modules (tabelline/nimib, tabelline/nanuq); nothing loaded from the networkgt imports 20 R packages, Great Tables 8 Python ones

The first row is the one of One stylesheet for every table: the API reference has 152 tables, and sharing their style took it from 1.71 MB to 0.88 MB. The format of a summary cell is one of the choices of What the book found for 0.2; another sides with Great Tables: aggregates skip missing values, as Polars does, where gt needs na.rm = TRUE.

A syntax of its own

The verbs are gt's, in camelCase. The way they are written is Nim's: a table is a block, one verb per line, and a verb that takes pairs takes them as an indented block. A row is it, and a condition on rows is plain Nim:

let syntax = tabella(planets(), rownameCol = "planet", groupnameCol = "type"):
  colsHide ["mass", "diameter", "density", "gravity", "day_length",
            "distance", "orbital_period", "mean_temp", "rings"]
  tabStyle style.text(weight = "bold"), loc.body("moons", where(it.moons > 10))
  summaryRows:
    total: agg.sum
  optCssTheme()
nbTable syntax
moons
Terrestrial
Mercury0
Venus0
Earth1
Mars2
total3
Gas giant
Jupiter95
Saturn146
total241
Ice giant
Uranus28
Neptune16
total44

tabella(data): body is a macro: each line of the body is a verb called on the table, with no dots and no pipes. where(it.moons > 10) is a template that makes a proc of the row, checked by the compiler like any Nim code; summaryRows: takes its pairs one per line. Without the sugar it is a chain of procs: initTabella(...), then .colsHide(...), .tabStyle(...) and .summaryRows(fns = {"total": agg.sum}).

In a notebook there is one step less. R and Python notebooks show the last value of a cell; in nimib, nbTable data: body makes the table and shows it, without naming it.

What it took

How much work is in a release made by agents? We measured it the way we did for nanuq (from its first commit to 0.6, in a week), with the same sources, so the numbers compare. 0.1 is what the tag v0.1.0 holds; 0.2 is everything merged after it, up to the release PR, on 14 November. The islands story, with its Italian page and the Minoan look made for it, was built alongside 0.2 and has a column of its own. The column tabelline is the three together, from the first commit, to set next to nanuq.

What it took
both from nothing; then tabelline in parts
nanuqtabelline0.10.2islands
days77.53.34.32.9
pull requests—8441421
threads333118132
token cost$636$997$374$438$185
tokens (billions)1.722.770.981.280.51
output (millions)5.17.72.93.41.4
agent hours25–3545–6617–2920–278–10
CI hours85133.57.71.6
lines (thousands)626226+28+7.6
developer months4–85.5–102–3.52–41.5–2.5

Where the numbers come from:

In all, 5.5 to 10 months of an experienced developer: a little more than nanuq.

0.2 added more than 0.1, in about the same time; with the islands story, they took a little more than nanuq's six releases.

How it is built

Everything above runs in one place, build.nim, the step every renderer shares. For each cell it now does, in order:

  1. format the value (formatCell: the last format that covers it, then any substitution);
  2. merge it with other columns, when a merge rule starts at its column (shownCell, with fillPattern for the pattern and its <<...>> parts);
  3. transform the text (textTransform).

Then, for the table as a whole:

  1. the rows go in display order, without the hidden ones, into their groups;
  2. each group gets its summary rows, and the table its grand ones: an aggregate gets the group's non-missing values of a column, and its result is formatted like the column (summaryOf, formatSummary);
  3. the columns aligned on the decimal mark get their padding, summary cells included (alignDecimals);
  4. the footnote marks are numbered in reading order, through the summary rows too.

The renderers only lay out the result: the HTML adds the classes tb_summary_row, tb_grand_summary_row and tb_indent_N; the text draws a dotted rule before a group's summary and a double one before the table's.

The formats of group 3 are plain functions, as the formats of 0.1 are, so they run in step 1. Units are read in three passes (units.nim): a part between % signs goes to the chemistry reader; the rest is split at spaces into tokens, and each token into a name, a subscript after _ and a power after ^ (unitToken); the tokens are joined again with spaces, none after an opening bracket or around a lone / (joinTokens). Chemistry reads a token a character at a time (chemToken): an isotope at the start, then a count, then elements, with digits after them as subscripts and a sign at the end as a charge. A superscript or a subscript is <sup> or <sub> in HTML and Unicode in text (toSuperscript, toSubscript). Labels go through renderLabel, which formats what is between {{ and }} and leaves the rest to the label's own kind of text (plain or Markdown).

The locales of group 4 are three tables (locales.nim): every value once, in one long string (localeValues); for each locale, the fields it says differently from its parent, each a field number and a value number (localeCellField, localeCellValue); and where each locale's fields start (localeTable). getLocale finds the locale by binary search, fills the fields it does not have from its parents, and gives a Locale object: marks, patterns, names. A format reads it once, when its verb is called. Dates are written by formatPattern, which reads a CLDR pattern a letter at a time: y the year, MMMM the month's name, LLLL its name standing alone (Russian has both), EEE the short weekday, h and a the hour and AM or PM, and text between quotes as it is.

The pictures of group 5 are formats too, so they also run in step 1. An icon is a line of fontawesome.tsv (name, style, width, label, the SVG path), found by name in a table built the first time an icon is needed (findIcon), and written as an <svg> as high as the text and as wide as its shape (iconSvg). An image is read and encoded in base64 when its verb is called (imageDataUrl), once per file. A nanoplot is drawn in nanoplots.nim as Great Tables draws it: the values are scaled to a box 100 units high, with the reference line, the area and zero in the same scale; then layer after layer is written from the bottom up (the reference area, the area under the line, the line, as Bézier curves, the bars, the reference line, the points, and last the guides that show a value on hover). A box plot computes its quartiles by linear interpolation and its whiskers by Tukey's rule (the farthest values within 1.5 boxes). The verb reads every cell of the column first, so the plots of a column share their scale.

Lists and records of group 6 are two more branches of Value, the object every cell is (core.nim): items, a seq of values, and fields, a seq of names and values in order. toValue makes a record by walking an object's fields with fieldPairs, as toTableData does for a row. The dot is a template, `.`, under Nim's experimental dotOperators: the compiler calls it only when a name is neither a field nor a proc, and it turns v.hi into v["hi"]; the same template on Row turns it.mass into it["mass"]. A format meets a list in step 1: formatCell gives each item (or field) to the format and joins the results, unless the format takes the list whole (wholeValue, set by the pictures). A nanoplot reads y and x from the record, sorts the pairs by x, and places each point at its share of the x axis.

Group 8 adds little to the steps, and most of it when a verb is called. A shape is drawn by shapePlot (nanoplots.nim): the side of its square is its width or its height, the larger (shapeSide, or the column's largest with autoscale), so across and up have one scale; the points become one path, a missing value starting a new ring, filled with the even-odd rule so that a ring inside another is a hole. tabellaPreview marks the rows to show (the top, the bottom and moreRows, resolved like any row selector) and adds a shaded row for each run of rows left out. A summary label goes through textTransform when the verb is called, like every label, but into a shown label kept beside it (shown), so the label itself stays the key that the locations find. A mask is a location: it is resolved when its verb is called, by calling the proc on every cell of its columns and rows. The sticky stub is only CSS: the stub's cells are position: sticky at the left edge, with the stub's background, so the cells that scroll go under them.

How the HTML of every table shares one stylesheet, also in 0.2, has a post of its own: One stylesheet for every table.