# @salmonui/charts/heat-map API reference

> 17 exported symbols of @salmonui/charts/heat-map: 1 component, 1 function, 11 interfaces, 3 types and 1 constant.

Canonical: https://salmonui.dev/docs/reference/charts/heat-map

```ts
import { … } from '@salmonui/charts/heat-map';
```

## Components

### HeatMap

Kind: component

Page: https://salmonui.dev/docs/reference/charts/heat-map/HeatMap

```ts
function HeatMap(props: HeatMapProps): ReactNode;
```

Props: [`HeatMapProps`](https://salmonui.dev/docs/reference/charts/heat-map/HeatMapProps) (its members are the props)

## Interfaces

### HeatMapAxis

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/heat-map/HeatMapAxis

```ts
interface HeatMapAxis {
    readonly scale?: 'category' | 'linear' | 'time' | undefined;
    readonly labels?: readonly string[] | undefined;
    readonly min?: number | undefined;
    readonly max?: number | undefined;
    readonly interval?: number | undefined;
    readonly format?: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions | ((value: string) => string) | undefined;
    readonly labelOverlap?: 'none' | 'hide' | 'trim' | 'wrap' | 'rotate45' | 'rotate90' | undefined;
    readonly maxLabelWidth?: number | undefined;
    readonly position?: 'bottom' | 'top' | 'start' | 'end' | undefined;
    readonly reversed?: boolean | undefined;
    readonly title?: string | undefined;
    readonly labelGroups?: readonly HeatMapLabelGroup[] | undefined;
}
```

Members (12):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `scale` | `readonly scale?: 'category' \| 'linear' \| 'time' \| undefined;` | optional | How keys are ordered and formatted. Default `category` (first seen order). |
| `labels` | `readonly labels?: readonly string[] \| undefined;` | optional | Explicit category labels (table data), in order. |
| `min` | `readonly min?: number \| undefined;` | optional | Numeric / time axes: keep keys in [min, max]. |
| `max` | `readonly max?: number \| undefined;` | optional |  |
| `interval` | `readonly interval?: number \| undefined;` | optional | Show every `interval`-th label. |
| `format` | `readonly format?: Intl.NumberFormatOptions \| Intl.DateTimeFormatOptions \| ((value: string) => string) \| undefined;` | optional | Label format for numeric and time keys. |
| `labelOverlap` | `readonly labelOverlap?: 'none' \| 'hide' \| 'trim' \| 'wrap' \| 'rotate45' \| 'rotate90' \| undefined;` | optional |  |
| `maxLabelWidth` | `readonly maxLabelWidth?: number \| undefined;` | optional |  |
| `position` | `readonly position?: 'bottom' \| 'top' \| 'start' \| 'end' \| undefined;` | optional | x: `bottom` \| `top`; y: `start` \| `end`. |
| `reversed` | `readonly reversed?: boolean \| undefined;` | optional |  |
| `title` | `readonly title?: string \| undefined;` | optional |  |
| `labelGroups` | `readonly labelGroups?: readonly HeatMapLabelGroup[] \| undefined;` | optional | Multi-level labels below (x) or beside (y) the axis labels. |

### HeatMapCell

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/heat-map/HeatMapCell

```ts
interface HeatMapCell {
    readonly x: number;
    readonly y: number;
    readonly xKey: string;
    readonly yKey: string;
    readonly value: number;
    readonly size: number | null;
    readonly color: string;
}
```

Members (7):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `x` | `readonly x: number;` |  |  |
| `y` | `readonly y: number;` |  |  |
| `xKey` | `readonly xKey: string;` |  |  |
| `yKey` | `readonly yKey: string;` |  |  |
| `value` | `readonly value: number;` |  | NaN for an empty cell. |
| `size` | `readonly size: number \| null;` |  |  |
| `color` | `readonly color: string;` |  |  |

### HeatMapCellRef

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/heat-map/HeatMapCellRef

```ts
interface HeatMapCellRef {
    readonly x: number;
    readonly y: number;
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `x` | `readonly x: number;` |  |  |
| `y` | `readonly y: number;` |  |  |

### HeatMapCellsOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/heat-map/HeatMapCellsOptions

```ts
interface HeatMapCellsOptions {
    readonly labels?: boolean | undefined;
    readonly format?: Intl.NumberFormatOptions | ((value: number) => string) | undefined;
    readonly shape?: 'rect' | 'bubble' | undefined;
    readonly bubble?: 'size' | 'color' | 'sizeAndColor' | 'sector' | undefined;
    readonly highlight?: boolean | undefined;
}
```

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `labels` | `readonly labels?: boolean \| undefined;` | optional |  |
| `format` | `readonly format?: Intl.NumberFormatOptions \| ((value: number) => string) \| undefined;` | optional |  |
| `shape` | `readonly shape?: 'rect' \| 'bubble' \| undefined;` | optional |  |
| `bubble` | `readonly bubble?: 'size' \| 'color' \| 'sizeAndColor' \| 'sector' \| undefined;` | optional |  |
| `highlight` | `readonly highlight?: boolean \| undefined;` | optional | Dim other cells on hover. Default true. |

### HeatMapColorScale

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/heat-map/HeatMapColorScale

```ts
interface HeatMapColorScale {
    readonly kind?: 'gradient' | 'steps' | undefined;
    readonly stops?: readonly HeatMapStop[] | undefined;
    readonly domain?: 'all' | 'row' | 'column' | undefined;
    readonly outOfRange?: string | undefined;
}
```

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `kind` | `readonly kind?: 'gradient' \| 'steps' \| undefined;` | optional |  |
| `stops` | `readonly stops?: readonly HeatMapStop[] \| undefined;` | optional | Data values (domain `all`) or positions 0..1 (domain `row` / `column`). |
| `domain` | `readonly domain?: 'all' \| 'row' \| 'column' \| undefined;` | optional | Normalize per table, row or column. Default `all`. |
| `outOfRange` | `readonly outOfRange?: string \| undefined;` | optional | Color of values outside the stop range (steps); default the end stops. |

### HeatMapLabelGroup

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/heat-map/HeatMapLabelGroup

```ts
interface HeatMapLabelGroup {
    readonly from: number;
    readonly to: number;
    readonly text: string;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `from` | `readonly from: number;` |  | First and last category index covered (inclusive). |
| `to` | `readonly to: number;` |  |  |
| `text` | `readonly text: string;` |  |  |

### HeatMapLegendOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/heat-map/HeatMapLegendOptions

```ts
interface HeatMapLegendOptions {
    readonly position?: 'top' | 'bottom' | 'start' | 'end' | undefined;
    readonly title?: string | undefined;
    readonly labels?: 'all' | 'edge' | 'none' | undefined;
    readonly format?: ((value: number) => string) | undefined;
    readonly toggle?: boolean | undefined;
}
```

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `position` | `readonly position?: 'top' \| 'bottom' \| 'start' \| 'end' \| undefined;` | optional |  |
| `title` | `readonly title?: string \| undefined;` | optional |  |
| `labels` | `readonly labels?: 'all' \| 'edge' \| 'none' \| undefined;` | optional |  |
| `format` | `readonly format?: ((value: number) => string) \| undefined;` | optional |  |
| `toggle` | `readonly toggle?: boolean \| undefined;` | optional | Steps legend items toggle cells of that step. Default true. |

### HeatMapProps

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/heat-map/HeatMapProps

```ts
interface HeatMapProps {
    readonly data: readonly unknown[];
    readonly xField?: string | undefined;
    readonly yField?: string | undefined;
    readonly valueField?: string | undefined;
    readonly sizeField?: string | undefined;
    readonly xAxis?: HeatMapAxis | undefined;
    readonly yAxis?: HeatMapAxis | undefined;
    readonly colorScale?: HeatMapColorScale | undefined;
    readonly cells?: HeatMapCellsOptions | undefined;
    readonly legend?: boolean | HeatMapLegendOptions | undefined;
    readonly tooltip?: boolean | {
        readonly render?: ((cell: HeatMapCell) => ReactNode) | undefined;
    } | undefined;
    readonly selection?: boolean | {
        readonly multiple?: boolean | undefined;
    } | undefined;
    readonly selectedCells?: readonly HeatMapCellRef[] | undefined;
    readonly defaultSelectedCells?: readonly HeatMapCellRef[] | undefined;
    readonly onSelectedCellsChange?: ((cells: readonly HeatMapCellRef[], event: HeatMapChangeEvent) => void) | undefined;
    readonly hiddenItems?: readonly number[] | undefined;
    readonly defaultHiddenItems?: readonly number[] | undefined;
    readonly onHiddenItemsChange?: ((hidden: readonly number[], event: HeatMapChangeEvent) => void) | undefined;
    readonly onCellClick?: ((cell: HeatMapCell, event: HeatMapChangeEvent) => void) | undefined;
    readonly onCellDoubleClick?: ((cell: HeatMapCell) => void) | undefined;
    readonly onCellHover?: ((cell: HeatMapCell | null) => void) | undefined;
    readonly formatCell?: ((cell: HeatMapCell) => string) | undefined;
    readonly getCellStyle?: ((cell: HeatMapCell) => {
        readonly color?: string | undefined;
    } | undefined) | undefined;
    readonly renderer?: 'svg' | 'canvas' | 'auto' | undefined;
    readonly width?: number | undefined;
    readonly height?: number | undefined;
    readonly title?: string | undefined;
    readonly subtitle?: string | undefined;
    readonly description?: string | undefined;
    readonly locale?: string | undefined;
    readonly text?: Partial<HeatMapText> | undefined;
    readonly timeZone?: string | undefined;
    readonly showDataTable?: boolean | undefined;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
    readonly id?: string | undefined;
    readonly ref?: Ref<HeatMapApi> | undefined;
    readonly onResize?: ((size: {
        readonly width: number;
        readonly height: number;
    }) => void) | undefined;
    readonly animated?: boolean | undefined;
}
```

Members (39):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `data` | `readonly data: readonly unknown[];` |  | A 2D table (`data[row][column]`) or records with `xField` / `yField` / `valueField`. |
| `xField` | `readonly xField?: string \| undefined;` | optional |  |
| `yField` | `readonly yField?: string \| undefined;` | optional |  |
| `valueField` | `readonly valueField?: string \| undefined;` | optional |  |
| `sizeField` | `readonly sizeField?: string \| undefined;` | optional | Bubble size value. |
| `xAxis` | `readonly xAxis?: HeatMapAxis \| undefined;` | optional |  |
| `yAxis` | `readonly yAxis?: HeatMapAxis \| undefined;` | optional |  |
| `colorScale` | `readonly colorScale?: HeatMapColorScale \| undefined;` | optional |  |
| `cells` | `readonly cells?: HeatMapCellsOptions \| undefined;` | optional |  |
| `legend` | `readonly legend?: boolean \| HeatMapLegendOptions \| undefined;` | optional |  |
| `tooltip` | `readonly tooltip?: boolean \| {     readonly render?: ((cell: HeatMapCell) => ReactNode) \| undefined; } \| undefined;` | optional |  |
| `selection` | `readonly selection?: boolean \| {     readonly multiple?: boolean \| undefined; } \| undefined;` | optional |  |
| `selectedCells` | `readonly selectedCells?: readonly HeatMapCellRef[] \| undefined;` | optional |  |
| `defaultSelectedCells` | `readonly defaultSelectedCells?: readonly HeatMapCellRef[] \| undefined;` | optional |  |
| `onSelectedCellsChange` | `readonly onSelectedCellsChange?: ((cells: readonly HeatMapCellRef[], event: HeatMapChangeEvent) => void) \| undefined;` | optional |  |
| `hiddenItems` | `readonly hiddenItems?: readonly number[] \| undefined;` | optional | Indices of `steps` stops whose cells are hidden (legend toggles). |
| `defaultHiddenItems` | `readonly defaultHiddenItems?: readonly number[] \| undefined;` | optional |  |
| `onHiddenItemsChange` | `readonly onHiddenItemsChange?: ((hidden: readonly number[], event: HeatMapChangeEvent) => void) \| undefined;` | optional |  |
| `onCellClick` | `readonly onCellClick?: ((cell: HeatMapCell, event: HeatMapChangeEvent) => void) \| undefined;` | optional |  |
| `onCellDoubleClick` | `readonly onCellDoubleClick?: ((cell: HeatMapCell) => void) \| undefined;` | optional |  |
| `onCellHover` | `readonly onCellHover?: ((cell: HeatMapCell \| null) => void) \| undefined;` | optional |  |
| `formatCell` | `readonly formatCell?: ((cell: HeatMapCell) => string) \| undefined;` | optional | Cell label text. |
| `getCellStyle` | `readonly getCellStyle?: ((cell: HeatMapCell) => {     readonly color?: string \| undefined; } \| undefined) \| undefined;` | optional | Cell data color override. |
| `renderer` | `readonly renderer?: 'svg' \| 'canvas' \| 'auto' \| undefined;` | optional | `auto` draws marks on canvas from 10,000 cells. Default `auto`. |
| `width` | `readonly width?: number \| undefined;` | optional |  |
| `height` | `readonly height?: number \| undefined;` | optional |  |
| `title` | `readonly title?: string \| undefined;` | optional |  |
| `subtitle` | `readonly subtitle?: string \| undefined;` | optional |  |
| `description` | `readonly description?: string \| undefined;` | optional |  |
| `locale` | `readonly locale?: string \| undefined;` | optional |  |
| `text` | `readonly text?: Partial<HeatMapText> \| undefined;` | optional | Built-in text (over the nearest `LocaleProvider`'s `heatMap` entry). |
| `timeZone` | `readonly timeZone?: string \| undefined;` | optional |  |
| `showDataTable` | `readonly showDataTable?: boolean \| undefined;` | optional |  |
| `className` | `readonly className?: string \| undefined;` | optional |  |
| `style` | `readonly style?: CSSProperties \| undefined;` | optional |  |
| `id` | `readonly id?: string \| undefined;` | optional |  |
| `ref` | `readonly ref?: Ref<HeatMapApi> \| undefined;` | optional |  |
| `onResize` | `readonly onResize?: ((size: {     readonly width: number;     readonly height: number; }) => void) \| undefined;` | optional |  |
| `animated` | `readonly animated?: boolean \| undefined;` | optional | Entrance and update transitions, default `true`: client only (never in server markup), off under `prefers-reduced-motion`. The CSS is the opt-in `@salmonui/charts/viz-animations.css`. |

### HeatMapStop

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/heat-map/HeatMapStop

```ts
interface HeatMapStop {
    readonly value: number;
    readonly color: string;
    readonly label?: string | undefined;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `value` | `readonly value: number;` |  |  |
| `color` | `readonly color: string;` |  | Data color. |
| `label` | `readonly label?: string \| undefined;` | optional |  |

### HeatMapText

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/heat-map/HeatMapText

```ts
interface HeatMapText {
    readonly heatMap: string;
    readonly legend: string;
    readonly column: string;
    readonly row: string;
    readonly value: string;
    readonly noValue: string;
}
```

Built-in text of a HeatMap (`text` prop; the `heatMap` entry of a `LocaleProvider` catalog).

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `heatMap` | `readonly heatMap: string;` |  | Name and role description of the cell grid when there is no `title`. Default `"Heat map"`. |
| `legend` | `readonly legend: string;` |  |  |
| `column` | `readonly column: string;` |  | Data table headers without axis titles, and the value column. |
| `row` | `readonly row: string;` |  |  |
| `value` | `readonly value: string;` |  |  |
| `noValue` | `readonly noValue: string;` |  | A cell without a value. |

## Types

### HeatMapApi

Kind: type

Page: https://salmonui.dev/docs/reference/charts/heat-map/HeatMapApi

```ts
type HeatMapApi = VizInstance;
```

Members (7):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `element` | `element: HTMLElement \| null;` | inherited | The root `<figure>` (null before mount). |
| `export` | `export: (options?: VizExportOptions \| undefined) => Promise<void>;` | inherited | Downloads the visualization; settles after the download starts. |
| `toBlob` | `toBlob: (format?: ImageFormat \| undefined) => Promise<Blob>;` | inherited |  |
| `toDataURL` | `toDataURL: (format?: ImageFormat \| undefined) => Promise<string>;` | inherited |  |
| `toSVGString` | `toSVGString: () => string;` | inherited | The drawn SVG markup with `xmlns`, synchronously; theme colors stay `var(--salmon-*)` references. `toBlob('svg')` is the standalone file with colors resolved. Empty before mount. |
| `print` | `print: () => Promise<void>;` | inherited |  |
| `focus` | `focus: () => void;` | inherited | Focuses the plot (the one tab stop). |

### HeatMapChangeEvent

Kind: type

Page: https://salmonui.dev/docs/reference/charts/heat-map/HeatMapChangeEvent

```ts
type HeatMapChangeEvent = VizChangeEvent<'click' | 'keyboard' | 'legend'>;
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `source: VizChangeSource;` | inherited |  |
| `reason` | `reason: "click" \| "keyboard" \| "legend";` | inherited |  |

## Constants

### HEAT_MAP_CANVAS_THRESHOLD

Kind: const

Page: https://salmonui.dev/docs/reference/charts/heat-map/HEAT_MAP_CANVAS_THRESHOLD

```ts
const HEAT_MAP_CANVAS_THRESHOLD = 10000;
```

`renderer: 'auto'` switches to canvas at this many cells.

## Re-exported entry points

- [@salmonui/charts/chart/export](https://salmonui.dev/docs/reference/charts/chart-export.md): 3 symbols: 1 function, 1 interface and 1 type
  `ExportVisualizationsOptions`, `ExportableVisualization`, `exportVisualizations`
