SankeyChart

Flows between steps, with the width of each link following its amount. Use it to follow where something goes, such as visitors across pages or money across budgets.

Charts need Recharts. Install it once with yarn add recharts, then import from @bolio-ui/core/charts. The package stays out of your bundle until you use a chart.

General

nodes lists the steps and links joins them by position: source and target are indexes of nodes.

Colors and format

A link takes the color of its source. Set color on a node to choose it.

APIs

SankeyChart.Props

AttributeDescriptionTypeAccepted valuesDefault
datathe steps and the flows between them{ nodes, links }SankeyNode, SankeyLink-
heightheight of the chart, in pixelsnumber-320
nodeWidthwidth of the bars of the steps, in pixelsnumber-12
nodePaddingvertical space between steps of one column, in pixelsnumber-24
withTooltipshow the amount of a flow on hoverboolean-true
valueFormatterhow a number is written(value: number) => string-thousands separators, en-US
...native props, passed to the rootHTMLAttributes'aria-label', 'className', ...-

SankeyNode

type SankeyNode = {
  name: string
  color?: string // any CSS color, a theme color when missing
}

SankeyLink

type SankeyLink = {
  source: number // position of the step in `nodes`
  target: number
  value: number // the width of the flow
}

Ref

The ref points at the root div.

Accessibility

Name the chart with aria-label, or with aria-labelledby pointing at a heading. A named chart becomes a group. A flow chart cannot be read with the keyboard, so describe the main paths in text next to it, or offer the links in a Table.

Edit this page on GitHub