Skip to content

Mood tracker ​

Mood day after day, as faces on five levels. Good for wellness and mental health diaries.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'mood',
  data: [
    { label: '1 Apr', mood: 3 },
    { label: '2 Apr', mood: 3 },
    { label: '3 Apr', mood: 3 },
    { label: '4 Apr', mood: 4 },
    { label: '5 Apr', mood: 3 },
    { label: '6 Apr', mood: 3 },
    { label: '7 Apr', mood: 3 },
    { label: '8 Apr', mood: 3 },
    { label: '9 Apr', mood: 2 },
    { label: '10 Apr', mood: 2 },
    { label: '11 Apr', mood: 1 },
    { label: '12 Apr', mood: 2 },
    { label: '13 Apr', mood: 4 },
    { label: '14 Apr', mood: 2 },
  ],
};

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

/** Mood day after day, as faces on five levels. */
interface MoodSpec extends Base {
  type: 'mood';
  /** `mood` from 1 (very bad) to 5 (very good). */
  data: { label: string; mood: number; note?: string }[];
  labels?: 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