0|

Heatmap Chart

Documentation Index

Fetch the complete documentation index at: /llms.txt. Use this file to discover all available pages before exploring further.

Categorical heatmaps for session grids, correlation matrices, and intensity maps — powered by Apache ECharts

Basic Chart

Installation

pnpm dlx shadcn@latest add @beecharts/heatmap-chart @beecharts/chart-recipes

Usage

The heatmap chart is composible. <BeeHeatmapChart> is the container — pass a chartConfig whose keys match your intensity series. Flatten a row × column matrix with prepareHeatmapCells(), then compose <Heatmap /> with the resulting cells and optional axis labels. Add <Tooltip /> and <Legend /> when you want the shared BeeCharts chrome.

import {
  BeeHeatmapChart,
  Heatmap,
  Tooltip,
  Legend,
} from "@/components/beecharts/charts/heatmap-chart";
import { prepareHeatmapCells } from "@/lib/chart-recipes";
const rowLabels = ["Mon", "Tue", "Wed", "Thu", "Fri"];
const colLabels = ["9am", "12pm", "3pm", "6pm"];
const matrix = [
  [12, 28, 45, 22],
  [18, 35, 52, 30],
  [10, 22, 38, 18],
  [24, 42, 58, 36],
  [15, 30, 48, 26],
];
 
const { cells, min, max } = prepareHeatmapCells(rowLabels, colLabels, matrix);
 
const chartConfig = {
  intensity: {
    label: "Sessions",
    colors: {
      light: ["#fff7ed", "#f97316", "#9a3412"],
      dark: ["#431407", "#ea580c", "#fdba74"],
    },
  },
} satisfies ChartConfig;
 
<BeeHeatmapChart config={chartConfig} className="h-80 w-full">
  <Heatmap
    dataKey="intensity"
    data={cells}
    xLabels={colLabels}
    yLabels={rowLabels}
    min={min}
    max={max}
  />
  <Legend />
  <Tooltip />
</BeeHeatmapChart>

prepareHeatmapCells() returns flat { row, col, x, y, value } cells plus computed min / max for the visual map. Pass explicit min and max when you need a fixed scale across refreshes (for example, comparing weeks).

Examples

Session grid

Weekday × time-of-day activity — the default preview uses a warm amber scale so low traffic stays quiet and peaks read clearly.

session grid

Weekly density

A wider grid (seven days × eight slots) with a rose scale for dashboards that need finer time resolution.

weekly density

Correlation matrix

Symmetric product × product scores — useful for affinity, co-purchase, or feature correlation views.

correlation matrix

Team workload

Employee × day utilization for capacity planning — see also the calendar chart for single-person month views.

team workload

API Reference

The chart is composed of a root container and declarative parts. Render the root, then compose the slots you need as children.

BeeHeatmapChart

The root container. Owns chartConfig, the ECharts canvas, and the part registry that compiles heatmap options.

PropTypeDefaultDescription
config*ChartConfig

Configuration for the intensity series. Use a three-stop colors.light / colors.dark array on the key passed to <Heatmap dataKey /> — the compiler maps them to the ECharts visual map gradient.

children*ReactNode

Compose <Heatmap /> (required for data), optionally <Tooltip /> and <Legend />.

classNamestring

Size and layout classes on the chart container (for example h-80 w-full).

Heatmap

Registers matrix cells and axis labels with the ECharts compiler. Renders no DOM of its own.

PropTypeDefaultDescription
dataKey*string

Key into chartConfig for the visual map gradient and tooltip labels.

data*HeatmapCell[]

Flat cells from prepareHeatmapCells() — each { row, col, x, y, value }.

xLabelsstring[]

Column category labels (x-axis). Inferred from unique col values when omitted.

yLabelsstring[]

Row category labels (y-axis). Inferred from unique row values when omitted.

minnumber

Visual map minimum. Defaults to the smallest cell value.

maxnumber

Visual map maximum. Defaults to the largest cell value.

Tooltip

Enables the shared BeeCharts HTML tooltip layer when composed.

Legend

Hides the built-in ECharts legend and reserves space for the shared BeeCharts legend chrome when composed.