Skip to main content
{% map %}
    {% area_layer
        geography="us_states"
        match_by="name"
        data="state_sales"
        area_id="state"
        value="sum(sales)"
    /%}
{% /map %}

Examples

US States by Name

{% map %}
    {% area_layer
        geography="us_states"
        match_by="name"
        data="state_sales"
        area_id="state"
        value="sum(sales)"
    /%}
{% /map %}

US States by Abbreviation

{% map %}
    {% area_layer
        geography="us_states"
        match_by="abbr"
        data="state_sales"
        area_id="state_abbr"
        value="sum(sales)"
    /%}
{% /map %}

US Counties by State + County

{% map %}
    {% area_layer
        geography="us_counties"
        match_by="state-county"
        data="county_sales"
        area_id="state || '-' || county"
        value="sum(sales)"
    /%}
{% /map %}

US Counties by FIPS

{% map %}
    {% area_layer
        geography="us_counties"
        match_by="fips"
        data="county_sales"
        area_id="state_fips || county_fips"
        value="sum(sales)"
    /%}
{% /map %}

Custom GeoJSON

{% area_layer
    geojson_url="https://example.com/custom.geojson"
    geojson_id="id"
    data="my_data"
    area_id="region_id"
    value="sum(sales)"
/%}

Diverging Scale Centered at 0

{% map %}
    {% area_layer
        geography="us_states"
        match_by="abbr"
        data="state_growth"
        area_id="state_abbr"
        value="growth_pct"
        color_palette=["#d73027", "#ffffbf", "#1a9850"]
        min=-100
        max=100
        midpoint=0
    /%}
{% /map %}

Attributes

data
string
required
Name of the table to query
filters
array
Array of filter IDs to apply
geography
string
Pre-provided geography (use this OR geojson_url + geojson_id)Allowed values:
  • us_states
  • us_counties
match_by
string
How to match areas. For us_states: “name”, “abbr”, or “fips”. For us_counties: “state-county” or “fips”.
geojson_url
string
URL to custom GeoJSON file (use with geojson_id for custom maps)
geojson_id
string
GeoJSON property to join on. Use a string for single property (e.g., “NAME”) or array for composite key (e.g., [“STATE”, “COUNTY”]).
area_id
string
required
Column name in data that matches geo_id (e.g., “state_id”)
value
string
required
Column or expression for coloring the choropleth (e.g., “sum(sales)”)
color_palette
array
Array of colors for the choropleth gradient
min
number
Lower bound for the color scale. Values below this clamp to the first color in the palette. Defaults to the minimum value in the data.
max
number
Upper bound for the color scale. Values above this clamp to the last color in the palette. Defaults to the maximum value in the data.
midpoint
number
Anchor a specific value (typically 0) at the middle of a diverging color palette. Requires a color_palette with 3 or more colors.
show_unmatched
boolean
default:"true"
Whether to show areas that do not have matching data
tooltip
boolean
default:"true"
Show tooltips on hover
tooltip_fields
array
Array of SQL expressions for additional fields to show in tooltip (e.g., [“category”, “emissions”])
name_property
string
GeoJSON property to use for area name in tooltip (defaults to “NAME”)
value_fmt
string
default:"num"
Format for values in tooltip. See Value Formatting for available formats.
zoom_threshold
array
Zoom range [min, max] where this layer is visible (e.g., [0, 8] shows layer from zoom 0 to 8)
legend
boolean
default:"true"
Show legend for this layer
legend_label
string
Custom label for the legend (defaults to table name)
date_range
options group
Use date_range to filter data for specific time periods. Accepts predefined ranges (e.g., “last 12 months”), dynamic ranges (e.g., “Last 90 days”), custom date ranges (e.g., “2020-01-01 to 2023-03-01”), or partial ranges (e.g., “from 2020-01-01”, “until 2023-03-01”)Example:
date_range={
  range = "today"
  date = "string"
}
Attributes:
  • range: string - Time period to filter. Use presets like ‘last 7 days’, dynamic patterns like ‘Last 90 days’, custom ranges like ‘2020-01-01 to 2023-03-01’, or partial ranges like ‘from 2020-01-01’.
    • Allowed values:
      • today
      • yesterday
      • last 7 days
      • last 30 days
      • last 3 months
      • last 6 months
      • last 12 months
      • previous week
      • previous month
      • previous quarter
      • previous year
      • this week
      • this month
      • this quarter
      • this year
      • next week
      • next month
      • next quarter
      • next year
      • week to date
      • month to date
      • quarter to date
      • year to date
      • all time
  • date: string - Date column to filter on. Required when the data has multiple date columns.
where
string
Custom SQL WHERE condition to apply to the query. For date filters, use date_range instead.
having
string
Custom SQL HAVING condition to apply to the query after GROUP BY
limit
number
Maximum number of rows to return from the query. Note: When used with tables, limit will disable subtotals to prevent incomplete subtotal rows.
order
string
Column name(s) with optional direction (e.g. “column_name”, “column_name desc”)
qualify
string
Custom SQL QUALIFY condition to filter windowed results

Allowed Parents