Skip to content

Commit 99dcd9a

Browse files
committed
inline interactive tip example
1 parent a7c6aba commit 99dcd9a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

docs/marks/geo.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const walmarts = shallowRef({type: "FeatureCollection", features: []});
1111
const world = shallowRef(null);
1212
const statemesh = computed(() => us.value ? topojson.mesh(us.value, us.value.objects.states, (a, b) => a !== b) : {type: null});
1313
const nation = computed(() => us.value ? topojson.feature(us.value, us.value.objects.nation) : {type: null});
14+
const states = computed(() => us.value ? topojson.feature(us.value, us.value.objects.states).features : []);
1415
const counties = computed(() => us.value ? topojson.feature(us.value, us.value.objects.counties).features : []);
1516
const land = computed(() => world.value ? topojson.feature(world.value, world.value.objects.land) : {type: null});
1617

@@ -128,7 +129,21 @@ Plot.plot({
128129
```
129130
:::
130131

131-
The geo mark doesn’t have **x** and **y** channels; to derive those, for example to add [interactive tips](https://observablehq.com/@observablehq/plot-maps-tips), you can apply a [centroid transform](../transforms/centroid.md) on the geometries.
132+
The geo mark doesn’t have **x** and **y** channels; to derive those, for example to add [interactive tips](./tip.md), you can apply a [centroid transform](../transforms/centroid.md) on the geometries.
133+
134+
:::plot defer https://observablehq.com/@observablehq/plot-state-centroids
135+
```js
136+
Plot.plot({
137+
projection: "albers-usa",
138+
marks: [
139+
Plot.geo(statemesh, {strokeOpacity: 0.2}),
140+
Plot.geo(nation),
141+
Plot.dot(states, Plot.centroid({fill: "red", stroke: "var(--vp-c-bg-alt)"})),
142+
Plot.tip(states, Plot.pointer(Plot.centroid({title: (d) => d.properties.name})))
143+
]
144+
})
145+
```
146+
:::
132147

133148
The geo mark supports [faceting](../features/facets.md). Below, a comic strip of sorts shows the locations of Walmart store openings in past decades.
134149

0 commit comments

Comments
 (0)