# Heatmap Chart

The <a href="https://www.telerik.com/blazor-ui/heatmap" target="_blank">Blazor Heatmap chart</a> shows the data in a grid-like structure that shows the magnitude of a value over two dimensions.

![Heatmap chart showing values across two dimensions](https://www.telerik.com/blazor-ui/documentation/assets/7eb612ebc5d5ab497ba8eaa5a87435ff/heatmap-chart.png)

#### In this article:

* [Data Binding Notes](https://www.telerik.com/blazor-ui/documentation/components/chart/types/heatmap#data-binding-notes)
* [Heatmap Chart Specific Appearance Settings](https://www.telerik.com/blazor-ui/documentation/components/chart/types/heatmap#heatmap-chart-specific-appearance-settings)
  * [Setting the Marker Type](https://www.telerik.com/blazor-ui/documentation/components/chart/types/heatmap#setting-the-marker-type)
  * [Color](https://www.telerik.com/blazor-ui/documentation/components/chart/types/heatmap#color)
  * [ColorField](https://www.telerik.com/blazor-ui/documentation/components/chart/types/heatmap#colorfield)
  * [Handling Long Y-axis Labels](https://www.telerik.com/blazor-ui/documentation/components/chart/types/heatmap#handling-long-y-axis-labels)
  * [Customize Chart Elements - Nested Tags Settings](https://www.telerik.com/blazor-ui/documentation/components/chart/types/heatmap#customize-chart-elements-nested-tags-settings)

This article assumes you are familiar with the [chart basics](https://www.telerik.com/blazor-ui/documentation/components/chart/overview) and [data binding](https://www.telerik.com/blazor-ui/documentation/components/chart/data-bind).

#### To create a Heatmap chart:

1. add a `ChartSeries` to the `ChartSeriesItems` collection
2. set its `Type` property to `ChartSeriesType.Heatmap`
3. provide a data collection to its `Data` property and set the corresponding attributes:
   * `XField` - the field that will be displayed on the X-axis
   * `YField` - the field that will be displayed on the Y-axis
   * `Field` - the field that will be rendered in the contents of the Heatmap Chart
4. optionally, provide data for the X and Y axes `Categories`

> caption A Heatmap Chart that shows commits made by developers

<demo metaUrl="client/chart/types/heatmap/overview/" height="500"></demo>

## Data Binding Notes

When you are data binding the Heatmap Chart you should have the following points under consideration:

* When you have set a value for the `XField` and `YField` attributes, you do not have to provide an `object[]` to the `Categories` attribute of the `<ChartXAxis>`, and the `<ChartYAxis>`.
  * If you define both `X/YField` and the `<ChartX/YAxis>` the items must match, otherwise blank data items will be rendered in the Heatmap content.

> caption Heatmap Chart where the data for the `Categories` does not match the `YField` value. **Problematic behavior**. The result from the code snippet below.

![Heatmap chart with mismatched category values](https://www.telerik.com/blazor-ui/documentation/assets/1642f6633793a245e6a0cad9390362cf/heatmap-problematic-behavior.png)

<demo metaUrl="client/chart/types/heatmap/categories-mismatch/" height="500"></demo>

## Heatmap Chart Specific Appearance Settings

### Setting the Marker Type

To change the marker type you should set the `Type` parameter, exposed on the `ChartSeriesMarkers` tag (child tag of the `<ChartSeries>`). It takes a member of the Telerik.Blazor.Components.ChartSeriesMarkersType enum:

* `Rect` - the default value - specifies a rectangular form of the marker.

* `RoundedRect` - specifies a rectangle with rounded edges form of the marker.

> caption Change the Type of the marker.

<demo metaUrl="client/chart/types/heatmap/marker-type/" height="500"></demo>

### Color

The `Color` parameter controls the general color palette for the markers of the Heatmap. The individual marker color set to the markers depends the value bound to the `Field` - the higher the value the darker the color.

> caption Change the Color of the Heatmap.

<demo metaUrl="client/chart/types/heatmap/color/" height="500"></demo>

### ColorField

The `ColorField` parameter allows you to control the color of an individual marker in the content of the Heatmap. If you do not provide a color in the field bound to the `ColorField` the Heatmap will render white markers.

> caption Provide a custom color to all markers in the Heatmap.

<demo metaUrl="client/chart/types/heatmap/color-field/" height="500"></demo>

### Handling Long Y-axis Labels

The Heatmap Y axis displays categories from the `YField` or the `Categories` collection. These categories can be text, such as names or descriptions. To prevent long labels from being truncated, use the settings under `ChartYAxisLabels` to adjust the label font, margin, position, or density. You can also rotate labels with the nested `ChartYAxisLabelsRotation` tag or provide custom label text through the `Template` parameter.

The Chart does not provide a Heatmap-specific parameter that automatically wraps Y-axis labels. If the labels still do not fit, increase the available chart width, shorten the category text, or hide the labels when the category information is available elsewhere. For general label rotation and density examples, see [Prevent crowded labels in the Chart](https://www.telerik.com/blazor-ui/documentation/knowledge-base/chart-crowded-labels). For custom label output and line breaks, see [Label Template and Format](https://www.telerik.com/blazor-ui/documentation/components/chart/labels-template-and-format).

### Customize Chart Elements - Nested Tags Settings

When configuring nested properties and child elements in your chart, the inner tags will contain their parent tag name and add specifics to its end. In general the structure of such nested tags will be `<Chart*Category**Specifics*>` where the Category can be one of the following:

* CategoryAxis
* ChartArea
* Legend
* PlotArea
* SeriesItems
* Title
* Tooltip
* ValueAxis
* XAxes
* YAxes
* and others

> tip To customize the chart, look for nested tags and their properties - the inner tags will contain their parent tag name and add specifics to its end. For example, the `ChartSeries` tag has a `ChartSeriesLabels` tag that exposes configuration options and more child tags.

For example, for [axis-free](https://www.telerik.com/blazor-ui/documentation/components/chart/data-bind#series-types) charts you can rotate their Labels, Title, Legend and others. Example for doing so is customizing the Chart Series Labels by using the parameters in the

`ChartSeriesItems` > `ChartSeries` > `ChartSeriesLabels` tag and its child tags.

This approach is not limited only to the Labels - it can be used with to all tags that are applicable for the chart type, for example the Chart Title `ChartTitle` > `ChartTitleMargin`.

> caption Hide the Labels for both X and Y axes.

<demo metaUrl="client/chart/types/heatmap/hide-axis-labels/" height="500"></demo>

## See Also

* [Live Demo: Heatmap Chart](https://demos.telerik.com/blazor-ui/chart/heatmap-chart)
