API Reference

Heatmap Chart API

Complete API reference for the Heatmap Chart, including data format, configuration options, custom parts, and context methods.

Data Format

A matrix of values indexed by x-labels (columns) and y-labels (rows). Values[yIndex][xIndex] represents the intensity at that cell.

type HeatmapData = {
  xLabels: string[];
  yLabels: string[];
  // segments are 2-dimensional array [yIndex][xIndex]
  values: number[][];
};
AG Style Config

Heatmap

PropertyTypeDefaultDescription
heatmap.colorRange[string, string, string]["#1D4ED8", "#FDE047", "#DC2626"]Three-color gradient range [low, mid, high] for mapping values.
heatmap.segment.gapnumber0Gap between heatmap cells in pixels.
Toast Style Config

Heatmap

PropertyTypeDefaultDescription
heatmap.colorRange[string, string, string]["#FDE68A", "#F97316", "#B91C1C"]Three-color gradient range [low, mid, high] for mapping values.
heatmap.segment.gapnumber0Gap between heatmap cells in pixels.

Custom Parts

Override any visual element by providing a custom builder function: (args, context) => Widget

PartArgsDescription
layout{ title: Widget; legend: Widget; plot: Widget }Top-level layout composing title, legend, and the plot area.
plot{ xAxis: Widget; yAxis: Widget; dataView: Widget; axisCorner: Widget; tooltipArea: Widget }The plot area composing axes, data view, and tooltip.
xAxis{ line: Widget; labels: Widget[]; tick: Widget }The complete x-axis assembly.
yAxis{ line: Widget; labels: Widget[]; tick: Widget }The complete y-axis assembly.
xAxisLabel{ name: string; index: number }Individual x-axis label.
yAxisLabel{ name: string; index: number }Individual y-axis label.
xAxisLineundefinedX-axis line.
yAxisLineundefinedY-axis line.
axisCornerundefinedCorner element where x and y axes meet.
xAxisTickundefinedX-axis tick mark.
yAxisTickundefinedY-axis tick mark.
dataView{ segments: Widget[][] }Container for all heatmap cells (2D array).
segment{ value: number; xIndex: number; yIndex: number; isHovered: boolean }Individual heatmap cell.
legendundefinedColor scale legend element.
titleundefinedChart title element.
tooltip{ label: string; items: { legend: string; color: string; value: number }[] }Tooltip content widget.
tooltipArea{ tooltip: Widget | null; hoveredSegment: HeatmapHoveredSegmentRect | null }Tooltip positioning area.

Context: HeatmapContext

Available in every custom builder via the second argument.

NameTypeKindDescription
dataHeatmapDatapropertyCurrent chart data.
widthnumberpropertyCurrent chart width in pixels.
heightnumberpropertyCurrent chart height in pixels.
scaleHeatmapScalepropertyComputed scale with min and max values.
hoveredSegmentHeatmapHoveredSegment | nullpropertyCurrently hovered cell info.
configTConfigpropertyThe resolved chart configuration object.
hoverSegment(xIndex, yIndex, anchorKey)(xIndex: number, yIndex: number, anchorKey: GlobalKey) => voidmethodSet hover state on a cell.
unhoverSegment(xIndex, yIndex)(xIndex: number, yIndex: number) => voidmethodClear hover if the specified cell is currently hovered.
unhoverAllSegments()() => voidmethodClear all cell hover state.
isSegmentHovered(xIndex, yIndex)(xIndex: number, yIndex: number) => booleanmethodCheck if a specific cell is hovered.
setSize(width, height)(width: number, height: number) => voidmethodUpdate chart dimensions.

Custom Part Example

import { ToastHeatmapChart } from "@/components/flitter/charts/toast-heatmap-chart";

<ToastHeatmapChart
  data={data}
  config={{
    heatmap: {
      colorRange: ["#dbeafe", "#3b82f6", "#1e3a5f"],
      segment: { gap: 2 },
    },
  }}
/>