Skip to content

Heart rate zones ​

A heart rate trace over coloured zones, and the time spent in each one. Good for workouts, running and cycling apps.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'hrzones',
  zones: [
    { name: 'Z1 Easy', from: 95, to: 114 },
    { name: 'Z2 Steady', from: 114, to: 133 },
    { name: 'Z3 Tempo', from: 133, to: 152 },
    { name: 'Z4 Hard', from: 152, to: 171 },
    { name: 'Z5 Max', from: 171, to: 190 },
  ],
  data: [
    95, 98, 104, 107, 107, 107, 107, 107, 112, 109, 121, 125, 130, 132, 134, 138, 137, 139,
    142, 143, 145, 143, 142, 143, 145, 143, 143, 142, 140, 142, 142, 143, 146, 147, 145, 143,
    144, 143, 143, 143, 149, 157, 159, 159, 159, 158, 160, 159, 149, 144, 140, 137, 136, 132,
    129, 129, 131, 132, 133, 131,
  ],
};

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

/** A heart rate trace over coloured zones, and the time spent in each zone beside it. */
interface HeartZonesSpec extends Base {
  type: 'hrzones';
  /** One heart rate a minute (or every `every` minutes). */
  data: (number | null)[];
  zones: HeartZone[];
  every?: number;
}

interface HeartZone {
  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