Medication tracker
A week of doses, one pill a day for each medicine and time, taken or missed. Good for treatment follow-up, care homes and patient apps.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
const spec = {
type: 'medication',
days: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
data: [
{ name: 'Metformin 500 mg', time: '08:00', states: ['taken', 'taken', 'taken', 'taken', 'taken', 'taken', null] },
{ name: 'Metformin 500 mg', time: '20:00', states: ['late', 'taken', 'taken', 'taken', 'taken', null, null] },
{ name: 'Lisinopril 10 mg', time: '08:00', states: ['taken', 'taken', 'taken', 'late', 'taken', 'taken', null] },
{ name: 'Vitamin D', time: '12:00', states: ['taken', 'taken', 'missed', 'skipped', 'taken', 'late', 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 medication takes:
/** A week of doses: one row by medicine and time, one pill by day, taken or missed. */
interface MedicationSpec extends Base {
type: 'medication';
days: string[];
data: { name: string; time?: string; states: DoseState[]; color?: string }[];
/** Words of the states in another language. */
labels?: Partial<Record<Exclude<DoseState, null>, string>>;
}
type DoseState = 'taken' | 'late' | 'missed' | 'skipped' | null;Style it
- Colours:
theme.palette,chart.setColor(name, colour), or--nervure-palettein your CSS. More - Marks:
[data-series="name"], parts:[data-part="axes"],legend,series. What you change is kept in exports. - Movement:
animation: falsedraws at once. More - Files:
chart.download('png'),svg,csv. More