observablehq / plot

A concise API for exploratory data visualization implementing a layered grammar of graphics
https://observablehq.com/plot/
ISC License
4.16k stars 171 forks source link

more GeoJSON awareness #2092

Closed mbostock closed 1 month ago

mbostock commented 1 month ago

Fixes #1745. Fixes #1172.

First, this changes the arrayify internal such that if values is a GeoJSON object, the corresponding array of features or geometries is returned. This makes GeoJSON objects usable as mark data for any mark, rather than being limited to the geo mark.

Second, this changes the field internal such that if the requested field is undefined on the given object d, it falls back to d.properties if d is a GeoJSON Feature object (d.type === "Feature"). This may have a slight performance overhead for such a core routine, but I expect the cost is negligible and I don’t think there is an alternative if we want GeoJSON to be more universally supported.