View as Markdown

Data Visualization

HeatMap

Heat maps from @salmonui/charts/heat-map with category, numeric and time axes, label groups, gradient and step color scales, bubbles, legends, selection, tooltips and a canvas renderer for a million cells.

HeatMap lives in @salmonui/charts/heat-map. data is a 2D table (data[row][column], rows are y) or records read through xField, yField and valueField; sizeField adds a second value for bubbles.

import { HeatMap } from '@salmonui/charts/heat-map';
import '@salmonui/charts/heat-map/styles.css';

<HeatMap data={table} xAxis={{ labels: days }} yAxis={{ labels: hours }} cells={{ labels: true }} height={360} />

Heat map with step legend

Open demo

A HeatMap of load by weekday and hour with cell labels, a step color scale of data colors, a toggling list legend, multiple selection and hour groups.

Load by weekday and hour

Heat map, 6 rows by 7 columns, values from 0 to 22.

Load by weekday and hour
HourColumnValue
00Mon0
00Tue5
00Wed10
00Thu15
00Fri3
00Sat8
00Sun13
04Mon11
04Tue16
04Wed4
04Thu9
04Fri14
04Sat2
04Sun7
08Mon11
08Tue16
08Wed21
08Thu9
08Fri14
08Sat13
08Sun1
12Mon22
12Tue10
12Wed15
12Thu20
12Fri8
12Sat7
12Sun12
16Mon16
16Tue21
16Wed9
16Thu14
16Fri19
16Sat1
16Sun6
20Mon4
20Tue9
20Wed14
20Thu2
20Fri7
20Sat12
20Sun0

Selected: none

Axes

xAxis and yAxis take labels, scale ('category', 'linear' or 'time': numeric and time keys are sorted and filtered by min / max), interval (every n-th label), format (Intl options or a function of the key), labelOverlap ('none', 'hide', 'trim', 'wrap', 'rotate45', 'rotate90'), maxLabelWidth, position ('bottom' / 'top', 'start' / 'end'), reversed, title and labelGroups: [{ from, to, text }] for a second level of labels. Time keys format in timeZone (UTC by default, so server and client agree).

Colors and legend

Without stops the cells use the derived sequential roles (--salmon-chart-sequential-1..9). colorScale takes data colors: { kind: 'gradient' | 'steps', stops: [{ value, color, label }], domain: 'all' | 'row' | 'column', outOfRange }. A gradient scale shows a gradient legend; a steps scale shows a list legend whose toggle buttons hide the cells of a step through hiddenItems / defaultHiddenItems / onHiddenItemsChange (indices of the steps stops). legend is true or { position: 'top' | 'bottom' | 'start' | 'end', title, labels: 'all' | 'edge' | 'none', format, toggle }. Empty cells (null) use the neutral empty color and read "No value" in the table.

cells: { labels, format, shape: 'rect' | 'bubble', bubble: 'size' | 'color' | 'sizeAndColor' | 'sector', highlight }. formatCell(cell) changes the label text and getCellStyle(cell) the color.

Selection, events and tooltip

selection (true or { multiple }) toggles cells on click, Enter and Space. Selection is controlled with selectedCells + onSelectedCellsChange or uncontrolled with defaultSelectedCells; cells are { x, y } column and row indices, and the event carries source and reason ('click' or 'keyboard').

import { useState } from 'react';
import { HeatMap, type HeatMapCellRef } from '@salmonui/charts/heat-map';

function Picker({ table }: { table: number[][] }) {
  const [selected, setSelected] = useState<readonly HeatMapCellRef[]>([]);
  return <HeatMap data={table} selection={{ multiple: true }} selectedCells={selected} onSelectedCellsChange={setSelected} height={300} />;
}

onCellClick(cell, event), onCellDoubleClick(cell) and onCellHover(cell | null) report a HeatMapCell (x, y, xKey, yKey, value, size, color). The tooltip (tooltip: true or { render(cell) }) is driven by the store: a pointer move that stays in a cell re-renders nothing.

Bubble heat map with custom cells

Open demo

A survey HeatMap of records with a value and a size field drawn as bubbles, long axis labels that trim or wrap, axis position and reversal, a title and subtitle, a custom tooltip, click and double-click events, formatCell and getCellStyle.

Engagement survey. Bubble size: number of responses

Heat map, 5 rows by 4 columns, values from 52 to 92.

Engagement survey
RowColumnValue
Customer onboardi…Q1 202652
Customer onboardi…Q2 202659
Customer onboardi…Q3 202666
Customer onboardi…Q4 202673
Payments platformQ1 202665
Payments platformQ2 202672
Payments platformQ3 202679
Payments platformQ4 202686★
Search and discove…Q1 202678
Search and discove…Q2 202685★
Search and discove…Q3 202692★
Search and discove…Q4 202658
Mobile experienceQ1 202691★
Mobile experienceQ2 202657
Mobile experienceQ3 202664
Mobile experienceQ4 202671
Data infrastructureQ1 202663
Data infrastructureQ2 202670
Data infrastructureQ3 202677
Data infrastructureQ4 202684

Last event: none

Large matrices

renderer is 'svg', 'canvas' or 'auto' (default): from 10,000 cells the cells draw on a lazily loaded canvas (one pixel per cell, scaled), while axes, legend, labels and the accessible table stay SVG and DOM. A 1,000 × 1,000 heat map mounts within 200 ms and hit-testing is index arithmetic. The server renders the axes and an empty, sized canvas.

Large heat map on canvas

Open demo

A 400 × 400 HeatMap (160,000 cells) that switches to the canvas renderer automatically, with a gradient of data colors per row.

160,000 cells

Heat map, 400 rows by 400 columns, values from -1 to 1.99.

160,000 cells
RowColumnValue
110
120.04
130.08
140.12
150.16
160.2
170.24
180.28
190.31
1100.35
1110.39
1120.43
1130.46
1140.5
1150.53
1160.56
1170.6
1180.63
1190.66
1200.69
1210.72
1220.74
1230.77
1240.8
1250.82
1260.84
1270.86
1280.88
1290.9
1300.92
1310.93
1320.95
1330.96
1340.97
1350.98
1360.99
1370.99
1381
1391
1401
1411
1421
1430.99
1440.99
1450.98
1460.97
1470.96
1480.95
1490.94
1500.93
1510.91
1520.89
1530.87
1540.85
1550.83
1560.81
1570.78
1580.76
1590.73
1600.7
1610.68
1620.65
1630.61
1640.58
1650.55
1660.52
1670.48
1680.45
1690.41
1700.37
1710.33
1720.3
1730.26
1740.22
1750.18
1760.14
1770.1
1780.06
1790.02
180-0.02
181-0.06
182-0.1
183-0.14
184-0.18
185-0.22
186-0.26
187-0.29
188-0.33
189-0.37
190-0.41
191-0.44
192-0.48
193-0.51
194-0.55
195-0.58
196-0.61
197-0.64
198-0.67
199-0.7
1100-0.73
1101-0.76
1102-0.78
1103-0.81
1104-0.83
1105-0.85
1106-0.87
1107-0.89
1108-0.91
1109-0.92
1110-0.94
1111-0.95
1112-0.96
1113-0.97
1114-0.98
1115-0.99
1116-0.99
1117-1
1118-1
1119-1
1120-1
1121-1
1122-0.99
1123-0.99
1124-0.98
1125-0.97
1126-0.96
1127-0.95
1128-0.93
1129-0.92
1130-0.9
1131-0.88
1132-0.86
1133-0.84
1134-0.82
1135-0.8
1136-0.77
1137-0.75
1138-0.72
1139-0.69
1140-0.66
1141-0.63
1142-0.6
1143-0.57
1144-0.53
1145-0.5
1146-0.46
1147-0.43
1148-0.39
1149-0.36
1150-0.32
1151-0.28
1152-0.24
1153-0.2
1154-0.16
1155-0.12
1156-0.08
1157-0.04
1158-0
11590.04
11600.08
11610.12
11620.16
11630.2
11640.23
11650.27
11660.31
11670.35
11680.39
11690.42
11700.46
11710.49
11720.53
11730.56
11740.59
11750.63
11760.66
11770.69
11780.72
11790.74
11800.77
11810.79
11820.82
11830.84
11840.86
11850.88
11860.9
11870.92
11880.93
11890.94
11900.96
11910.97
11920.98
11930.98
11940.99
11951
11961
11971
11981
11991
12000.99
12010.99
12020.98
12030.97
12040.96
12050.95
12060.94
12070.93
12080.91
12090.89
12100.87
12110.85
12120.83
12130.81
12140.79
12150.76
12160.73
12170.71
12180.68
12190.65
12200.62
12210.58
12220.55
12230.52
12240.48
12250.45
12260.41
12270.38
12280.34
12290.3
12300.26
12310.22
12320.18
12330.14
12340.1
12350.06
12360.02
1237-0.02
1238-0.06
1239-0.1
1240-0.13
1241-0.17
1242-0.21
1243-0.25
1244-0.29
1245-0.33
1246-0.37
1247-0.4
1248-0.44
1249-0.48
1250-0.51
1251-0.54
1252-0.58
1253-0.61
1254-0.64
1255-0.67
1256-0.7
1257-0.73
1258-0.75
1259-0.78
1260-0.8
1261-0.83
1262-0.85
1263-0.87
1264-0.89
1265-0.91
1266-0.92
1267-0.94
1268-0.95
1269-0.96
1270-0.97
1271-0.98
1272-0.99
1273-0.99
1274-1
1275-1
1276-1
1277-1
1278-1
1279-0.99
1280-0.99
1281-0.98
1282-0.97
1283-0.96
1284-0.95
1285-0.93
1286-0.92
1287-0.9
1288-0.88
1289-0.87
1290-0.84
1291-0.82
1292-0.8
1293-0.77
1294-0.75
1295-0.72
1296-0.69
1297-0.66
1298-0.63
1299-0.6
1300-0.57
1301-0.54
1302-0.5
1303-0.47
1304-0.43
1305-0.4
1306-0.36
1307-0.32
1308-0.28
1309-0.24
1310-0.2
1311-0.17
1312-0.13
1313-0.09
1314-0.05
1315-0.01
13160.03
13170.07
13180.11
13190.15
13200.19
13210.23
13220.27
13230.31
13240.35
13250.38
13260.42
13270.46
13280.49
13290.53
13300.56
13310.59
13320.62
13330.65
13340.68
13350.71
13360.74
13370.77
13380.79
13390.82
13400.84
13410.86
13420.88
13430.9
13440.91
13450.93
13460.94
13470.96
13480.97
13490.98
13500.98
13510.99
13521
13531
13541
13551
13561
13570.99
13580.99
13590.98
13600.98
13610.97
13620.95
13630.94
13640.93
13650.91
13660.89
13670.88
13680.86
13690.83
13700.81
13710.79
13720.76
13730.74
13740.71
13750.68
13760.65
13770.62
13780.59
13790.55
13800.52
13810.49
13820.45
13830.42
13840.38
13850.34
13860.3
13870.26
13880.23
13890.19
13900.15
13910.11
13920.07
13930.03
1394-0.01
1395-0.05
1396-0.09
1397-0.13
1398-0.17
1399-0.21
1400-0.25
210
220.04
230.08
240.12
250.16
260.2
270.24
280.28
290.32
2100.35
2110.39
2120.43
2130.46
2140.5
2150.53
2160.57
2170.6
2180.63
2190.66
2200.69
2210.72
2220.75
2230.77
2240.8
2250.82
2260.84
2270.86
2280.88
2290.9
2300.92
2310.93
2320.95
2330.96
2340.97
2350.98
2360.99
2370.99
2381
2391
2401
2411
2421
2431
2440.99
2450.98
2460.97
2470.96
2480.95
2490.94
2500.93
2510.91
2520.89
2530.87
2540.85
2550.83
2560.81
2570.79
2580.76
2590.73
2600.71
2610.68
2620.65
2630.62
2640.58
2650.55
2660.52
2670.48
2680.45
2690.41
2700.37
2710.34
2720.3
2730.26
2740.22
2750.18
2760.14
2770.1
2780.06
2790.02
280-0.02
281-0.06
282-0.1
283-0.14
284-0.17
285-0.21
286-0.25
287-0.29
288-0.33
289-0.37
290-0.4
291-0.44
292-0.47
293-0.51
294-0.54
295-0.58
296-0.61
297-0.64
298-0.67
299-0.7
2100-0.73
159500 more cells not shown

Keyboard and accessibility

One tab stop; arrow keys move by cell (reversed axes flip their arrows), Home / End to the row ends (with Ctrl to the corners), PageUp / PageDown to the first and last row, Enter or Space selects, Escape hides the tooltip. The focused cell is announced ("08, Wed: 12"). The table lists the cells, capped with a summary row for large matrices (showDataTable shows it). title and subtitle label the figure; description replaces the automatic summary.

Server rendering and API

The server renders the final SVG markup (or the sized empty canvas) at width / height, and time keys format in timeZone, so hydration matches; tooltips are client only. animated (default true) runs the entrance transition after hydration with the opt-in @salmonui/charts/viz-animations.css; it is off under prefers-reduced-motion. onResize reports size changes.

ref receives a HeatMapApi: element, export(options), toBlob, toDataURL, toSVGString, print() and focus(). Every prop and type is in the API reference.

Custom content uses render props (tooltip.render, formatCell, getCellStyle), not HTML string templates; colors follow the theme and visual tokens are system-owned (see Rendering and colors).