A page that shows numbers should not copy them by hand. The data tile reads a JSON
file when the site is built and becomes the tile that draws it.
:::tile data
source: status.json
as: kpi
kpi: name
value: count
delta: change
:::
with status.json next to the page:
[
{"name": "Open issues", "count": 42, "change": "+3"},
{"name": "Closed this week", "count": 17}
]
The data tile becomes the tile it draws as, with the same lines the hand-written tile takes, and the same renderer draws it, so the two cannot differ.
The lines
sourceis the JSON file, relative to the page’s own folder and inside it: an array of flat objects, 500 rows at most.asiskpi,timeline,flow,pillorprogress.The mapping lines are the lines of that tile, each naming the key of every row that holds it. For
kpi:kpi,value,delta,trend,tone,note. Fortimeline:event,date,time,body. Forflow:fromandto, one edge a row. Forpill:statusandlabel. Forprogress:value,max,labelandstatus.orderfor a timeline andtitlefor a flow are written as for the tile itself.
A value is text, a number or true or false, and a number is written as a person would
write it (42, -2, 3.5). pill and progress are a stack, one tile for each row,
where the others are one tile for all the rows.
A whole board in one file
at names the key of a JSON object whose value is the array of rows, so one file can
feed a whole board, each part a data tile with its own at:
:::tile data
source: board.json
at: pills
as: pill
label: who
status: state
:::
with board.json next to the page:
{"pills": [{"who": "Build", "state": "running"}, {"who": "Docs", "state": "done"}]}
Here is that very file read by a data tile on this page:
A missing key under at is an error that names it, a value under at that is not an
array is an error, and at on a file that is a plain array is an error. The full
reference is “Data tile” in docs/authoring.md.