Heatmap
A grid of cells shaded by value, for spotting patterns across two dimensions such as activity by day and hour.
Installation
npx dafink-ui add heatmapDemo
| 9am | 11am | 1pm | 3pm | 5pm | |
|---|---|---|---|---|---|
| Mon | 2 | 8 | 5 | 9 | 3 |
| Tue | 4 | 10 | 6 | 12 | 2 |
| Wed | 3 | 7 | No data | 8 | 4 |
| Thu | 5 | 11 | 9 | 14 | 6 |
| Fri | 1 | 6 | 4 | 7 | 2 |
| 9am | 11am | 1pm | 3pm | 5pm | |
|---|---|---|---|---|---|
| Mon | 2 | 8 | 5 | 9 | 3 |
| Tue | 4 | 10 | 6 | 12 | 2 |
| Wed | 3 | 7 | No data | 8 | 4 |
| Thu | 5 | 11 | 9 | 14 | 6 |
| Fri | 1 | 6 | 4 | 7 | 2 |
Props
| Name | Type | Default | Description |
|---|---|---|---|
| data | (number | null)[][] | - | One array per row. null marks a cell with no data, drawn as a dashed outline. |
| rowLabels | string[] | - | Labels down the left edge, one per row. |
| columnLabels | string[] | - | Labels across the top, one per column. |
| min | number | smallest value | Value shaded as the lightest cell. Values below it clamp to the lightest shade. |
| max | number | largest value | Value shaded as the darkest cell. Values above it clamp to the darkest shade. |
| showValues | boolean | false | Prints each value inside its cell, on a small surface chip so it stays readable at every shade. |
| formatValue | (value: number) => string | rounded to 2 places | Formats values in cells, tooltips, the legend and the text read by screen readers. |
| showLegend | boolean | true | Shows the light-to-dark scale with its low and high values. |
| label | string | 'Heatmap' | Accessible name of the table. |
| className | string | '' | Extra classes on the root. |
Accessibility
Heatmap is a read-only graphic with no interactive elements, so it has no tab stops or keyboard shortcuts. It renders a real <table> named by label, with column headers and row headers, so a screen reader can move cell by cell and hear the row, column and value; every cell carries its value as text and empty cells read "No data". Shade is never the only signal: the legend shows the scale's low and high values, each cell has a tooltip, and showValues prints the value in the cell on a surface chip that keeps text contrast at every shade.