Globe Chart 3D
A globe of tiles on the land, each rising to its value.
The globe is a grid of tiles between meridians and parallels, step degrees
wide, on the land. An entry names a place, in the lon and lat fields, and
the tile that holds it rises to the entry's value, in the color of its
series; a tile without an entry is not drawn. Aggregation happens before
the chart: round a list of places to the grid, or hand the chart a grid it
already has, one entry per tile - where two entries fall on one tile, the
last one wins. The tile is the identity of a mark: an entry that moves to
another tile leaves there and enters here, and a tile that changes its series
leaves as one and enters as the other. label names a field whose value, of
the last entry on a tile, titles its tooltip. For regions colored by a value
see the choropleth, for a dot at
every place the places chart: the three
share the land.
The demos show the populated places of the world, the 7,332 cities and towns
of Natural Earth
with the people of their metro areas, summed on tiles of 2°: a tile rises to
the people on it, and its color is their class, nine steps of the square root
up to 10 million in YlOrRd, as the
world population of globe.gl
colors its hexagons; the legend of the container lists the classes. Most
tiles are flat sparks, a few dozen are towers. The classes and the sums live
in docs/examples/population.ts, not in the chart: the chart takes a
series per tile and a config entry per class, as any chart does. Thousands
of tiles are too many for SVG while the camera turns, so every demo starts on
"canvas".
The land is a GeoJSON feature collection, the regions of the earth: d3-geo
cuts them at the horizon and lays them on the ocean disc, flat in the colors
of the walls - or in --chart-3d-ocean and --chart-3d-land where you set
them, as these docs do for a globe at night in the dark theme, see
Theming - and they turn, pan and zoom with
the tiles. The land is scenery: it never enters, glides or answers the
pointer. The demos take the land of
world-atlas at 110m, its
countries, converted from TopoJSON with
topojson-client,
as docs/examples/land.ts shows; the chart takes GeoJSON alone. Mind the
winding: d3-geo reads a region wound clockwise, the opposite of RFC 7946, and
a region wound the other way fills the globe around it - topojson-client
winds them right, a GeoJSON file from elsewhere may not. The globe is
orthographic, as d3-geo projects it, so it ignores the perspective of the
camera.
Installation
npx shadcn@latest add niekes/chart3dcn/globe-chart-3d#v1.2.0Start at a place
The globe starts at the default view of the container, which looks at the
Atlantic, at 30° west and 30° north. Hand the container
defaultView={facing(lon, lat)}, in degrees, and the camera starts over
that place - here Germany - and a reset returns it there. facing is an
export of chart-3d:
<ChartContainer3D config={chartConfig} defaultView={facing(10, 51)}>
<GlobeChart3D data={tiles} land={land} lon="lon" lat="lat" value="metro" />
</ChartContainer3D>To turn the globe to a place later, as a tour does, give it a heading with
view, see chart-3d.
Update
Press the button: every tile glides from the people of its metro areas to
the people of its cities proper, and back, over the animationDuration of
its container, and the ceiling - the height of the tallest tile - glides
along, so no tile jumps. The class of a tile stays that of its metro areas,
so every tile glides and none leaves.
Enter and leave
New data may also bring and drop tiles. A quake that arrives grows out of the globe and fades in; one that goes shrinks back into it and fades out, the mirror of its entering (see Enter in the glossary). Here the world arrives place by place: lowering the bar from the megacities to every place, the smaller places enter and light up; raising it, they sink back. A tile that was there already grows as a place joins it, and leaves as one class to enter as another where the newcomers lift it over a bound.
Renderers
The same chart on every renderer, side by side. The marks are data the chart hands to the container, and "svg" and "canvas" draw them all - where the browser has no canvas, as SVG.
Many marks
Tiles of 1°, nearly every place its own spark, five thousand tiles over the
land - and the chart stays interactive. A tile thinner than a pixel draws its
top alone, so the globe projects a face per flat tile, not five. The scene is
one list of marks, so the demo starts on "canvas", the renderer for many
marks, and the select shows the same scene on SVG.
API Reference
Prop
Type