Skip to content

Sunburst chart ​

Rings of slices, from the centre to the leaves. Good for a hierarchy and the weight of each branch.

The smallest code that works. change the code, then press Run

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'sunburst',
  data: [
    { name: 'North', children: [{ name: 'Gabes', value: 13 }, { name: 'Bizerte', value: 38 }, { name: 'Sfax', value: 7 }] },
    {
      name: 'South',
      children: [
        { name: 'Tunis', value: 12 },
        { name: 'Kairouan', value: 19 },
        { name: 'Sousse', value: 24 },
      ],
    },
    {
      name: 'East',
      children: [
        { name: 'Bizerte', value: 10 },
        { name: 'Tunis', value: 31 },
        { name: 'Kairouan', value: 19 },
        { name: 'Djerba', value: 22 },
      ],
    },
    {
      name: 'West',
      children: [
        { name: 'Nabeul', value: 25 },
        { name: 'Kairouan', value: 22 },
        { name: 'Bizerte', value: 31 },
      ],
    },
  ],
};

export default function Example() {
  return <Chart spec={spec} style={{ height: 340 }} />;
}

Or import this chart alone: what each import weighs.

Options

Beside the fields shared by every chart (title, format, heading, export…), type sunburst takes:

interface SunburstSpec extends Base {
  type: 'sunburst';
  data: SunburstNode[];
  center?: string;
}

/** A leaf needs a `value`; a branch is the sum of its children. */
interface SunburstNode {
  name: string;

Style it

  • Colours: theme.palette, chart.setColor(name, colour), or --nervure-palette in your CSS. More
  • Marks: [data-series="name"], parts: [data-part="axes"], legend, series. What you change is kept in exports.
  • Movement: animation: false draws at once. More
  • Files: chart.download('png'), svg, csv. More

Close to it