Orthographic Pie Chart
A pie chart rendered as geographic features is projected onto an orthographic globe using D3 v4. The example converts SVG arc paths into GeoJSON via a custom module that samples path coordinates and translates them into geographic coordinates. The globe and pie chart rotate together in an animation.
AI-generated descriptionThis bl.ock follows in the footsteps of this block with orthographic labels.
It uses a quick demo of a module that takes a path or selection with paths, overlays it on a projection, converts the path's coordinates to geographic coordinates and then into geojson.
It uses a few methods:
geoCentroid([longitude,latitude])
The geographic centroid to apply to the non-geographic path. Aligns with 0,0 in the non-geographic coordinate space.
geoScale(value)
Sets the scale of the geographic projection which the non-geographic path is overlain ontop of before getting the geographic coordinates. Lower values result in larger features.
pathScale(value)
Sets the scaling value of the non-geographic path. Smaller values result in smaller features.
selection(selection)
Takes a d3 selection, extracts their paths and creates geojson from the paths.
path(path)
Takes a path and creates geojson from the path.
features()
Returns features generated from the selection/path
featureCollection()
Returns a featureCollection generated from the selection/path