# 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.

To see how a legend is defined, take a look at [the legend block section](https://developers.felt.com/felt-style-language/style-definition-blocks/the-legend-block).

## Simple legend

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

```jsx
"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:

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

![](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:

```jsx
"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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
