Navigation

v2.1.0
Distribution

Heatmap chart

A pattern across two scales: cells as dark as their values.

On this page

A heatmap shows a pattern across two scales at once: the hours of a week, the months of several years. Each series is a row and each label a column, and the cell where they meet is as dark as its value between the lowest and the highest. Tone is the only channel, so a heatmap says where the high and the low values lie, not what they are.

Heatmap

<div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Commits</h3>    <p class="card-description">By day and hour</p>  </div>  <figure class="chart" id="activity"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('activity'), {  type: 'heatmap',  label: 'Commits by day of the week and hour',  labels: ['00', '03', '06', '09', '12', '15', '18', '21'],  series: [    { name: 'Mon', values: [1, 0, 2, 14, 18, 16, 9, 3] },    { name: 'Tue', values: [0, 1, 3, 16, 21, 19, 11, 4] },    { name: 'Wed', values: [2, 0, 4, 18, 24, 17, 12, 5] },    { name: 'Thu', values: [1, 1, 3, 15, 20, 22, 10, 6] },    { name: 'Fri', values: [0, 0, 2, 13, 17, 12, 6, 2] },    { name: 'Sat', values: [0, 0, 0, 3, 5, 4, 2, 1] },    { name: 'Sun', values: [0, 0, 1, 2, 4, 3, 3, 2] }  ]})})</script><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { Chart } from './ui/chart'<div className="card max-w(560) mx-auto">  <div className="card-header">    <h3 className="card-title">Commits</h3>    <p className="card-description">By day and hour</p>  </div>  <Chart    id="activity"    type="heatmap"    label="Commits by day of the week and hour"    labels={['00', '03', '06', '09', '12', '15', '18', '21']}    series={[      { name: 'Mon', values: [1, 0, 2, 14, 18, 16, 9, 3] },      { name: 'Tue', values: [0, 1, 3, 16, 21, 19, 11, 4] },      { name: 'Wed', values: [2, 0, 4, 18, 24, 17, 12, 5] },      { name: 'Thu', values: [1, 1, 3, 15, 20, 22, 10, 6] },      { name: 'Fri', values: [0, 0, 2, 13, 17, 12, 6, 2] },      { name: 'Sat', values: [0, 0, 0, 3, 5, 4, 2, 1] },      { name: 'Sun', values: [0, 0, 1, 2, 4, 3, 3, 2] }    ]}  /></div>
<script>  import Chart from './ui/Chart.svelte'</script><div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Commits</h3>    <p class="card-description">By day and hour</p>  </div>  <Chart    id="activity"    type="heatmap"    label="Commits by day of the week and hour"    labels={['00', '03', '06', '09', '12', '15', '18', '21']}    series={[      { name: 'Mon', values: [1, 0, 2, 14, 18, 16, 9, 3] },      { name: 'Tue', values: [0, 1, 3, 16, 21, 19, 11, 4] },      { name: 'Wed', values: [2, 0, 4, 18, 24, 17, 12, 5] },      { name: 'Thu', values: [1, 1, 3, 15, 20, 22, 10, 6] },      { name: 'Fri', values: [0, 0, 2, 13, 17, 12, 6, 2] },      { name: 'Sat', values: [0, 0, 0, 3, 5, 4, 2, 1] },      { name: 'Sun', values: [0, 0, 1, 2, 4, 3, 3, 2] }    ]}  /></div>
<script setup>import Chart from './ui/Chart.vue'</script><template>  <div class="card max-w(560) mx-auto">    <div class="card-header">      <h3 class="card-title">Commits</h3>      <p class="card-description">By day and hour</p>    </div>    <Chart      id="activity"      type="heatmap"      label="Commits by day of the week and hour"      :labels="['00', '03', '06', '09', '12', '15', '18', '21']"      :series="[        { name: 'Mon', values: [1, 0, 2, 14, 18, 16, 9, 3] },        { name: 'Tue', values: [0, 1, 3, 16, 21, 19, 11, 4] },        { name: 'Wed', values: [2, 0, 4, 18, 24, 17, 12, 5] },        { name: 'Thu', values: [1, 1, 3, 15, 20, 22, 10, 6] },        { name: 'Fri', values: [0, 0, 2, 13, 17, 12, 6, 2] },        { name: 'Sat', values: [0, 0, 0, 3, 5, 4, 2, 1] },        { name: 'Sun', values: [0, 0, 1, 2, 4, 3, 3, 2] }      ]"    />  </div></template>
Each cell is a point: point at one, or walk them with the arrow keys.

The lowest value keeps a trace of ink, so a cell that holds a value is told from one that holds none; a value of null leaves its cell out. min and max hold the ends of the range, so two heatmaps side by side share one. A row's cells take its series' category when it names one; otherwise they are ink.

This is the heatmap with two named scales. A field of many small cells with no scales beside it, such as a year of days, is the heatmap component, which is a list the stylesheet draws with no script.

#Options

OptionDefault
labelnoneWhat the chart shows and in what unit: the plot's accessible name
labels[]The names along the scale, around a radar or over a heatmap's columns
series[]Each with a name and what its form reads: values, a value, points, ranges or children; optionally a category, a type, low and high, and a ring's max
min, max, ticksfit, 4The ends of the scale and about how many steps mark it; xMin, xMax and xTicks for a scatter's scale across
format, tickFormatthe locale'sHow a value and a tick are written; xFormat for a scatter's scale across

The readout, the keys, the legend, the colors and the scale are the same in every form: Chart holds them, with every option, class and custom property.