Places Chart 3D
Dots on the land of a globe, one per place, sized by value.
The places chart puts a dot on the globe for every entry, at its lon and
lat, in the color of its series. With a value, the area of a dot is its
share of the largest value, so a place of four times the people gets a dot of
twice the radius; without one, every dot is as large as radius. A dot on the
far side is hidden by the globe. id names an entry: the name is the title of
its tooltip and its identity through updates, so a dot follows its name when
the data changes. Without id, the tooltip shows the series and the place.
The demos show the populated places of
Natural Earth,
public domain, with the people of their metro areas, a capital in its own
color. The land under the dots is the one every globe takes, cut at the
horizon by d3-geo; see the globe for where
it comes from and how its regions must be wound. The dots are few, so the
demos start on "svg", and the many demo on "canvas".
Installation
npx shadcn@latest add niekes/chart3dcn/places-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)}>
<PlacesChart3D data={places} 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 dot glides from the people of its metro area to the
people of its city proper, and back, over the animationDuration of its
container. The largest value glides along, so no dot jumps.
Enter and leave
New data may also bring and drop places. A place that arrives grows out of the globe from nothing as it fades in; one that goes shrinks back and fades out, the mirror of its entering (see Enter in the glossary). Here the bar moves from the megacities down to every place.
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
Every place of Natural Earth, seven thousand dots over the land, the smallest
a speck - and the chart stays interactive. 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