Skip to content

Alluvial diagram ​

Stages in columns, and ribbons that show how the same items change category. Good for customers moving between plans, voters between parties, from year to year.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'alluvial',
  stages: ['2022', '2023', '2024'],
  flows: [
    { path: ['Free', 'Free', 'Free'], value: 26 },
    { path: ['Free', 'Pro', 'Gone'], value: 6 },
    { path: ['Free', 'Gone', 'Free'], value: 5 },
    { path: ['Basic', 'Free', 'Free'], value: 6 },
    { path: ['Basic', 'Basic', 'Free'], value: 15 },
    { path: ['Basic', 'Basic', 'Basic'], value: 34 },
    { path: ['Basic', 'Basic', 'Pro'], value: 17 },
    { path: ['Basic', 'Pro', 'Pro'], value: 20 },
    { path: ['Basic', 'Gone', 'Free'], value: 52 },
    { path: ['Basic', 'Gone', 'Gone'], value: 26 },
    { path: ['Pro', 'Free', 'Gone'], value: 24 },
    { path: ['Pro', 'Pro', 'Pro'], value: 36 },
    { path: ['Pro', 'Gone', 'Free'], value: 10 },
    { path: ['Pro', 'Gone', 'Gone'], value: 42 },
  ],
};

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 alluvial takes:

/** Stages in columns, the same items in each: ribbons show how they move from one category to another. */
interface AlluvialSpec extends Base {
  type: 'alluvial';
  stages: string[];
  /** A group of items: its category at each stage, in the order of `stages`, and how many they are. */
  flows: { path: string[]; value: number }[];
  colors?: Record<string, 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