Browse Components

Heatmap

Spot patterns across a matrix of values.

Basic

Hover, tap or focus a mark to inspect exact values. Arrow keys move between observations.

Weekly activity
Weekly activity — example data
ObservationMorningMiddayEveningNight
Mon1228194
Tue835246
Wed1631185
Thu1140278
Fri20333812
Sat7172915
Sun514229
View Code
HTML
<figure class="chart" data-chart="heatmap">
  <figcaption>
    Weekly activity
  </figcaption>
  <div class="chart-data">
    <table>
      <caption>
        Weekly activity — example data
      </caption>
      <thead>
        <tr>
          <th scope="col">
            Observation
          </th>
          <th scope="col">
            Morning
          </th>
          <th scope="col">
            Midday
          </th>
          <th scope="col">
            Evening
          </th>
          <th scope="col">
            Night
          </th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th scope="row">
            Mon
          </th>
          <td>
            12
          </td>
          <td>
            28
          </td>
          <td>
            19
          </td>
          <td>
            4
          </td>
        </tr>
        <tr>
          <th scope="row">
            Tue
          </th>
          <td>
            8
          </td>
          <td>
            35
          </td>
          <td>
            24
          </td>
          <td>
            6
          </td>
        </tr>
        <tr>
          <th scope="row">
            Wed
          </th>
          <td>
            16
          </td>
          <td>
            31
          </td>
          <td>
            18
          </td>
          <td>
            5
          </td>
        </tr>
        <tr>
          <th scope="row">
            Thu
          </th>
          <td>
            11
          </td>
          <td>
            40
          </td>
          <td>
            27
          </td>
          <td>
            8
          </td>
        </tr>
        <tr>
          <th scope="row">
            Fri
          </th>
          <td>
            20
          </td>
          <td>
            33
          </td>
          <td>
            38
          </td>
          <td>
            12
          </td>
        </tr>
        <tr>
          <th scope="row">
            Sat
          </th>
          <td>
            7
          </td>
          <td>
            17
          </td>
          <td>
            29
          </td>
          <td>
            15
          </td>
        </tr>
        <tr>
          <th scope="row">
            Sun
          </th>
          <td>
            5
          </td>
          <td>
            14
          </td>
          <td>
            22
          </td>
          <td>
            9
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</figure>

Right-to-left

Labels follow the reading direction. Numeric and radial axes keep their established orientation.

Weekly activity
Weekly activity — example data
ObservationMorningMiddayEveningNight
Mon1228194
Tue835246
Wed1631185
Thu1140278
Fri20333812
Sat7172915
Sun514229
View Code
HTML
<figure class="chart" dir="rtl" data-chart="heatmap">
  <figcaption>
    Weekly activity
  </figcaption>
  <div class="chart-data">
    <table>
      <caption>
        Weekly activity — example data
      </caption>
      <thead>
        <tr>
          <th scope="col">
            Observation
          </th>
          <th scope="col">
            Morning
          </th>
          <th scope="col">
            Midday
          </th>
          <th scope="col">
            Evening
          </th>
          <th scope="col">
            Night
          </th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th scope="row">
            Mon
          </th>
          <td>
            12
          </td>
          <td>
            28
          </td>
          <td>
            19
          </td>
          <td>
            4
          </td>
        </tr>
        <tr>
          <th scope="row">
            Tue
          </th>
          <td>
            8
          </td>
          <td>
            35
          </td>
          <td>
            24
          </td>
          <td>
            6
          </td>
        </tr>
        <tr>
          <th scope="row">
            Wed
          </th>
          <td>
            16
          </td>
          <td>
            31
          </td>
          <td>
            18
          </td>
          <td>
            5
          </td>
        </tr>
        <tr>
          <th scope="row">
            Thu
          </th>
          <td>
            11
          </td>
          <td>
            40
          </td>
          <td>
            27
          </td>
          <td>
            8
          </td>
        </tr>
        <tr>
          <th scope="row">
            Fri
          </th>
          <td>
            20
          </td>
          <td>
            33
          </td>
          <td>
            38
          </td>
          <td>
            12
          </td>
        </tr>
        <tr>
          <th scope="row">
            Sat
          </th>
          <td>
            7
          </td>
          <td>
            17
          </td>
          <td>
            29
          </td>
          <td>
            15
          </td>
        </tr>
        <tr>
          <th scope="row">
            Sun
          </th>
          <td>
            5
          </td>
          <td>
            14
          </td>
          <td>
            22
          </td>
          <td>
            9
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</figure>

Empty data

The chart keeps its reserved space without inventing observations.

Weekly activity
Weekly activity — example data
ObservationMorningMiddayEveningNight
View Code
HTML
<figure
  class="chart"
  data-chart-labels="[&quot;Mon&quot;, &quot;Tue&quot;, &quot;Wed&quot;, &quot;Thu&quot;, &quot;Fri&quot;, &quot;Sat&quot;, &quot;Sun&quot;]"
  data-chart="heatmap"
>
  <figcaption>
    Weekly activity
  </figcaption>
  <div class="chart-data">
    <table>
      <caption>
        Weekly activity — example data
      </caption>
      <thead>
        <tr>
          <th scope="col">
            Observation
          </th>
          <th scope="col">
            Morning
          </th>
          <th scope="col">
            Midday
          </th>
          <th scope="col">
            Evening
          </th>
          <th scope="col">
            Night
          </th>
        </tr>
      </thead>
      <tbody>
      </tbody>
    </table>
  </div>
</figure>

Installation

Download these files into the matching paths in your project, or use Create to assemble a kit. Include each dependency once. Do not also load app.css.

Add to your page
<link rel="stylesheet" href="/library/assets/base.css">
<link rel="stylesheet" href="/library/assets/chart-core.css">
<link rel="stylesheet" href="/library/assets/chart-plots.css">
<link rel="stylesheet" href="/library/assets/heatmap.css">
<script defer src="/library/assets/chart-core.js"></script>
<script defer src="/library/assets/chart-plots.js"></script>
<script defer src="/library/assets/heatmap.js"></script>

12,194 bytes CSS including base · 16,434 bytes runtime JavaScript

Usage

Data format

Rows and columns form a matrix with up to four columns and 32 rows. Darker or brighter cells indicate higher values using a single sequential color scale. Hover or focus for exact values; compare only within the same scale.

Shared interactions

Hover, tap or focus a mark to inspect its exact value. Arrow keys, Home and End move between marks; Escape dismisses the tooltip. The source table remains available without JavaScript. Enhanced charts expose exact values through accessible marks and tooltips.

Lifecycle and themes

Load Chart Core, Chart Plots and this component module. Theme tokens supply colors in light and dark modes. Use layoutCharts.refresh(root) after changing the table and destroy(root) before unmounting. Wide charts scroll within their frame.

Building with AI? The AI Manifest has these notes and the full contract. See the AI Guide.