Skip to content

Heatmap

Values on a grid of two categories, as shades of one colour: requests by weekday and hour. Darker is more; the scale gives the range.

import { Heatmap } from '@sypnia/ui/react'

On this page
  1. Requests by weekday and hour
  2. When to use it
  3. For everyone
  4. Props

Requests by weekday and hour

Requests
Per hour, last week
Day000102030405060708091011121314151617181920212223
Mon
Tue
Wed
Thu
Fri
Sat
Sun
View as table
Day000102030405060708091011121314151617181920212223
Mon152229361825323918812916019113216319413516619713816930371926
Tue162330371926331520514617720814918012115218312415518631382027
Wed172431382027341613216319413516619713816920014117220332392128
Thu182532392128351714918012115218312415518612715818913033152229
Fri192633152229361816619713816920014117220314417520614734162330
Sat8111469121587350627451637652647753661471012
Sun————10121588056698158708259718460721471013
Code
import { Heatmap } from '@sypnia/ui/react';

// Requests by weekday and hour. Darker is more; hover or focus a cell to read it.
const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
const hours = Array.from({ length: 24 }, (_, h) => String(h).padStart(2, '0'));
const values = days.map((_, d) => hours.map((_, h) => (d === 6 && h < 4 ? null : Math.round((d < 5 ? 1 : 0.4) * (h >= 8 && h <= 19 ? 120 + ((h * 31 + d * 17) % 90) : 15 + ((h * 7 + d) % 25))))));
export default function Week() {
  return <Heatmap title="Requests" subtitle="Per hour, last week" rows={days} columns={hours} values={values} rowLabel="Day" />;
}

When to use it

Use it when

  • Patterns by day and hour, or any two categories.

Do not use it when

  • Exact comparisons: shades are read roughly; use the table or a bar chart.

For everyone

  • It is a grid: each cell is focusable and named with its row, column and value.
  • Cells without a measure are outlined, not shaded.

Props

HeatmapTypeDefault
columnsrequired string[]
rowsrequired string[]
titlerequired ReactNode
valuesrequired

values[row][column]; null when there is no measure.

(number | null)[][]
empty ReactNode
error ReactNode
formatValue Fmt
height number
loading boolean
rowLabel string
subtitle ReactNode
  1. Requests by weekday and hour
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms