Skip to content

Stream graph ​

Layers that swell and shrink around a middle. Good for how a mix changes over time.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'stream',
  categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  series: [
    { name: 'Bread', data: [34.7, 29.4, 29.7, 23.6, 17.4, 20.1, 21.4, 16.9, 12.8, 8.2, 4, 12.9] },
    { name: 'Fruit', data: [23.9, 15.7, 14.8, 10.7, 6.8, 11.7, 4, 4, 6.2, 5.9, 12.5, 7.5] },
    { name: 'Cheese', data: [32.2, 39.7, 35.2, 36.9, 34.9, 27.6, 32.8, 29.6, 29.3, 38.2, 45.4, 43.3] },
    { name: 'Coffee', data: [29, 27.6, 27.7, 28.7, 26.3, 36, 33.9, 29.7, 25.7, 17.8, 14.5, 6.5] },
    { name: 'Tea', data: [35.4, 37.3, 37.7, 42.7, 36.2, 31.5, 33.5, 38.8, 42.7, 49.8, 48.4, 55.4] },
  ],
};

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

interface StreamSpec extends Base {
  type: 'stream';
  categories: string[];
  series: { name: string; data: number[]; color?: 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