@@ -7,13 +7,17 @@ import {computed, shallowRef, onMounted} from "vue";
7
7
8
8
const us = shallowRef (null );
9
9
const earthquakes = shallowRef ([]);
10
+ const walmarts = shallowRef ({type: " FeatureCollection" , features: []});
10
11
const world = shallowRef (null );
12
+ const statemesh = computed (() => us .value ? topojson .mesh (us .value , us .value .objects .states , (a , b ) => a !== b) : {type: null });
13
+ const nation = computed (() => us .value ? topojson .feature (us .value , us .value .objects .nation ) : {type: null });
11
14
const counties = computed (() => us .value ? topojson .feature (us .value , us .value .objects .counties ).features : []);
12
15
const land = computed (() => world .value ? topojson .feature (world .value , world .value .objects .land ) : {type: null });
13
16
14
17
onMounted (() => {
15
18
d3 .json (" https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.geojson" ).then ((data ) => (earthquakes .value = data));
16
19
d3 .json (" ../data/countries-110m.json" ).then ((data ) => (world .value = data));
20
+ d3 .tsv (" ../data/walmarts.tsv" , d3 .autoType ).then ((data ) => (walmarts .value = {type: " FeatureCollection" , features: data .map ((d ) => ({type: " Feature" , properties: {date: d .date }, geometry: {type: " Point" , coordinates: [d .longitude , d .latitude ]}}))}));
17
21
Promise .all ([
18
22
d3 .json (" ../data/us-counties-10m.json" ),
19
23
d3 .csv (" ../data/us-county-unemployment.csv" )
@@ -60,11 +64,12 @@ The size of Point and MultiPoint geometries is controlled by the **r** option. F
60
64
Plot .plot ({
61
65
projection: " equirectangular" ,
62
66
style: " overflow: visible;" ,
67
+ r: {transform : (r ) => Math .pow (10 , r)}, // Richter to amplitude
63
68
marks: [
64
69
Plot .geo (land, {fill: " currentColor" , fillOpacity: 0.2 }),
65
70
Plot .sphere (),
66
71
Plot .geo (earthquakes, {
67
- r : (d ) => Math . pow ( 10 , d .properties .mag ) ,
72
+ r : (d ) => d .properties .mag ,
68
73
fill: " red" ,
69
74
fillOpacity: 0.2 ,
70
75
stroke: " red" ,
@@ -124,6 +129,29 @@ Plot.plot({
124
129
```
125
130
:::
126
131
132
+ The geo mark supports [ faceting] ( ./facets.md ) . Below, a comic strip of sorts shows the locations of Walmart store openings in past decades.
133
+
134
+ :::plot defer https://observablehq.com/@observablehq/plot-map-large-multiples
135
+ ``` js
136
+ Plot .plot ({
137
+ margin: 0 ,
138
+ padding: 0 ,
139
+ projection: " albers" ,
140
+ fy: {interval: d3 .utcYear .every (10 )},
141
+ marks: [
142
+ Plot .geo (statemesh, {strokeOpacity: 0.2 }),
143
+ Plot .geo (nation),
144
+ Plot .geo (walmarts, {fy : (d ) => d .properties .date , r: 1.5 , fill: " blue" }),
145
+ Plot .axisFy ({frameAnchor: " top" , dy: 30 , tickFormat : (d ) => ` ${ d .getUTCFullYear ()} ’s` })
146
+ ]
147
+ })
148
+ ```
149
+ :::
150
+
151
+ ::: info
152
+ This uses the [ ** interval** scale option] ( ../transforms/interval.md ) to bin temporal data into facets by decade.
153
+ :::
154
+
127
155
Lastly, the geo mark is not limited to spherical geometries! [ Plot’s projection system] ( ../features/projections.md ) includes planar projections, which allow you to work with shapes—such as contours—generated on an arbitrary flat surface.
128
156
129
157
## Geo options
0 commit comments