> 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 generate the labels for you — from the computed breaks for numeric classes, or from the category names for categorical visualizations (`"auto"` requires `steps` or `categories` to be set in `config`). An empty `legend: {}` still produces a legend entry using the dataset's geometry and color.

For continuous (non-stepped) color-by and heatmap legends keyed by index, `"0"` labels the lowest value and the highest index labels the highest value. Continuous **size** legends are the historical exception: their indices run inverted, with `"0"` labeling the maximum, `"1"` the midpoint, and `"2"` the minimum.

## Simple legend

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

```json
"legend": {}
```

![](https://293097899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLlIfNdbm4rCsu755xrdc%2Fuploads%2FzphGB27BWsaU51Tm78HV%2Fsimple_legend.png?alt=media\&token=d5271603-da37-43e5-9747-7eefd88932b9)

## Categorical legend

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

```json
"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"
  }
}
```

![](https://293097899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLlIfNdbm4rCsu755xrdc%2Fuploads%2FkasxtqkVCdGmvoMhw7pH%2Fcategorical_legend.png?alt=media\&token=9bb3fcd0-8d28-4496-bdfa-4a3d4538c698)

## 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"
  }
}
```

![](https://293097899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLlIfNdbm4rCsu755xrdc%2Fuploads%2F7vbQ9JBcQy9JBGxXpuP3%2Fnumeric_stepped_legend.png?alt=media\&token=b658b946-1ad3-46c5-834f-844a2ec41886)

### **Continuous**

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

![](https://293097899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLlIfNdbm4rCsu755xrdc%2Fuploads%2FtWm3tentTQmzSRTmU5EO%2Fcontinuous_stepped_legend.png?alt=media\&token=671a0400-e541-47d6-8d1f-099aa6fb44cb)

## Heatmap legends

Heatmap legends are defined as follows:

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

![](https://293097899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLlIfNdbm4rCsu755xrdc%2Fuploads%2FiT3WxFiildEs6znxLD2o%2Fheatmap_legend.png?alt=media\&token=defa57d0-f170-4ab7-8ab5-d5b660e79834)

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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
