FunnelChart

Steps that get narrower, to show where people drop off. Use it for a process with ordered stages, such as visit, sign up and purchase.

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

Each item has a name and a value. Pass the steps from the widest to the narrowest.

Legend and format

Swap the labels for a legend, and use valueFormatter to change how the tooltip reads.

APIs

FunnelChart.Props

AttributeDescriptionTypeAccepted valuesDefault
datathe steps, from the widest to the narrowestChartSlice[]ChartSlice-
heightheight of the chart, in pixelsnumber-300
withTooltipshow the value of a step on hover and focusboolean-true
withLegendshow the legendboolean-false
withLabelswrite the name of each stepboolean-true
labelsPositionwhere the names gostring'left', 'right', 'inside'right
valueFormatterhow a number is written(value: number) => string-thousands separators, en-US
...native props, passed to the rootHTMLAttributes'aria-label', 'className', ...-

ChartSlice

type ChartSlice = {
  name: string // shown in the labels, the legend and the tooltip
  value: number // the width of the step
  color?: string // any CSS color, a theme color when missing
}

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. The chart can be focused. Arrow Left and Right then move through the data and show the values in the tooltip.

Steps differ by color and width, so keep the names visible with withLabels or withLegend.

Edit this page on GitHub