SankeyChart

Where a quantity flows between stages, e.g. traffic sources to pages to signups. Links are given by node name.

Status: beta. Category: Data display.

import { SankeyChart } from '@glyphui/ui/chart'

Exports: SankeyChart.

Notes

  • Nodes are created from the names in links; pass nodes to fix their order or colors.
  • Each link takes its source’s color. Hover a link or node to see its value.

SankeyChart props

PropTypeDefaultDescription
links (required)readonly SankeyLink[]
title (required)string
classNamestring
descriptionReactNode
emptyReactNodeShown when there is no data. Defaults to a short "No data" message.
errorunknownShows an error message in place of the plot, with a retry button when onRetry is set.
heightnumberPlot height in pixels. Default 300.
hideTitleboolean
loadingbooleanShows a skeleton in place of the plot.
nodesreadonly (string | SankeyNode)[]Node order and colors. Defaults to every name in links, in order of appearance.
onRetry(() => unknown)
valueFormatter((value: number) => string)

Example: Traffic to signups

import { SankeyChart } from '@glyphui/ui/chart'

const links = [
  { source: 'Search', target: 'Pricing', value: 4200 },
  { source: 'Search', target: 'Docs', value: 2600 },
  { source: 'Social', target: 'Pricing', value: 1300 },
  { source: 'Social', target: 'Blog', value: 2100 },
  { source: 'Referral', target: 'Pricing', value: 900 },
  { source: 'Docs', target: 'Signup', value: 700 },
  { source: 'Blog', target: 'Signup', value: 300 },
  { source: 'Pricing', target: 'Signup', value: 2400 },
]

export default function Example() {
  return (
    <SankeyChart
      className="w-full"
      title="How visitors reach signup"
      description="Sessions, last 7 days"
      links={links}
      height={300}
    />
  )
}

Live page: https://glyphui.xyz/components/sankey-chart