# Heatmap

Animated uniform grids for matrices, spectrograms, and capacity maps.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).





<ComponentPreview base="chartgpu" title="Basic Chart" name="heatmap-demo">
  <HeatmapDemo />
</ComponentPreview>

## Installation [#installation]

<CodeTabs>
  <TabsList>
    <TabsTrigger value="cli">
      Command
    </TabsTrigger>

    <TabsTrigger value="manual">
      Manual
    </TabsTrigger>
  </TabsList>

  <TabsContent value="cli">
    ```bash
    npx shadcn@latest add @chartcn/chartgpu/heatmap
    ```
  </TabsContent>

  <TabsContent value="manual">
    <Steps>
      <Step>
        Install the following dependencies:
      </Step>

      ```bash
      npm install @chartgpu/chartgpu
      ```

      <Step>
        Copy and paste the following code into your project.
      </Step>

      <ComponentSource src="registry/bases/chartgpu/ui/chart.tsx" title="components/chart/chart.tsx" />

      <ComponentSource src="registry/bases/chartgpu/ui/tooltip.ts" title="components/chart/tooltip.ts" />

      <ComponentSource src="registry/bases/chartgpu/components/heatmap/heatmap.tsx" title="components/chart/heatmap.tsx" />

      <Step>
        Update the import paths to match your project setup.
      </Step>
    </Steps>
  </TabsContent>
</CodeTabs>

## Usage [#usage]

```tsx
import { ChartcnHeatmap } from "@/components/chart/heatmap";
```

```tsx
<ChartcnHeatmap config={{}} data={data}>
  <ChartcnHeatmap.XAxis />
  <ChartcnHeatmap.YAxis />
  <ChartcnHeatmap.Legend />
  <ChartcnHeatmap.Tooltip />
  <ChartcnHeatmap.Heatmap colormap="viridis" />
</ChartcnHeatmap>
```

## Examples [#examples]

### Cell gaps and colormaps [#cell-gaps-and-colormaps]

<ComponentPreview base="chartgpu" title="Inferno cells" name="cell-gap-heatmap-demo">
  <CellGapHeatmapDemo />
</ComponentPreview>

## API Reference [#api-reference]

| Prop        | Type                         | Default                                 |
| ----------- | ---------------------------- | --------------------------------------- |
| `data`      | `HeatmapData`                | -                                       |
| `config`    | `ChartConfig`                | -                                       |
| `animation` | `boolean \| AnimationConfig` | `{ duration: 650, easing: "cubicOut" }` |
| `isLoading` | `boolean`                    | `false`                                 |

### Heatmap [#heatmap]

| Prop           | Type                                                                       | Default         |
| -------------- | -------------------------------------------------------------------------- | --------------- |
| `colormap`     | `"viridis" \| "plasma" \| "inferno" \| "magma" \| "grayscale" \| string[]` | `"viridis"`     |
| `cellGapPx`    | `number`                                                                   | `0`             |
| `opacity`      | `number`                                                                   | `1`             |
| `zScale`       | `"linear" \| "log"`                                                        | `"linear"`      |
| `nullHandling` | `"transparent" \| "lowest" \| "highest"`                                   | `"transparent"` |
