Skip to content

Entry filters ​

An infoj entry with filter adds an option to the filter panel of its layer; see layer filter for which entries are listed. Selecting it adds a card, whose input writes a filter expression for the entry field into layer.filter.current.[1]

filter: true derives the type from entry.type: text → like, and numeric, integer, date, datetime and boolean alike. Other entry types are not listed. An empty object acts like true but fails the strict schema. A string is the type; an object needs type, or it is skipped with a warning, as is an unknown type.[2]

typeInputWritesKeys
like, matchText inputlike or match with the textleading_wildcard
in, niCheckboxes, a dropdown or a searchbox of valuesin or ni with the selected valuesin, ni, dropdown, dropdown_pills, dropdown_search, searchbox, placeholder
numeric, integerRange slider and inputsgte and ltemin, max, step, prefix, suffix, label_a, label_b, histogram
date, datetimeDate inputs "after" and "before"gt and lt in epoch seconds
boolean, nullCheckboxboolean or nulllabel

meta adds a text to any card.

Behaviour ​

  • in and ni without a value array query the distinct values of the field with the distinct_values template, filtered by the other current filters. A configured in or ni array is offered as is.[1:1]
  • A range filter merges its entry, so entry.min, max, step, prefix and suffix apply unless the filter sets them. Bounds which are not set are queried with the field_minmax template. A range with configured bounds filters the layer as soon as the card opens.
  • histogram draws the built-in histogram dataview with the histogram query template of the field; an object sets options or queryparams, eg. buckets.

Pitfalls ​

  • With layer.filter.viewport, the queried minimum and maximum of the viewport replace configured min and max.
  • The date filters compare epoch seconds; the column must be numeric epoch seconds for them to match.
  • like matches the start of the value; commas in the input are alternatives. match compares the full text, so leading_wildcard only helps like.
  • minmax_query is documented in older JSDoc but not read; the range always queries field_minmax.

Examples ​

A countries layer whose panel filters the name, continent, subregion and population.

json
{
  "dbs": "DEVDB",
  "locale": {
    "layers": {
      "countries": {
        "display": true,
        "format": "geojson",
        "table": "naturalearth.countries",
        "geom": "geom_4326",
        "srid": "4326",
        "qID": "id",
        "infoj": [
          { "type": "key" },
          { "title": "Name", "field": "name", "filter": { "type": "like", "leading_wildcard": true } },
          {
            "title": "Continent",
            "field": "continent",
            "filter": { "type": "in", "dropdown_pills": true, "placeholder": "Select continents" }
          },
          { "title": "Subregion", "field": "subregion", "filter": { "type": "ni", "searchbox": true } },
          {
            "title": "Population",
            "field": "pop_est",
            "type": "integer",
            "filter": { "type": "integer", "min": 0, "meta": "Estimated population", "histogram": true, "label_a": "At least", "label_b": "At most" }
          }
        ]
      }
    }
  }
}

  1. layers/filters.mjs ↩︎ ↩︎

  2. panels/filter.mjs listFilter ↩︎

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