Relationship · Intermediate

Heatmap

Values where two categories meet, shown as color depth.

Open in playground
Use when
Finding patterns such as orders by weekday × hour
Avoid when
Exact value comparison matters

Try it

10

Heatmap

Orders by weekday × hour
HeatmapHeatmap. 7 rows × 8 columns, values from 1 to 46.2131622162830213132518233321315212127282131324173032213142019324611213302238402131134253245
Heatmap data
Mon · 12am2
Mon · 3am1
Mon · 6am3
Mon · 9am16
Mon · 12pm22
Mon · 3pm16
Mon · 6pm28
Mon · 9pm30
Tue · 12am2
Tue · 3am1
Tue · 6am3
Tue · 9am13
Tue · 12pm25
Tue · 3pm18
Tue · 6pm23
Tue · 9pm33
Wed · 12am2
Wed · 3am1
Wed · 6am3
Wed · 9am15
Wed · 12pm21
Wed · 3pm21
Wed · 6pm27
Wed · 9pm28
Thu · 12am2
Thu · 3am1
Thu · 6am3
Thu · 9am13
Thu · 12pm24
Thu · 3pm17
Thu · 6pm30
Thu · 9pm32
Fri · 12am2
Fri · 3am1
Fri · 6am3
Fri · 9am14
Fri · 12pm20
Fri · 3pm19
Fri · 6pm32
Fri · 9pm46
Sat · 12am1
Sat · 3am1
Sat · 6am2
Sat · 9am13
Sat · 12pm30
Sat · 3pm22
Sat · 6pm38
Sat · 9pm40
Sun · 12am2
Sun · 3am1
Sun · 6am3
Sun · 9am11
Sun · 12pm34
Sun · 3pm25
Sun · 6pm32
Sun · 9pm45
Friday nights are the busiestIntermediate

Hover over the chart, or Tab in and use the arrow keys to move between items. The numbers are sample data.

Variants

Named looks for this chart. Each one is the example above with a few options or fields changed. The CLI (ztd-charts example heatmap --variant <id>) and the MCP server know the same names.

Every value

Orders by weekday × hour
Sample data

Without legend

Orders by weekday × hour
Sample data

Code

Heatmap.tsx
import { ChartCard, Heatmap } from "ztd-charts";

const data = [
  {"day":"Mon","hour":"12am","orders":2},
  {"day":"Mon","hour":"3am","orders":1},
  {"day":"Mon","hour":"6am","orders":3},
  {"day":"Mon","hour":"9am","orders":16},
  {"day":"Mon","hour":"12pm","orders":22},
  {"day":"Mon","hour":"3pm","orders":16},
  // … 50 more rows
];

export function Example() {
  return (
    <ChartCard number="10" title="Heatmap" subtitle="Orders by weekday × hour" takeaway="Friday nights are the busiest" level="intermediate" replay>
      <Heatmap
        data={data}
        x="hour"
        y="day"
        value="orders"
      />
    </ChartCard>
  );
}

Props

<Heatmap> takes these props. Rows marked Common work the same on every chart.

32 props

Prop
dataRequiredAn array of objects. Pass CSV, REST or database rows as they areobject[]
xRequiredColumn fieldstring | (d, i) => string
yRequiredRow fieldstring | (d, i) => string
valueRequiredValue fieldstring | (d, i) => number
showValuesNumbers in cells. "auto" shows them when they fitanyDefault "auto"
legendShow the color legendbooleanDefault true
legendLabelsNames at both ends of the legendstring[]
canvasThresholdCell count that switches to canvasnumberDefault 2500
colorReverseDarkest color for the smallest value, for rankings where 1st should stand out. The default highlight moves to the smallest value toobooleanDefault false
colorCenterValue that gets the lightest color. Values above take the accent color and values below take gray, so gains and losses split there (for example 0)number
colorStepsColor in this many steps instead of a smooth scale. The heatmap legend shows each stepnumber
heightCommonHeight in px. Without it, each chart picks a default that fits its widthnumber
widthCommonFixed width in px. Without it, the chart fits its parentnumber
highlightCommonItem to highlight. An index, a name, an array, or "max" | "min" | "first" | "last" | "none"number | string | (number|string)[] | "max" …
formatCommonValue format. "number" | "integer" | "percent" (values are already percents: 42 → "42%") | "ratio" (0.42 → "42%") | "compact" | "currency" (KRW for Korean locales, otherwise USD; for another currency pass Intl options with currency) | "decimal" or Intl.NumberFormat options"number" | "percent" | "compact" | …
unitCommonUnit appended to values. For example "%" or "ms"string
localeCommonLocale for numbers, dates and the text a chart writes itself (tooltips, screen reader sentences). "ko" or "ko-*" switches to Korean. Falls back to the ThemeProvider localestringDefault "en-US"
animateCommonEntry and update animationbooleanDefault true
durationCommonAnimation length (ms)number
easingCommonMotion curve"spring" | "easeOut" | "easeInOut" | "linear"Default "spring"
staggerCommonDelay between items as they enter (ms)number
reducedMotionCommon"auto" follows the OS setting. true always turns motion offanyDefault "auto"
animateOnViewCommonPlay when the chart scrolls into viewbooleanDefault true
showLabelsCommonLabels drawn on the chart (values and names)booleanDefault true
tooltipCommonShow tooltips. { template: "{label} · {value} · owner {owner}" } writes them: {label}, {value}, {series} or any other column of the row. \n starts a new line, and a line with an empty value is left outtooltipDefault true
syncIdCommonCharts with the same syncId show the hovered x together (line, area, bar, candlestick). <ChartGrid sync> sets one for every chart inside itstring
ariaLabelCommonName for screen readersstring
descriptionCommonDescription for screen readers. Built from the data when omittedstring
onHoverCommonRuns when hover or keyboard focus moves to another item(e: ChartEvent | null) => void
onClickCommonRuns on click, Enter or Space(e: ChartEvent) => void
replayKeyCommonReplays the entry animation when it changesstring | number
themeCommonChanges theme tokens for this chart onlyPartial<ChartTheme>

Above 2,500 items it draws on a canvas. Axes and labels stay SVG.