Skip to content

Theme categories ​

Categorized, graduated and distributed themes pick a style from categories by the feature's field value.

Categories ​

categories is an ordered array of { value, label, style }; label defaults to value. Style keys directly on a category, and an icon, move into its style. The legacy cat, keyed by value, and cat_arr become categories.[1]

  • categorized: values match as text. With fields instead of field, each category names its field, and a feature shows the icons of every matching category stacked; a category without an icon gets a dot icon with a warning. Cluster features are not themed.[2]
  • graduated: values are numbers, sorted by the parser. graduated_breaks: less_than (the default) picks the category with the lowest value at or above the feature value; greater_than the highest value at or below it. Any other graduated_breaks becomes less_than. Values outside all ranges get the nearest category. Without categories the theme is ignored with a warning.[3]
  • distributed: field defaults to id; features with the same value share a category.[4]

Requirements ​

Without categories a categorized or distributed theme throws for every feature,[2:1][4:1] and a graduated theme is ignored.[1:1] Do not leave the array empty for a distributed theme: assigning the first category fails. Without field a graduated theme, or without field or fields a categorized theme, matches no feature.

Distribution ​

distribution computes the legend from the loaded features:[5] count shows only the values present, with counts; jenks replaces graduated values with natural breaks, one per category. To follow the map extent, set params.viewport on vector layers, or wkt_properties on MVT layers. Another distribution is ignored.

Examples ​

A categorized continent theme with counts, and a jenks population theme.

json
{
  "dbs": "DEVDB",
  "locale": {
    "layers": {
      "countries": {
        "display": true,
        "format": "geojson",
        "table": "naturalearth.countries",
        "geom": "geom_4326",
        "srid": "4326",
        "qID": "id",
        "style": {
          "default": { "fillOpacity": 0.7, "strokeColor": "#fff", "strokeWidth": 1 },
          "themes": {
            "continent": {
              "type": "categorized",
              "field": "continent",
              "distribution": "count",
              "categories": [
                { "value": "Europe", "style": { "fillColor": "#1b9e77" } },
                { "value": "Africa", "style": { "fillColor": "#d95f02" } }
              ]
            },
            "population": {
              "type": "graduated",
              "field": "pop_est",
              "graduated_breaks": "greater_than",
              "distribution": "jenks",
              "categories": [
                { "style": { "fillColor": "#fee5d9" } },
                { "style": { "fillColor": "#fb6a4a" } },
                { "style": { "fillColor": "#a50f15" } }
              ]
            }
          }
        }
      }
    }
  }
}

  1. styleParser.mjs parseTheme, catStyle ↩︎ ↩︎

  2. themes/categorized.mjs ↩︎ ↩︎

  3. themes/graduated.mjs ↩︎

  4. themes/distributed.mjs ↩︎ ↩︎

  5. featureFields.mjs distribution ↩︎

XYZ v5.1.0. Generated from knowledge/ at dd7a6fa27736502733499c1bf485f15659b10338. Concepts marked draft are not reviewed.