Skip to content

TkxHeatmap

9am11am1pm3pm5pmMon × 9am: 1212Tue × 9am: 88Wed × 9am: 1515Thu × 9am: 1010Fri × 9am: 66Mon × 11am: 3030Tue × 11am: 2626Wed × 11am: 3434Thu × 11am: 2929Fri × 11am: 2121Mon × 1pm: 2222Tue × 1pm: 2525Wed × 1pm: 2828Thu × 1pm: 3131Fri × 1pm: 1818Mon × 3pm: 1818Tue × 3pm: 2020Wed × 3pm: 2424Thu × 3pm: 2626Fri × 3pm: 1212Mon × 5pm: 88Tue × 5pm: 1111Wed × 5pm: 1313Thu × 5pm: 1515Fri × 5pm: 44MonTueWedThuFri344

TkxHeatmap is a matrix-style heatmap: categorical x and y axes with colour-coded cells. Reach for it for cohort retention, confusion matrices, correlation matrices, or hourly-traffic grids. For the date-driven GitHub-style activity calendar, use TkxCalendarHeatmap instead.

import { TkxHeatmap } from 'tekivex-ui';
<TkxHeatmap
data={[
{ x: 'Mon', y: '9am', value: 12 },
{ x: 'Mon', y: '10am', value: 30 },
{ x: 'Tue', y: '9am', value: 8 },
]}
showValues
/>
colorScale="diverging"
CPURAMI/OCPU × CPU: 1.001.00RAM × CPU: 0.620.62I/O × CPU: -0.35-0.35CPU × RAM: 0.620.62RAM × RAM: 1.001.00I/O × RAM: -0.12-0.12CPU × I/O: -0.35-0.35RAM × I/O: -0.12-0.12I/O × I/O: 1.001.00CPURAMI/O-1.001.00
PropTypeDefaultDescription
dataTkxHeatmapCell[]—Cells: { x, y, value, label? }. x/y are string | number.
xLabelsArray<string | number>derivedX-axis order; if omitted, sorted unique values from data.
yLabelsArray<string | number>derivedY-axis order; if omitted, sorted unique values from data.
cellSizenumber32Cell side length in px.
gapnumber2Spacing between cells in px.
colorScale'sequential' | 'diverging' | string[]'sequential'Built-in scale or custom hex stop array.
domain[number, number]derived[min, max] for colour mapping; defaults to data min/max.
showValuesbooleanfalseRender the value text inside each cell.
showLegendbooleantrueRender the colour legend.
legendPosition'right' | 'bottom''right'Legend placement.
formatValue(v: number) => stringString(v)Format cell and tooltip values.
emptyCellColorstringtheme.surfaceAltFill for an (x, y) pair with no datapoint.
ariaLabelstringautoAccessible name; auto-generated from grid size and range.
onCellClick(cell: TkxHeatmapCell) => void—Fires when a cell that has data is clicked.

All other div attributes (except onClick) are spread onto the root.

  • Scales: 'sequential' lerps from a near-white tint to the theme primary; 'diverging' is a fixed red → white → blue ramp ideal for correlation matrices in [-1, 1]. A custom string[] is interpolated evenly across its stops.
  • Axis labels with mixed numeric/string values are sorted numerically only when every value parses as a number; otherwise they sort by localeCompare.
  • Long x-axis labels (wider than a cell) are automatically rotated -45°.
  • In-cell value text picks black or white per WCAG luminance for contrast, so it stays readable on any cell colour.
  • A degenerate domain (all values identical) maps every cell to the mid-colour.
  • onCellClick only fires for cells that have a datapoint — empty cells are not interactive.

src/components/TkxHeatmap.tsx