Skip to content

Delay heat strip ​

Lines down the side and hours across, each cell coloured by the average delay, with the share on time. Good for punctuality of a network by hour or by day, and where the rush hours hurt.

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

In your framework

import { Chart } from 'nervure/react';
import 'nervure/themes';

const spec = {
  type: 'delays',
  hours: [
    '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20',
    '21', '22', '23',
  ],
  lines: [
    { name: 'A', delays: [1.6, 0.5, 3.4, 7.8, 0.6, 0.6, 2.9, 1.9, 1.2, 0.7, 0, 6.8, 5.5, 1.1, 2.6, 1.7, 0.2, 0.8] },
    { name: 'B', delays: [2.9, 1, 7.2, 8.4, 1, 1, 0.7, 0.8, 1.1, 1.7, 2.2, 7.6, 10.3, 2.6, 2.5, 1.8, 1, 2.9] },
    { name: 'C', delays: [2.3, 2.6, 11.3, 14.7, 2.3, 2.4, 0.8, 1.4, 2.8, 0.1, 2.8, 12.3, 4.5, 0.2, 1.5, 1.8, 1.6, 2.2] },
    { name: 'D', delays: [1, 0.4, 13.1, 3.8, 1.8, 1.9, 2.4, 2.6, 0.7, 3, 2.1, 15.7, 10.4, 2.2, 2.9, 1.1, 2.8, 2.2] },
    { name: 'T1', delays: [3, 0.5, 13.3, 11.9, 2.4, 0.6, 2.8, 0.9, 2.3, 2.2, 0.2, 14.4, 10.8, 2.7, 0.3, 1.5, 3, 2.5] },
    {
      name: 'T2',
      delays: [
        2.7, 2.3, 19.5, 10.7, 2.8, 0.7, 1.4, 0.7, 0.3, 0.7, 0.8, 12.5, 19.3, 2.1, 2.9, 1.3, null,
        null,
      ],
    },
  ],
};

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

/** Delay heat strip: lines down the side, hours across, each cell coloured by the average delay. */
interface DelaysSpec extends Base {
  type: 'delays';
  /** Names of the columns: `'06'`, `'07'`… or `'Mon'`, `'Tue'`… */
  hours: string[];
  /** One row for each line; `delays` in minutes, one for each column, null when nothing runs. */
  lines: { name: string; delays: (number | null)[]; color?: string }[];
  /** Minutes from which a trip counts as late: 5 by default. */
  late?: number;
  onItemClick?: (name: string) => void;
}

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