Output Charts

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
Sankey

Change any number or label. The chart follows.

Fields

The sankey document
FieldTypeRule
sourceKeyRequiredstringThe key in each row that holds the item the amount flows from. Up to 80 characters.
targetKeyRequiredstringThe key in each row that holds the item the amount flows to. Up to 80 characters. Must differ from sourceKey.
valueKeyRequiredstringThe key in each row that holds the amount. Up to 80 characters. Must differ from sourceKey and targetKey.
formatOptionalstringnumber (the default), compact or percent. A percent value is a fraction: 0.25 shows as 25%.
prefixOptionalstringShown before every figure, such as "$". Up to 80 characters.
suffixOptionalstringShown after every figure, such as " k". Up to 80 characters.
dataRequiredarrayUp to 100 flows between at most 50 distinct items; may be empty.
Each row in data
FieldTypeRule
<sourceKey>RequiredstringThe item the amount flows from. Up to 80 characters. Not the same as the row's target.
<targetKey>RequiredstringThe 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>RequirednumberThe 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