Skip to content

Tariff clock ​

A 24-hour dial of the tariff periods and their price, the use of each hour inside, and the hour now. Good for choosing when to run machines, charge a car or heat water.

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: 'tariffclock',
  periods: [
    { from: '22:00', to: '06:00', name: 'Off-peak', price: 0.1696 },
    { from: '06:00', to: '17:00', name: 'Peak', price: 0.2146 },
    { from: '17:00', to: '20:00', name: 'Evening peak', price: 0.2795 },
    { from: '20:00', to: '22:00', name: 'Peak', price: 0.2146 },
  ],
  usage: [
    0.71, 1.27, 1.2, 1.29, 1.19, 1.18, 0.73, 1.11, 1.01, 0.62, 0.61, 0.61, 0.84, 0.56, 0.74,
    0.55, 0.67, 0.62, 1.42, 1.57, 1.35, 1.48, 0.73, 0.68,
  ],
  now: '18:11',
};

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

/** A 24-hour dial of the tariff periods and their price, the use of each hour inside, and the hour now. */
interface TariffClockSpec extends Base {
  type: 'tariffclock';
  /** Periods of the day: "22:00" to "06:00" crosses midnight. */
  periods: { from: string; to: string; name: string; price: number; color?: string }[];
  /** 24 values of use, one for each hour: bars inside the dial. */
  usage?: (number | null)[];
  /** "€/kWh" by default. */
  priceUnit?: string;
  /** "kWh" by default. */
  unit?: string;
  now?: 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