Dataviews
A dataview runs a query template and renders the response. Dataviews are configured in two places:
layer.dataviewsmaps keys to dataviews; the layer view lists them with checkboxes in a drawer.[1]- An infoj entry with
type: dataviewis a dataview for the location; itstargetdefaults 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]
| Param | Value |
|---|---|
table | The layer table for the current zoom |
filter | The layer's current filter |
viewport | The map extent; also dataview.viewport |
z | The zoom level |
id, qID | The location ID and ID column, for location dataviews |
center, geom | The 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.
{
"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 }
}
}
}
}
}
}