Skip to content

Punch card ​

A circle for each row and column. Good for when things happen.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'punchcard',
  rows: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
  columns: ['0 h', '2 h', '4 h', '6 h', '8 h', '10 h', '12 h', '14 h', '16 h', '18 h', '20 h', '22 h'],
  values: [
    [21, 16, 7, 19, 5, 5, 24, 21, 8, 9, 8, 8],
    [38, 1, 25, 0, 16, 9, 10, 29, 1, 17, 23, 18],
    [33, 7, 15, 21, 35, 9, 22, 14, 2, 30, 11, 18],
    [38, 35, 14, 5, 30, 15, 19, 21, 13, 40, 14, 9],
    [9, 1, 11, 1, 14, 28, 23, 19, 29, 4, 8, 23],
    [30, 27, 34, 15, 34, 24, 24, 33, 13, 13, 39, 12],
    [31, 26, 35, 5, 4, 35, 23, 39, 31, 6, 32, 20],
  ],
};

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

interface PunchcardSpec extends Base {
  type: 'punchcard';
  rows: string[];
  columns: string[];
  values: (number | null)[][];
  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