RadialBarChart

Concentric bars that curve around a center, one ring per item. Use it to compare a few values against a shared maximum, such as goals reached.

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. The longest bar marks the biggest value.

Labels and angles

withLabels writes the value on each bar. startAngle and endAngle set the arc, so 180 to 0 is the upper half.

APIs

RadialBarChart.Props

AttributeDescriptionTypeAccepted valuesDefault
dataone ring per itemChartSlice[]ChartSlice-
heightheight of the chart, in pixelsnumber-300
barSizethickness of each bar, in pixelsnumber-20
withBackgrounddraw the empty track behind each barboolean-true
withLabelswrite the value on each barboolean-false
withLegendshow the legendboolean-false
withTooltipshow the value of a bar on hover and focusboolean-true
startAnglewhere the bars start, in degreesnumber-90
endAnglewhere the bars end, in degreesnumber--270
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 legend and the tooltip
  value: number // the length of the bar
  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.

Bars differ by color and length, so turn on withLegend or withLabels and write the key numbers in text next to the chart.

Edit this page on GitHub