Sankey
Docs · Visuals
Sankey diagram JSON format.
How amounts flow between named things, read left to right.
Try it
Edit the example and the visual redraws. Mistakes show the same messages the API returns.
The visual
Change any number or label. The chart follows.
Fields
| Field | Type | Rule |
|---|---|---|
sourceKeyRequired | string | The key in each row that holds the item the amount flows from. Up to 80 characters. |
targetKeyRequired | string | The key in each row that holds the item the amount flows to. Up to 80 characters. Must differ from sourceKey. |
valueKeyRequired | string | The key in each row that holds the amount. Up to 80 characters. Must differ from sourceKey and targetKey. |
formatOptional | string | number (the default), compact or percent. A percent value is a fraction: 0.25 shows as 25%. |
prefixOptional | string | Shown before every figure, such as "$". Up to 80 characters. |
suffixOptional | string | Shown after every figure, such as " k". Up to 80 characters. |
dataRequired | array | Up to 100 flows between at most 50 distinct items; may be empty. |
| Field | Type | Rule |
|---|---|---|
<sourceKey>Required | string | The item the amount flows from. Up to 80 characters. Not the same as the row's target. |
<targetKey>Required | string | The item the amount flows to. Up to 80 characters. The same source and target pair may appear once, and the flow must not close a loop. |
<valueKey>Required | number | The amount: a number above 0. |
Good to know
- A sankey reads left to right, so a flow that closes a loop is refused, named: "This flow makes a loop: Rent → Salary → Budget → Rent".
- A flow from an item to itself, and a pair sent twice, are refused too.
- Items are drawn in the order first seen, each link in its source item's colour.
- A sankey holds no row list: send the whole document with PUT /v1/visuals/{id}/data to change it.
Example
{
"sourceKey": "from",
"targetKey": "to",
"valueKey": "amount",
"prefix": "$",
"data": [
{ "from": "Salary", "to": "Budget", "amount": 5200 },
{ "from": "Side job", "to": "Budget", "amount": 800 },
{ "from": "Budget", "to": "Rent", "amount": 1800 },
{ "from": "Budget", "to": "Food", "amount": 900 },
{ "from": "Budget", "to": "Savings", "amount": 1500 }
]
}Send it from your code
Paste the document in the editor, or replace it with a PUT to the visual's push URL. The push API page has the details and examples.
Next: Bar chart JSON format