Documentation · Data
Sankey diagram
Write every flow as a source, an arrow, a target and how much. The nodes are made from the names, and each band is as wide as its flow.
When to use it
Show how a quantity divides and combines as it moves: energy balances, material flows, budgets or user journeys.
Write losses and leftovers as flows of their own, so every node visibly balances. A band's width is its value on one scale for the whole diagram.
Working example
Copy this complete example into the Source tab, then press Generate. Change its labels or values to make your first version.
sankey "Household energy (PJ)" {
unit "PJ"
"Natural gas" -> "Electricity" 120
"Coal" -> "Electricity" 80
"Natural gas" -> "Heat" 40
"Electricity" -> "Homes" 70
"Electricity" -> "Industry" 60
"Electricity" -> "Losses" 70
"Heat" -> "Homes" 30
"Heat" -> "Losses" 10
}Syntax reference
The same reference used by the editor and AI briefing. Syntax is notation-specific; use the keywords listed here.
Figure
| Syntax | Meaning |
|---|---|
sankey "Title" { | open a Sankey diagram |
Flows
| Syntax | Meaning |
|---|---|
"Gas" -> "Power" 120 | a flow of 120 from one node to another |
Coal -> Power 80 | a one-word name needs no quotes |
node "Coal" "#555555" | pin a node's colour |
Look
| Syntax | Meaning |
|---|---|
unit "PJ" | written after every value |
values off | leave the totals off the nodes |
colors colorful | ink (grey bands) or colorful (a hue per source) |
text 13 | caption size, 9 to 22 |
size 760 420 | width and height on the sheet |
# comment | line comment (also //) |
Language rules
- The file is one sankey "Title" { ... } block. Nothing may sit outside it.
- A flow is "Source" -> "Target" 120: two names and a value above 0. A name with no space needs no quotes.
- Nodes are made from the names in the order they are first written; node "Name" "#rrggbb" pins one's colour.
- Flows run one way: no flow may lead back round to where it started, and a node never flows into itself.
- Write a loss as a flow of its own ("Power" -> "Losses" 70); nothing is added to balance a node.
- Settings are written as name value, in any order.
- Do not invent settings. Every one the language has is listed above.
Edit on the canvas
- Rename a node in place on the sheet.
- Add, change or remove flows, pin node colours and choose grey or coloured bands in the Sankey panel.
Generate replaces the drawing from source. Save before generating again if you want to preserve manual finishing touches.
Read Saving & exportingWrite it with an assistant
Tingraph AI already knows this notation. For another assistant, copy the tutorial below, describe your diagram under MY DIAGRAM, then paste the returned source into the editor. This prompt includes every syntax row, rule and working example above.
Read the complete prompt
You are writing Tingraph source. Tingraph is a small text language that draws a Sankey diagram. Answer with Tingraph source only.
SYNTAX
Figure
sankey "Title" { open a Sankey diagram
Flows
"Gas" -> "Power" 120 a flow of 120 from one node to another
Coal -> Power 80 a one-word name needs no quotes
node "Coal" "#555555" pin a node's colour
Look
unit "PJ" written after every value
values off leave the totals off the nodes
colors colorful ink (grey bands) or colorful (a hue per source)
text 13 caption size, 9 to 22
size 760 420 width and height on the sheet
# comment line comment (also //)
RULES
- The file is one `sankey "Title" { ... }` block. Nothing may sit outside it.
- A flow is `"Source" -> "Target" 120`: two names and a value above 0. A name with no space needs no quotes.
- Nodes are made from the names in the order they are first written; `node "Name" "#rrggbb"` pins one's colour.
- Flows run one way: no flow may lead back round to where it started, and a node never flows into itself.
- Write a loss as a flow of its own (`"Power" -> "Losses" 70`); nothing is added to balance a node.
- Settings are written as `name value`, in any order.
- Do not invent settings. Every one the language has is listed above.
WORKED EXAMPLE
sankey "Household energy (PJ)" {
unit "PJ"
"Natural gas" -> "Electricity" 120
"Coal" -> "Electricity" 80
"Natural gas" -> "Heat" 40
"Electricity" -> "Homes" 70
"Electricity" -> "Industry" 60
"Electricity" -> "Losses" 70
"Heat" -> "Homes" 30
"Heat" -> "Losses" 10
}
OUTPUT
- Reply with one fenced code block and nothing else.
- The block starts with `sankey "…" {` and ends with `}`.
- Do not invent keywords: use only the ones listed above.
- Keep labels short enough to read inside a box, and keep every ID unique.
MY DIAGRAM
Describe what you want here, then send this message.Something unclear? Contact support or read the Privacy Policy.