Charts
Heatmap
Busy hours by weekday — one hue, light to dark, with the scale printed.
Entries by hour
0003060912151821SatSunMonTueWedThuFri
0 cars89 cars
heatmap.tsx
"use client";
import { ChartCard, Heatmap } from "@waveinno/ui";
const HEAT = Array.from({ length: 7 }, (_, d) =>
Array.from({ length: 24 }, (_, h) => {
const rush = Math.exp(-((h - 9) ** 2) / 6) * 60 + Math.exp(-((h - 18) ** 2) / 5) * 70;
const base = h >= 7 && h <= 22 ? 12 : 2;
return Math.round((base + rush) * (d === 6 ? 0.45 : 1) * (0.85 + ((d * 7 + h) % 5) * 0.06));
}),
);
export default function HeatmapExample() {
return (
<ChartCard title="Entries by hour" height={210}>
<Heatmap
rows={["Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri"]}
columns={Array.from({ length: 24 }, (_, h) => String(h).padStart(2, "0"))}
values={HEAT}
showColumnEvery={3}
format={(v) => `${v} cars`}
/>
</ChartCard>
);
}Import#
Everything comes from the package root. The example above uses:
your-component.tsx
import { ChartCard, Heatmap } from "@waveinno/ui";Props#
Read from the source of this version, so they match the code exactly.
<Heatmap>
src/components/charts/heatmap.tsx| Prop | Type | Default | Description |
|---|---|---|---|
rowsrequired | string[] | — | Row labels, top to bottom (e.g. weekdays). |
columnsrequired | string[] | — | Column labels, left to right (e.g. hours). |
valuesrequired | number[][] | — | values[row][column] |
format | (v: number) => string | (v) => String(v) | |
max | number | — | Top of the scale; defaults to the largest value. |
showColumnEvery | number | 1 | Label every nth column so 24 hours stay readable. |
className | string | — |
<ChartCard>
src/components/charts/chart-card.tsx| Prop | Type | Default | Description |
|---|---|---|---|
titlerequired | string | — | |
description | string | — | |
series | SeriesMeta[] | — | |
action | React.ReactNode | — | |
childrenrequired | React.ReactNode | — | |
className | string | — | |
height | number | 240 |
Install#
If the project does not have the package yet, add it, then follow the setup for Next.js or Vite once.
$ npm install @waveinno/ui