Skip to content

24-hour clock chart ​

A bar for each hour around a clock face, with a second series beside it. Good for when things happen in a day: visits, calls, energy use.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'clock',
  series: [
    { name: 'Weekdays', data: [5, 4, 2, 5, 1, 1, 10, 24, 45, 55, 52, 59, 83, 80, 79, 54, 37, 19, 9, 9, 1, 4, 6, 4] },
    { name: 'Weekend', data: [7, 2, 3, 5, 8, 2, 5, 3, 0, 8, 4, 10, 23, 37, 50, 64, 76, 66, 51, 34, 18, 15, 5, 3] },
  ],
};

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

/** A day around a clock face: one bar for each hour, and a second series beside it. */
interface ClockSpec extends Base {
  type: 'clock';
  series: ClockSeries[];
}

interface ClockSeries {
  name: 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