All components (283)
Heatmap
Data · HeatmapChart · .amset-heatmap
What it is and when to use it
A grid of cells whose colour says how much: orders by day and hour, usage per week. It is for seeing patterns at a glance; the exact figures are in each cell's tooltip and in the table.
When to use it
- Two axes with categories and a value at each crossing.
valueshas one list per row.nullmeans no data, and it is drawn differently: it is not the same as zero.
When not to
- A single series over time:
LineChart. - Comparing few categories:
BarChart.
Keyboard: Tab takes you to the grid (a single tab stop) and the arrows move from cell to cell; Home and End go to the ends of the row, and Escape leaves. A spoken notice says each cell.
Accessibility: the grid is an image (role="img") with a written summary, and underneath goes a real table. Colour is not alone: a cell with no data has a pattern, and each value can be read in the tooltip and the table.
Fine-tuning: --amset-heatmap-cell is the minimum cell size, --amset-heatmap-name the width of the names and --amset-heatmap-tone the colour.
What it looks like
Orders by day and hour
Week of 2 to 6 March
Peak hour
Viernes, 18-20 h
34 orders in that slot
| Slot | Mon | Tue | Wed | Thu | Fri |
|---|---|---|---|---|---|
| 8-10 | 4 | 6 | 3 | 8 | 5 |
| 10-12 | 12 | 15 | 10 | 17 | 14 |
| 12-14 | 18 | 21 | 16 | 24 | 27 |
| 14-16 | 9 | 11 | 8 | 13 | 16 |
| 16-18 | 14 | no data | 12 | 18 | 21 |
| 18-20 | 22 | 19 | 25 | 30 | 34 |
<Card title="Orders by day and hour" subtitle="Week of 2 to 6 March">
<Stat label="Peak hour" value="Friday, 6-8 pm" detail="34 orders in that slot" tone="accent" />
<HeatmapChart
label="Orders by day and hour"
rows={["8-10", "10-12", "12-14", "14-16", "16-18", "18-20"]}
columns={["Mon", "Tue", "Wed", "Thu", "Fri"]}
values={pedidosPorFranja}
rowName="Slot"
/>
</Card>Props
Import it with import { HeatmapChart } from '@amset/ui'. Required props are marked.
| Prop | Type | What it does |
|---|---|---|
columnsrequired | readonly string[] | What goes on top: the hours. |
labelrequired | string | What is being measured. Required: a chart without a title does not inform. |
rowsrequired | readonly string[] | What goes on the left: the days of the week. |
valuesrequired | readonly (readonly (number | null)[])[] | One list per row, with one value per column. `null` means no data, which is not the same as zero. |
className | string | Merged with the library classes; it does not replace them. |
error | ReactNode | The data has not arrived: it says so in the place of the drawing, with what is passed here. |
format | (value: number) => string | — |
loading | boolean | The data is on its way. |
rowName | string | What the first column of the table is called. |
tableVisible | boolean | Also shows the table. For the screen reader it is always there. |
It also accepts the attributes of the element it renders: className, style, data-*, aria-* and its events.
CSS variables
These CSS variables are how you adapt it. Declare them on the component's selector, not on :root: the stylesheet redeclares them in the rule itself, and a declaration on the same element always wins.
| Variable | Default |
|---|---|
--amset-heatmap-cell | 1.75rem |
--amset-heatmap-name | 4.5rem |
--amset-heatmap-tone | var(--amset-accent) |
How to change it
.amset-heatmap {
--amset-heatmap-cell: ...;
--amset-heatmap-name: ...;
}In the test bench
Every state and variant, to try one at a time, on its page at storybook.amsetui.com:
