Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{
"$schema": "https://vega.github.io/schema/vega/v3.0.json",
"config":{"background":"#ffffff"},
"width": 800,
"height": 480,
"autosize": "none",
"projections": [
{
"name": "projection",
"type": "albersUsa",
"scale": 900,
"translate": [{"signal": "width / 2"},{"signal": "height / 2"}]
}
],
"data": [
{
"name": "states",
"url": "data/us-10m.json",
"format": {"type": "topojson","feature": "states"},
"transform": [{"type": "geopath","projection": "projection"}]
},
{
"name": "zipcodes",
"url": "data/zip_codes_states.csv",
"format": {
"type": "csv",
"parse": {
"longitude": "number",
"latitude": "number",
"zip_code": "string"
}
},
"transform": [
{
"type": "formula",
"expr": "substring(datum.zip_code, 0, 1)",
"as": "digit"
},
{
"type": "geopoint",
"projection": "projection",
"fields": ["longitude","latitude"]
}
]
}
],
"scales": [
{
"name": "color",
"type": "ordinal",
"domain": {"data": "zipcodes","field": "digit", "sort": true},
"range": "category"
}
],
"legends": [{"fill": "color", "orient": "top-right"}],
"marks": [
{
"type": "path",
"from": {"data": "states"},
"encode": {
"enter": {
"strokeWidth": {"value": "1"},
"stroke": {"value": "#fff"},
"fill": {"value": "#ddd"},
"path": {"field": "path"}
}
}
},
{
"type": "symbol",
"interactive": false,
"from": {"data": "zipcodes"},
"encode": {
"enter": {
"size": {"value": 2},
"shape": {"value": "circle"},
"fill": {"scale": "color","field": "digit"}
},
"update": {"x": {"field": "x"},"y": {"field": "y"}}
}
}
]
}