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
fieldsinstead offield, each category names itsfield, 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 lowestvalueat or above the feature value;greater_thanthe highestvalueat or below it. Any othergraduated_breaksbecomesless_than. Values outside all ranges get the nearest category. Without categories the theme is ignored with a warning.[3] - distributed:
fielddefaults toid; 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.
{
"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" } }
]
}
}
}
}
}
}
}