Skip to content

Small multiples ​

The same small chart for each group, on one scale. Good for comparing the shape of many series without a tangle of lines.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'facet',
  categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  panels: [
    { name: 'North', data: [45, 40.9, 41.1, 36.4, 31.5, 33.6, 34.7, 31.1, 28, 24.4, 20.8, 27.7] },
    { name: 'South', data: [33.2, 26.9, 26.2, 23, 20, 23.7, 17.5, 17, 18.8, 18.5, 23.6, 19.7] },
    { name: 'East', data: [41.9, 47.7, 44.3, 45.6, 44, 38.3, 42.4, 39.9, 39.6, 46.6, 52.2, 50.6] },
    { name: 'West', data: [37.9, 36.8, 36.9, 37.7, 35.8, 43.3, 41.7, 38.4, 35.3, 29.2, 26.6, 20.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 facet takes:

/** The same small chart for each group, on the same scale. */
interface FacetSpec extends Base {
  type: 'facet';
  categories: string[];
  panels: { name: string; data: (number | null)[]; color?: string }[];
  kind?: 'line' | 'bar';
  /** Panels on a row; chosen from the width by default. */
  columns?: number;
}

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