SunburstChart

Rings of arcs that show how a whole splits into parts and sub-parts. Use it for data with levels, such as a category and its products.

It is plain svg, so it does not need any extra package.

General

A leaf has a value. A group takes the sum of its children. Hover an arc to read it.

Labels and size

withLabels writes the name of every arc that is big enough. A bigger size leaves room for more.

Half circle

0 is the top and angles grow clockwise, so -90 to 90 draws the upper half.

APIs

SunburstChart.Props

AttributeDescriptionTypeAccepted valuesDefault
datathe top level items, each one may have childrenSunburstNode[]SunburstNode-
sizewidth and height, in pixelsnumber-300
innerRadiusradius of the hole in the center, in pixelsnumber-36
gapspace between arcs and rings, in pixelsnumber-1
startAnglewhere the first arc starts, in degrees, 0 is the topnumber-0
endAnglewhere the last arc ends, in degreesnumber-360
withLabelswrite the name inside the arcs that are big enoughboolean-false
valueFormatterhow a number is written(value: number) => string-thousands separators, en-US
...native props, passed to the svgSVGAttributes'aria-label', 'className', ...-

SunburstNode

type SunburstNode = {
  name: string
  value?: number // a leaf needs a value, a group is the sum of its children
  color?: string // any CSS color, children take their parent's, a little lighter
  children?: SunburstNode[]
}

Ref

The ref points at the svg.

Accessibility

Each arc has a hover title with its name and value. Describe the chart with aria-label or aria-labelledby. With a name it is an image, without one it is hidden from assistive technology.

Write the biggest parts in text next to the chart, or offer the same data in a Table.

Edit this page on GitHub