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.
<SankeyDiagram
data={query_name}
sourceCol= sourceCol
targetCol = targetCol
valueCol= valueCol
/>
Vertical
<SankeyDiagram
data={query_name}
sourceCol=sourceCol
targetCol=targetCol
valueCol=valueCol
orient=vertical
/>
Echarts Options String
<SankeyDiagram
data={traffic_data}
title="Sankey"
subtitle="A simple sankey chart"
sourceCol=source
targetCol=target
valueCol=count
echartsOptions={{
title: {
text: "Custom Echarts Option",
textStyle: {
color: '#476fff'
}
}
}}
/>
Node Depth Override
<SankeyDiagram
data={apple_income_statement}
title="Apple Income Statement"
subtitle="USD Billions"
sourceCol=source
targetCol=target
valueCol=amount_usd
depthOverride={{'services revenue': 1}}
nodeAlign=left
/>
Labels
Node Labels
nodeLabels=name
(default)
<SankeyDiagram
data={simple_sankey}
sourceCol=source
targetCol=target
valueCol=amount
percentCol=percent
nodeLabels=name
/>
nodeLabels=value
<SankeyDiagram
data={simple_sankey}
sourceCol=source
targetCol=target
valueCol=amount
percentCol=percent
nodeLabels=value
/>
nodeLabels=full
<SankeyDiagram
data={simple_sankey}
sourceCol=source
targetCol=target
valueCol=amount
percentCol=percent
nodeLabels=full
valueFmt=usd
/>
Link Labels
linkLabels=full
(default)
Requires percentCol
to show percentage beside value
<SankeyDiagram
data={simple_sankey}
sourceCol=source
targetCol=target
valueCol=amount
percentCol=percent
valueFmt=usd
linkLabels=full
/>
linkLabels=value
<SankeyDiagram
data={simple_sankey}
sourceCol=source
targetCol=target
valueCol=amount
percentCol=percent
valueFmt=usd
linkLabels=value
/>
linkLabels=percent
<SankeyDiagram
data={simple_sankey}
sourceCol=source
targetCol=target
valueCol=amount
percentCol=percent
valueFmt=usd
linkLabels=percent
/>
Custom Color Palette
<SankeyDiagram
data={simple_sankey}
sourceCol=source
targetCol=target
valueCol=amount
percentCol=percent
linkColor=grey
colorPalette={['#ad4940', '#3d8cc4', '#1b5218', '#ebb154']}
/>
Link Colors
linkColor=grey
(default)
<SankeyDiagram
data={simple_sankey}
sourceCol=source
targetCol=target
valueCol=amount
percentCol=percent
linkColor=grey
colorPalette={['#ad4940', '#3d8cc4', '#1b5218', '#ebb154']}
/>
linkColor=source
<SankeyDiagram
data={simple_sankey}
sourceCol=source
targetCol=target
valueCol=amount
percentCol=percent
linkColor=source
colorPalette={['#ad4940', '#3d8cc4', '#1b5218', '#ebb154']}
/>
linkColor=target
<SankeyDiagram
data={simple_sankey}
sourceCol=source
targetCol=target
valueCol=amount
percentCol=percent
linkColor=target
colorPalette={['#ad4940', '#3d8cc4', '#1b5218', '#ebb154']}
/>
linkColor=gradient
<SankeyDiagram
data={simple_sankey}
sourceCol=source
targetCol=target
valueCol=amount
percentCol=percent
linkColor=gradient
colorPalette={['#6e0e08', '#3d8cc4', '#1b5218', '#ebb154']}
/>
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
Query name, wrapped in curly braces
- Options:
- query name
Column to use for the source of the diagram
- Options:
- column name
Column to use for the target of the diagram
- Options:
- column name
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
Formatting & Styling
Format to use for valueCol
(see available formats)
- Options:
- Excel-style format | built-in format | custom format
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
Chart
Chart title. Appears at top left of chart.
- Options:
- string
Chart subtitle. Appears just under title.
- Options:
- string
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'}}