The plugin currently supports US maps and state names. The model and data styles for the subsequent examples are:
source: airports is duckdb.table('../data/airports.parquet') { primary_key: code measure: airport_count is count() view: by_state is { group_by: state aggregate: airport_count } # shape_map view: by_state_shaped is by_state }
Run a query and tag the reusults as a shape map
We can explicitly return a result as a shape map.
# shape_map run: airports -> by_state
[ { "state": "TX", "airport_count": 1845 }, { "state": "CA", "airport_count": 984 }, { "state": "IL", "airport_count": 890 }, { "state": "FL", "airport_count": 856 }, { "state": "PA", "airport_count": 804 } ]
SELECT airports."state" as "state", COUNT( 1) as "airport_count" FROM '../data/airports.parquet' as airports GROUP BY 1 ORDER BY 2 desc NULLS LAST
The tag is in the semantic model
In the query below the tag is in the semantic model.
run: airports -> by_state_shaped {where: fac_type='SEAPLANE BASE'}
[ { "state": "AK", "airport_count": 104 }, { "state": "MN", "airport_count": 72 }, { "state": "FL", "airport_count": 43 }, { "state": "ME", "airport_count": 38 }, { "state": "NY", "airport_count": 23 } ]
SELECT airports."state" as "state", COUNT( 1) as "airport_count" FROM '../data/airports.parquet' as airports WHERE airports."fac_type"='SEAPLANE BASE' GROUP BY 1 ORDER BY 2 desc NULLS LAST
Run as a trellis
By calling the configured map as a nested subtable, a trellis is formed.