Skip to content

Dataviews ​

A dataview runs a query template and renders the response. Dataviews are configured in two places:

  • layer.dataviews maps keys to dataviews; the layer view lists them with checkboxes in a drawer.[1]
  • An infoj entry with type: dataview is a dataview for the location; its target defaults to the location view.[2]

Type and target ​

dataview names the renderer in mapp.ui.utils. The core has Json, a JSON viewer whose editor options are props. A table object selects tabulator and a chart object selects chartjs; both are provided by the tabulator and chartjs plugins, which the locale must load. table holds Tabulator options, eg. columns, and chart a Chart.js configuration. A missing renderer logs an error.[3]

target is the id of an element, or tabview for the tab bar of the default view. label (defaulting to title or the key) adds the display checkbox; display shows the dataview at once.

Data ​

data is shown as is. Otherwise query names the query template, with queryparams. The layer's queryparams are merged in, and some params resolve when set to true:[4]

ParamValue
tableThe layer table for the current zoom
filterThe layer's current filter
viewportThe map extent; also dataview.viewport
zThe zoom level
id, qIDThe location ID and ID column, for location dataviews
center, geomThe map centre, and the layer geometry column

mapChange reloads the dataview after the map moves, while it and its layer are displayed. reload reloads it whenever it is shown; dynamic recreates it. toolbar adds buttons above the dataview, eg. update, which edits the query in a dialog; the plugins add download_csv and others.

Pitfalls ​

  • A table or chart without its plugin fails to render. Check that the locale loads the plugin.
  • The query template must use ${table}, ${filter} and ${viewport} for the matching params to apply.

Examples ​

Countries with two JSON dataviews: population statistics and a count of the countries in the current filter.

json
{
  "dbs": "DEVDB",
  "locale": {
    "layers": {
      "countries": {
        "display": true,
        "format": "geojson",
        "table": "naturalearth.countries",
        "geom": "geom_4326",
        "srid": "4326",
        "qID": "id",
        "dataviews": {
          "population": {
            "title": "Population",
            "dataview": "Json",
            "query": "field_stats",
            "queryparams": { "table": true, "field": "pop_est" }
          },
          "count": {
            "title": "Countries",
            "dataview": "Json",
            "query": "location_count",
            "queryparams": { "table": true, "filter": true }
          }
        }
      }
    }
  }
}

  1. ui layers/panels/dataviews.mjs ↩︎

  2. ui locations/entries/dataview.mjs ↩︎

  3. ui Dataview.mjs checkDataview ↩︎

  4. mapp utils/queryParams.mjs ↩︎

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