Sankey Diagram

The SankeyDiagram component accepts a query and displays a flow from one set of values to another.

To display a flow with multiple levels, like these examples, see Mutli-level below.

Loading...

Vertical

Loading...

Echarts Options String

Loading...

Node Depth Override

Loading...

Labels

Node Labels

nodeLabels=name (default)

Loading...

nodeLabels=value

Loading...
The value labels can be formatted using the `valueFmt` option.

nodeLabels=full

Loading...

linkLabels=full (default)

Requires percentCol to show percentage beside value

Loading...

linkLabels=value

Loading...

linkLabels=percent

Loading...

Custom Color Palette

Loading...

linkColor=grey (default)

Loading...

linkColor=source

Loading...

linkColor=target

Loading...

linkColor=gradient

Loading...

Multi-level

The syntax for multi-level sankey diagrams is the same, but the underlying query must represent all the levels using the same sourceCol and targetCol, so it is necessary to union each level together. sourceCol nodes on the next level will be linked to targetCol nodes in the previous level with the same name.

For example, here is the source for the visuals above.

```sql traffic_source
select 
    channel as source,
    'all_traffic' as target,
    count(user_id) as count
from events.web_events
group by 1,2

union all

select 
    'all_traffic' as source,
    page_route as target,
    count(user_id) as count
from events.web_events
group by 1, 2
‍```

<SankeyDiagram
    data={traffic_data}
    title="Sankey"
    subtitle="A simple sankey chart"
    sourceCol=source
    targetCol=target
    valueCol=count
/>

Options

Data

Required

Query name, wrapped in curly braces

Options:
query name
Required

Column to use for the source of the diagram

Options:
column name
Required

Column to use for the target of the diagram

Options:
column name
Required

Column to use for the value of the diagram

Options:
column name

Column to use for the percent labels of the diagram

Options:
column name

Manual adjustment to location of each node {{'services revenue': 2}}

Options:
object containing node name and depth level (0 is first level)

Sets behaviour for empty datasets. Can throw an error, a warning, or allow empty. When set to 'error', empty datasets will block builds in build:strict. Note this only applies to initial page load - empty datasets caused by input component changes (dropdowns, etc.) are allowed.

Default:
error

Text to display when an empty dataset is received - only applies when emptySet is 'warn' or 'pass', or when the empty dataset is a result of an input component change (dropdowns, etc.).

Options:
string
Default:
No records

Helper prop for custom chart development - inserts a code block with the current echarts config onto the page so you can see the options used and debug your custom options

Options:
Default:
false

Formatting & Styling

Format to use for valueCol (see available formats)

Options:
Excel-style format | built-in format | custom format

Layout direction of the nodes in the diagram.

Default:
horizontal

Whether the nodes are sorted by size in the diagram

Options:
Default:
false

Controls the horizontal alignment of nodes in the diagram. When orient is vertical, nodeAlign controls vertical alignment.

Default:
justify

The gap between any two rectangles in each column of the the diagram.

Options:
number
Default:
8

The node width of rectangle in the diagram.

Options:
number
Default:
20

Border color. Only accepts a single color.

Options:
CSS name | hexademical | RGB | HSL
Default:
transparent

Border Width. It should be a natural number.

Options:
number
Default:
1

Array of custom colours to use for the chart. E.g., {['#cf0d06','#eb5752','#e88a87']}

Options:
array of color strings (CSS name | hexademical | RGB | HSL)
Default:
built-in color palette

Color to use for the links between nodes in the diagram

Default:
grey

Chart

Chart title. Appears at top left of chart.

Options:
string

Chart subtitle. Appears just under title.

Options:
string

Adds labels to the nodes of the diagram

Default:
name

Adds labels to the links between nodes

Default:
full (requires percentCol)

Minimum height of the chart area (excl. header and footer) in pixels. Adjusting the height affects all viewport sizes and may impact the mobile UX.

Options:
number
Default:
180

Custom Echarts Options

Custom Echarts options to override the default options. See reference page for available options.

Options:
{{exampleOption:'exampleValue'}}

Helper prop for custom chart development - inserts a code block with the current echarts config onto the page so you can see the options used and debug your custom options

Options:
Default:
false