Any docs page can carry a chart or a diagram. You write it as a fenced code block and the shell renders it in place as an SVG — server-side, no chart library, no JavaScript. Everything picks up the reader's theme, so it stays legible in all eight of them.
There are three families of block, and the difference is what you are drawing:
chartplots numbers against a category axis: bar, column, pie, donut, line, area, candlestick. Reach for it when the question is how much.treeandflowlay out boxes and connectors: leadership structures, family trees, workflows, decision paths, idea frames. Reach for these when the question is how things relate.plotdraws statistics and mathematics on a numeric grid: scatter, histogram, box plot, function graph, radar, gauge, funnel, heatmap. Reach for it when the question is how the numbers are distributed, or when the picture is an equation.
Everything on this page is a live example: the picture under each snippet is what that snippet produces.
Part one — charts
Quick start
Open a fence, tag it chart, close it. Inside, write one setting per line as
key: value, then your data rows.
title: Monthly signups
type: bar
Jan: 120
Feb: 340
Mar: 220
Apr: 410
That gives you:
Order does not matter — settings and rows can be interleaved, though it reads better with the settings on top.
Chart types
Set type to one of these. If you leave it out you get a bar chart.
| Type | Good for |
|---|---|
bar | Comparing a handful of named things |
column | The same, with taller vertical columns |
stacked bar | Parts of a whole across several categories |
pie | Shares of one total, few slices |
donut | Shares of one total, with a headline number in the middle |
line | A value moving over time |
area | A value moving over time, with volume emphasis |
candlestick | Open / high / low / close price data |
Pie and donut
title: Traffic sources
type: donut
center: 4210
centerLabel: visits
Organic: 2100
Direct: 900
Referral: 610
Social: 600
center and centerLabel are donut-only — they print in the hole. Drop them
and the ring shows the total on its own.
Line and area
title: Page views
type: line
smooth: true
dots: true
Mon: 420
Tue: 510
Wed: 480
Thu: 640
Fri: 720
smooth: false gives you straight segments between points.
Candlestick
Four numbers per row, in the order open, high, low, close.
title: SPD close
type: candlestick
Mon: 10, 14, 9, 13
Tue: 13, 15, 12, 12
Wed: 12, 16, 11, 15
Thu: 15, 18, 14, 17
Writing the data
There are two ways to write a row, and they behave identically. Use whichever suits the label:
Organic search: 2100— colon form. The last colon on the line splits label from value, so labels may contain colons.Organic search | 2100— pipe form. Easier to read when the numbers vary in width.
Values are plain numbers. 1200, 12.5 and -40 are all fine; 1,200 is
not, because the comma separates values. A leading $ or a trailing % is
stripped for you, so $1200 and 12% both work.
A line starting with # is a comment and is ignored.
Several series
Give each row more than one number and name the columns with columns:
title: Visits and signups
type: column
columns: Visits, Signups
Jan | 1200 | 90
Feb | 1640 | 130
Mar | 1490 | 110
Apr | 1810 | 175
title: Visits and signups
type: column
stacked: true
columns: Visits, Signups
Jan | 1200 | 90
Feb | 1640 | 130
Mar | 1490 | 110
Apr | 1810 | 175
Add stacked: true (or write type: stacked bar) to stack them instead of
placing them side by side.
The same data can be written the other way round — one line per series, with the
category names declared once. Use labels for the categories and a series
line per set of numbers, where the part before the pipe is the series name:
title: Visits and signups
type: column
labels: Jan, Feb, Mar, Apr
series: Visits | 1200, 1640, 1490, 1810
series: Signups | 90, 130, 110, 175
Pick whichever shape you find easier to maintain; they produce the same chart.
Chart settings
Every one of these is optional.
Content
title— heading above the chart.caption— small grey line under the chart, for a source note or an explanation.labels— comma-separated category names, when you are usingserieslines rather than data rows.columns— comma-separated series names, when your data rows carry more than one number each.data— starts the data section. Optional, and if you use it, put it last: every line after it is treated as a data row.
Shape
type— see the table above.stacked—truestacks a multi-series bar or column chart.height— chart height in pixels, between 80 and 900. Left alone, charts size themselves to the column.
Numbers
prefix— printed before every value, e.g.prefix: $.suffix— printed after every value, e.g.suffix: %.decimals— decimal places, 0 to 6.
Look
colors— comma-separated hex or named colours, overriding the theme palette. Use this sparingly: the default palette is chosen to stay legible on dark themes, and a hard-coded colour will not adapt.smooth— curved rather than straight lines (lineandarea).dots— show a point marker at each value.track— show the soft band behind each bar.gradient— vertical gradient fill on bars and areas.center/centerLabel— the number and caption inside a donut.
Part two — trees and flows
Same idea, different block tag. Tag the fence tree for a hierarchy or flow
for a process. Instead of data rows you write an indented outline, and the
indentation is the structure.
Quick start
Every node line starts with a dash. Indent a line further than the one above it and it becomes that node's child.
title: Leadership
- Board of Directors
- CEO
- CTO
- COO
Leadership
Indent by two spaces per level. Any consistent amount works — what matters is that a deeper line is a child and a line at the same depth is a sibling.
Org charts
Add a second line to a box with |, and mark a box as important by putting *
in front of its label. Accented boxes use the theme's accent colour.
title: Reporting lines
- * Board of Directors | Governance
- CEO | Chief Executive
- CTO | Engineering
- Backend lead
- Frontend lead
- QA
- COO | Operations
- Support
- Logistics
- CFO | Finance
Reporting lines
Family trees
A family tree is the same shape — one line per person, children indented under the parent. Use the second line for dates or a role.
title: The Mwansa family
- Joseph Mwansa | 1938 – 2011
- Grace Mwansa | b. 1962
- Tandiwe
- Chanda
- Peter Mwansa | b. 1965
- Mulenga
The Mwansa family
One thing to know before you plan a big one: this draws a hierarchy, one
parent per node. It does not draw spouse pairs joined by a bar with the children
hanging off the middle. For a couple, put both names in one box —
- Joseph and Miriam Mwansa — and hang the children off that.
Workflows and decision flows
Tag the fence flow instead. Flows run left to right by default and draw
arrowheads. Put a word in brackets in front of a node and it labels the
connector coming into it, which is how you mark the branches of a decision.
title: Article publishing
- Draft submitted
- Editorial review
- (Approved) Schedule
- Publish
- (Rejected) Return to author
Article publishing
Set direction: down if a flow reads better vertically. Trees accept
direction: right too, which is often the better choice for a deep structure
with short labels.
Connections that are not parent and child
An outline can only say "this sits under that". When a step feeds back into an
earlier one, or two branches touch, add a link line. It draws a dashed
connector between any two boxes in the diagram, matched on their labels.
title: Idea to release
direction: down
- Idea
- Draft spec
- Build
- Review
- Ship
link: Review -> Draft spec | rework
Idea to release
Write it as link: From -> To, and add | label for a word on the connector.
link lines may sit anywhere in the block; keeping them at the bottom leaves
the outline readable.
Diagram settings
type—treeorflow. Usually you can leave it out, because the fence tag already says which one.direction—downorright. Trees default to down, flows to right.title— heading above the diagram.caption— small grey line underneath.arrows—trueorfalse, overriding the default (flows have arrowheads, trees do not).wrap— how many characters before a label wraps, 8 to 40. Raise it for long names that are breaking awkwardly.link— an extra connector, as above. Repeat the line for more than one.
Node line extras, all optional and combinable:
*before the label accents the box.(text)before the label labels the connector into that box.| textafter the label adds a small second line.
Part three — statistics and maths
Tag the fence plot. The type decides what is drawn, and the block accepts
numeric data on a real coordinate grid rather than a category axis.
Scatter
Rows are x, y pairs. Add trend: true for a least-squares line.
title: Height vs weight
type: scatter
x: Height (cm)
y: Weight (kg)
trend: true
150, 52
158, 55
163, 61
171, 66
178, 74
181, 79
Height vs weight
For more than one group, open each with a series line. Every row after it
belongs to that group until the next one.
title: Two groups
type: scatter
series: Group A
1, 2
2, 4
3, 5
series: Group B
1, 5
2, 6
3, 9
Histogram
Give it raw measurements and it does the binning. bins is optional — left
out, it uses the square root of the sample count.
title: Response times
type: histogram
x: Milliseconds
bins: 8
values: 12, 15, 19, 22, 24, 25, 26, 28, 29, 31, 33, 34, 35, 38, 41, 44, 52, 61, 88, 120
Response times
Box plot
One row per group, holding that group's raw values. The quartiles, the median and the whiskers are computed for you, and anything past 1.5 times the interquartile range is drawn as an outlier ring.
title: Scores by class
type: box
Class A: 12, 15, 18, 22, 30, 31, 33
Class B: 9, 14, 16, 17, 25, 60
Class C: 20, 21, 23, 24, 26
Scores by class
Function graphs
Write the equation on an f: line and it is plotted over the domain. Repeat
f: for more curves, and add | Name to label one in the legend. mark:
drops a labelled dot at a point — useful for roots, intercepts and turning
points.
title: Sine and parabola
type: function
domain: -6.5, 6.5
f: sin(x)
f: 0.1*x^2 - 1 | Parabola
mark: 0, 0 | origin
Sine and parabola
A leading y = is allowed and ignored, so f: y = 2x + 1 works.
What you can write. Operators + - * / ^ %, brackets, and implicit
multiplication (2x and 3(x+1) mean what you expect). Constants pi, tau
and e. Functions sin, cos, tan, asin, acos, atan, sinh, cosh,
tanh, sqrt, abs, ln, log (base 10), log2, exp, floor, ceil,
round, sign, and the two-argument pow, min, max, atan2, mod. The
variable is always x.
Anything undefined — a division by zero, the square root of a negative, an asymptote — breaks the curve rather than drawing a spike through the graph:
title: Discontinuities
type: function
domain: -5, 5
f: 1/x
f: tan(x)
Discontinuities
The vertical extent is chosen from the middle of the data so a single asymptote
cannot flatten everything else. Set range: -3, 3 when you want to fix it
yourself, and raise samples above the default 480 if a fast-oscillating curve
looks ragged.
Radar
Name the axes once, then one series line per thing being compared.
title: Model comparison
type: radar
axes: Speed, Power, Range, Cost, Weight
series: Model A | 8, 6, 7, 4, 5
series: Model B | 5, 9, 6, 7, 8
max: 10
Model comparison
For a single shape you can skip axes and write one labelled value per line
instead — Speed: 8, Power: 6, and so on.
Gauge
One number against a range. min defaults to 0 and max to 100.
title: Uptime this quarter
type: gauge
value: 99.4
suffix: %
decimals: 1
Uptime this quarter
Funnel
Stages in order, largest first. Each stage prints its value and its share of the first stage.
title: Signup funnel
type: funnel
Visitors: 12000
Signed up: 3400
Activated: 1200
Paid: 380
Signup funnel
Heatmap
Name the columns, then one row per band. Cell shading runs from the lowest value in the block to the highest.
title: Traffic by hour
type: heatmap
columns: Mon, Tue, Wed, Thu, Fri
00:00 | 3 | 5 | 2 | 8 | 4
06:00 | 12 | 15 | 11 | 14 | 9
12:00 | 30 | 34 | 29 | 41 | 22
18:00 | 22 | 25 | 19 | 33 | 40
Traffic by hour
Plot settings
type—scatter,histogram,box,function,radar,gauge,funnel,heatmap. You may also tag the fence with the type name directly and leave this out.titleandcaption— heading above, small note below.xandy— axis titles.domain— the x range, asdomain: -5, 5. On a function graph it decides what is plotted; elsewhere it clips the data.range— the y range. Left out, it is chosen from the data.trend— least-squares line on a scatter.bins— histogram bin count, 2 to 40.samples— points evaluated per curve on a function graph, 60 to 1200.axes— radar axis names.columns— heatmap column names.series— opens a scatter group, or carries a whole radar row.f— an equation to plot. Repeat for more.mark— a labelled point, asmark: 2, 4 | root.value,min,max— the gauge's number and its ends.maxalso caps a radar's outer ring.prefix,suffix,decimals— number formatting.height— 140 to 900 pixels.
Gotchas
Charts: data: swallows everything below it. It marks the start of the data
section, so any setting written after it is read as a row and quietly dropped.
Settings first, data: last — or leave data: out entirely, which is what the
examples on this page do.
Charts and plots: commas separate values, not thousands. 12,500 is read as
two numbers. Write 12500.
Charts: a row went missing. One unreadable number drops its whole row. Check
for a stray letter, a currency code like USD, or a thousands comma.
Diagrams: every node needs its dash. A line without a leading - is read as
a setting and ignored unless the name is one we know. That is also how a typo in
a setting name goes silent.
Diagrams: indent with something you can see. Tabs are accepted and counted as four spaces, but mixing tabs and spaces in one block produces depths you did not intend. Pick one and stay with it.
Diagrams: boxes all share one width. It is set by the longest label in the
block, so a single very long name makes every box wide. Shorten it, move the
detail to the second line after |, or raise wrap.
Diagrams: link matches on label text. If two boxes carry the same label,
the link attaches to the first one. Make the labels distinct.
Plots: an equation that will not compile is skipped. Only the names listed
under function graphs are known, the variable is always x, and scientific
notation like 1e-3 is not supported — write 0.001. If a curve is missing,
the expression is the place to look.
Plots: a blank graph means no usable data. Scatter needs two numbers per row, box plots need at least two values per group, radar needs three or more axes. When there is nothing to draw, the block is left on the page as plain code so you can see what you wrote.
Plots: the y range is trimmed on function graphs. The extremes of the
sampled values are ignored so an asymptote cannot squash the rest of the curve.
Set range explicitly if you need the full extent.
A code sample that begins with type: bar becomes a chart. So that untagged
fences still work, a block whose first line looks like a chart, diagram or plot
setting is rendered as one. If you are documenting that text and want it left
alone, put a comment or another line above it.
Nothing renders at all? The fence tag has to be exactly chart, tree,
flow or plot — not Chart, not charts, not diagram. If the block still
comes out as plain code, the page probably has an unclosed fence higher up.