Components · Data Display
Heatmap
BetaAdded v4.5.0
Intensity over a grid, such as activity by weekday and week, in seven sequential steps.
import { Heatmap } from '@nexub/react';Playground
Props
| Mon | 0 | 3 | 6 | 9 | 1 | 4 | 7 | 10 | 2 | 5 | 8 | 4 | 7 | 10 | 13 | 5 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Tue | 7 | 10 | 2 | 5 | 8 | 0 | 3 | 6 | 9 | 1 | 4 | 11 | 14 | 6 | 9 | 12 |
| Wed | 3 | 6 | 9 | 1 | 4 | 7 | 10 | 2 | 5 | 8 | 0 | 7 | 10 | 13 | 5 | 8 |
| Thu | 10 | 2 | 5 | 8 | 0 | 3 | 6 | 9 | 1 | 4 | 7 | 14 | 6 | 9 | 12 | 4 |
| Fri | 6 | 9 | 1 | 4 | 7 | 10 | 2 | 5 | 8 | 0 | 3 | 10 | 13 | 5 | 8 | 11 |
<Heatmap className="w-full" rowLabels={days} data={data} title="Payments sent per day, last 16 weeks" />Examples
Weekly activity
Missing cells and legend
`null` cells are hatched; `legend` shows the scale.
States
Payments sent per day, last 16 weeks Mon 0 3 6 9 1 4 7 10 2 5 8 4 7 10 13 5 Tue 7 10 2 5 8 0 3 6 9 1 4 11 14 6 9 12 Wed 3 6 9 1 4 7 10 2 5 8 0 7 10 13 5 8 Thu 10 2 5 8 0 3 6 9 1 4 7 14 6 9 12 4 Fri 6 9 1 4 7 10 2 5 8 0 3 10 13 5 8 11 defaultloading
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| datarequired | (number)[][] | — | Rows of values. 11.3: a missing cell (null, undefined or a hole) is drawn hatched, listed as "—" and left out of the colour range. |
| rowLabelsrequired | string[] | — | One label per row. |
| columnLabels | string[] | — | Used in the hover text. |
| titlerequired | string | — | Accessible name and table caption. |
| legend | boolean | — | 11.3: a low → high scale under the grid with the min and max values, plus a "No data" swatch when cells are missing. |
| tableView | string | boolean | — | 11.3: a "Show as table" disclosure under the drawing with the same data; a string sets its label. |
| emptyState | React.ReactNode | — | Shown when there is no data. Defaults to the "no data" message. |
| errorState | React.ReactNode | — | Shown in place of the data when a load failed, for example an ErrorState with a retry action. Wins over loading and empty. |
| interactive | boolean | — | A crosshair and tooltip that follow the pointer, and arrow-key navigation between points. |
| loading | boolean | — | Shows a skeleton in place of the data and sets aria-busy. |
| onPointClick | ((point: HeatmapPoint) => void) | — | Click, tap, or Enter/Space on a point. Turns interactive on unless it is set to false. |
| valueFormat | ((value: number) => string) | fmt |
Accessibility
Screen reader
The drawing is hidden from assistive tech; a visually hidden table or caption carries every value.
On iOS & Android
Web only
Heatmap has no @nexub/react-native twin. On phones, follow the platform pattern instead, or compose it from the native components listed on the React Native page.