Skip to content
On this page

Charts > Heat map ​

A heat map is a graphical representation of data where values in a matrix are represented as colors, with each cell's color intensity indicating the magnitude of the corresponding data point, commonly used to visualize patterns, correlations, or distributions in large datasets.

The Chart ​

Average temperature in : °C

Monthly average surface temperatures by year, Spain. Source: Our World in Data

Download example CSV
Copy HTML

Playground ​

Style

Color range

Usage Example (with tooltip) ​

vue
<template>
  <Heatmap :data="data" @hover="setTooltip" />

  <OTTooltip :info="tooltip">
    <p>{{ tooltip?.data?.name }} :</p>
  </OTTooltip>
</template>

<script setup>
import useTooltip from "@/functions/useTooltip.js";

const [tooltip, setTooltip] = useTooltip();
</script>

Component API ​

The heatmap is built using HTML and d3.

Data ​

js
[
  { name: "row 1", values: [10, 20, 30, 20, 10] },
  { name: "row 2", values: [50, 10, 20, 40, 30] },
  { name: "row 3", values: [5, 30, 20, 10, 50] },
];

Props ​

NameDefaultDescriptionType
data[]The datasetArray
categories[1, 2, 3, 4, 5]The column namesArray
colorRange['#BEDDE3', '#04404b']The min and max colorsArray
rangenullThe min and max values (use min, 0, max for diverging scale)Array
rotateHeadersfalseWhether or not to rotate the column namesBoolean
useIndexKeyfalseWhether or not to use the index as key for rowsBoolean
scaleTypescaleLinearThe type of scale to use (e.g. scaleLinear, scaleDiverging)String
showValuestrueWhether or not to show values on hoverBoolean
format(d) => d.toFixed(0)The format function for valuesFunction

Events ​

NameArgumentDescription
@select{ target, data }Emitted when row is clicked
@hover{ target, data, meta: { categories } } | nullEmitted when row is hovered

Dependencies ​

  • d3