-
Notifications
You must be signed in to change notification settings - Fork 591
/
geo_trellis.vg.json
142 lines (142 loc) · 3.53 KB
/
geo_trellis.vg.json
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"background": "white",
"padding": 5,
"data": [
{
"name": "source_1",
"url": "data/us-10m.json",
"format": {"type": "topojson", "feature": "states"}
},
{
"name": "source_0",
"url": "data/income.json",
"format": {"type": "json"},
"transform": [
{
"type": "lookup",
"from": "source_1",
"key": "id",
"fields": ["id"],
"as": ["geo"]
},
{"type": "filter", "expr": "isValid(datum[\"geo\"])"},
{"type": "geojson", "geojson": "geo", "signal": "child_geojson_0"},
{
"type": "filter",
"expr": "isValid(datum[\"pct\"]) && isFinite(+datum[\"pct\"])"
}
]
},
{
"name": "row_domain",
"source": "source_0",
"transform": [{"type": "aggregate", "groupby": ["group"]}]
}
],
"projections": [
{
"name": "projection",
"size": {"signal": "[child_width, child_height]"},
"fit": {"signal": "child_geojson_0"},
"type": "albersUsa"
}
],
"signals": [
{"name": "child_width", "value": 500},
{"name": "child_height", "value": 300}
],
"layout": {
"padding": 20,
"offset": {"rowTitle": 10},
"columns": 1,
"bounds": "full",
"align": "all"
},
"marks": [
{
"name": "row-title",
"type": "group",
"role": "row-title",
"title": {
"text": "group",
"orient": "left",
"style": "guide-title",
"offset": 10
}
},
{
"name": "row_header",
"type": "group",
"role": "row-header",
"from": {"data": "row_domain"},
"sort": {"field": "datum[\"group\"]", "order": "ascending"},
"title": {
"text": {
"signal": "isValid(parent[\"group\"]) ? parent[\"group\"] : \"\"+parent[\"group\"]"
},
"orient": "left",
"style": "guide-label",
"frame": "group",
"offset": 10
},
"encode": {"update": {"height": {"signal": "child_height"}}}
},
{
"name": "cell",
"type": "group",
"style": "view",
"from": {
"facet": {"name": "facet", "data": "source_0", "groupby": ["group"]}
},
"sort": {"field": ["datum[\"group\"]"], "order": ["ascending"]},
"encode": {
"update": {
"width": {"signal": "child_width"},
"height": {"signal": "child_height"}
}
},
"marks": [
{
"name": "child_marks",
"type": "shape",
"style": ["geoshape"],
"from": {"data": "facet"},
"encode": {
"update": {
"fill": {"scale": "color", "field": "pct"},
"ariaRoleDescription": {"value": "geoshape"},
"description": {
"signal": "\"pct: \" + (format(datum[\"pct\"], \"\")) + \"; geo: \" + (isValid(datum[\"geo\"]) ? datum[\"geo\"] : \"\"+datum[\"geo\"])"
}
}
},
"transform": [
{
"type": "geoshape",
"projection": "projection",
"field": "datum[\"geo\"]"
}
]
}
]
}
],
"scales": [
{
"name": "color",
"type": "linear",
"domain": {"data": "source_0", "field": "pct"},
"range": "heatmap",
"interpolate": "hcl",
"zero": false
}
],
"legends": [
{
"fill": "color",
"gradientLength": {"signal": "clamp(child_height, 64, 200)"},
"title": "pct"
}
]
}