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 heatmap

Demo

9am11am1pm3pm5pm
Mon28593
Tue4106122
Wed37No data84
Thu5119146
Fri16472
9am11am1pm3pm5pm
Mon28593
Tue4106122
Wed37No data84
Thu5119146
Fri16472

Props

NameTypeDefaultDescription
data(number | null)[][]-One array per row. null marks a cell with no data, drawn as a dashed outline.
rowLabelsstring[]-Labels down the left edge, one per row.
columnLabelsstring[]-Labels across the top, one per column.
minnumbersmallest valueValue shaded as the lightest cell. Values below it clamp to the lightest shade.
maxnumberlargest valueValue shaded as the darkest cell. Values above it clamp to the darkest shade.
showValuesbooleanfalsePrints each value inside its cell, on a small surface chip so it stays readable at every shade.
formatValue(value: number) => stringrounded to 2 placesFormats values in cells, tooltips, the legend and the text read by screen readers.
showLegendbooleantrueShows the light-to-dark scale with its low and high values.
labelstring'Heatmap'Accessible name of the table.
classNamestring''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.