Skip to content

Commit

Permalink
Merge pull request #1254 from nattaylor/sankey_docs2
Browse files Browse the repository at this point in the history
add details to sankey docs
  • Loading branch information
archiewood authored Oct 12, 2023
2 parents bfc7105 + 8628e01 commit 02c52ef
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions sites/docs/docs/components/sankey-diagram.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ title: Sankey Diagram
hide_table_of_contents: false
---

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](#multi-level) below.

![sankey](/img/exg-sankey.svg)

```markdown

<SankeyDiagram
data={query_name}
sourceCol= sourceCol
Expand All @@ -29,6 +34,44 @@ hide_table_of_contents: false
/>
```

## 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. `sourceCal` 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.

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

union all

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

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

## Props

### Data
Expand Down

0 comments on commit 02c52ef

Please sign in to comment.