Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Sankey diagrams

sirene draws Mermaid sankey diagrams (sankey-beta) as images and as text. In text, each node lists its outgoing flows, with bars scaled to the largest flow:

---
title: Household budget
config:
  sankey:
    linkColor: source
    nodeAlignment: left
    prefix: "$"
---
sankey
"Salary, net",Budget,4200
Side work,Budget,600
Budget,Rent,1800
Budget,Food,700
Budget,Savings,1200
Budget,"The ""other"" pile",1100
Savings,Index fund,900
Savings,Cash,300
the drawing of the mermaid source above

In the editor a sankey diagram is read-only on the drawing side.

What is read

SyntaxDrawn as
source,target,valuea band from source to target as wide as the value; nodes are made on first use
"a, b",c,1a quoted name may hold ,; "" is a literal "
frontmatter titlethe title above
config.sankey.linkColorgradient (the default), source, target, or a color such as "#a1a1a1"
config.sankey.nodeAlignmentjustify (the default), left, right, or center
config.sankey.showValuesfalse leaves values out of the labels
config.sankey.prefix, suffixtext around each value, e.g. "$" or " TWh"
config.sankeyalso width, height, nodeWidth, and nodePadding

Errors

A row that is not source,target,value, a value that is not a number, and a quoted name not closed on its line are errors. A negative value, a node flowing into itself, and a row that closes a cycle are errors and the row is left out. A bad config.sankey value is a warning.

Not drawn

Theme variables are ignored.