> For the complete documentation index, see [llms.txt](https://developers.felt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.felt.com/felt-style-language/legends.md).

# Legends

Adding a legend block to a visualization makes a legend entry appear for this visualization.

Each legend entry is shown with the geometry type and color defined by the dataset and the visualization block.

While simple visualizations will generate a single legend entry, categorical visualizations will generate a legend entry per category.

## The `legend` block

The only field is `displayName`. For **categorical** visualizations it maps each category to its label; for **numeric**/**heatmap** visualizations it maps the index of each class (`"0"`, `"1"`, …) to its label. Set `"displayName": "auto"` to let Felt label numeric classes from the computed breaks. An empty `legend: {}` still produces a legend entry using the dataset's geometry and color.

## Simple legend

The Biodiversity Hotspots layer in Felt has a simple visualization with a legend defined as follows:

```jsx
"legend": {}
```

![](/files/aoYHJNg6ujxDyCfF0pTK)

## Categorical legend

The Plant Hardiness Zones layer in Felt has a categorical visualization with a legend defined as follows:

```jsx
"legend": {
  "displayName": {
    "13": "13: 60 to 70 °F",
    "12": "12: 50 to 60 °F",
    "11": "11: 40 to 50 °F",
    "10": "10: 30 to 40 °F",
    "9": "9: 20 to 30 °F",
    "8": "8: 10 to 20 °F",
    "7": "7: 0 to 10 °F",
    "6": "6: -10 to 0 °F",
    "5": "5: -20 to -10 °F",
    "4": "4: -30 to -20 °F",
    "3": "3: -40 to -30 °F",
    "2": "2: -50 to -40 °F",
    "1": "1: -60 to -50 °F"
  }
}
```

![](/files/pyGjTKXtT36O8XRuZpbI)

## Numeric legends

The visual display of numeric legends varies based on the style method (stepped or continuous) and the geometry type (point, line, polygon).

The `displayName` can be modified in the `legend` block similar to simple and categorical style types.

### Stepped

```json
"legend": {
  "displayName": {
    "0": "5.14 to 19.46",
    "1": "19.46 to 26.43",
    "2": "26.43 to 34.06",
    "3": "34.06 to 45.06",
    "4": "45.06 to 100"
  }
}
```

![](/files/3Splg2sWDtmD3FKHrExL)

### **Continuous**

```json
"legend": {
  "displayName": {
    "0": "2.34M", 
    "1": "714.65K", 
    "2": "33K"
  }
}
```

![](/files/2rdUZlF0iyVKg9CvwdQP)

## Heatmap legends

Heatmap legends are defined as follows:

```jsx
"legend": {
  "displayName": {
    "0": "Low", 
    "1": "High"
 }
}
```

![](/files/X3zL3cTbBtbXyHRTDwNC)

Notice that the `displayName` mapping goes from `0` (left value) to `1` (right value)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers.felt.com/felt-style-language/legends.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
