-
Notifications
You must be signed in to change notification settings - Fork 592
/
arc_facet.vg.json
131 lines (131 loc) · 3.69 KB
/
arc_facet.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
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"background": "white",
"padding": 5,
"data": [
{
"name": "source_0",
"url": "data/barley.json",
"format": {"type": "json"},
"transform": [
{
"type": "aggregate",
"groupby": ["site", "year"],
"ops": ["sum"],
"fields": ["yield"],
"as": ["sum_yield"]
},
{
"type": "stack",
"groupby": ["year"],
"field": "sum_yield",
"sort": {"field": ["site"], "order": ["ascending"]},
"as": ["sum_yield_start", "sum_yield_end"],
"offset": "zero"
},
{
"type": "filter",
"expr": "isValid(datum[\"sum_yield\"]) && isFinite(+datum[\"sum_yield\"])"
}
]
},
{
"name": "column_domain",
"source": "source_0",
"transform": [{"type": "aggregate", "groupby": ["year"]}]
}
],
"signals": [
{"name": "child_width", "value": 200},
{"name": "child_height", "value": 200}
],
"layout": {
"padding": 20,
"offset": {"columnTitle": 10},
"columns": {"signal": "length(data('column_domain'))"},
"bounds": "full",
"align": "all"
},
"marks": [
{
"name": "column-title",
"type": "group",
"role": "column-title",
"title": {"text": "year", "style": "guide-title", "offset": 10}
},
{
"name": "column_header",
"type": "group",
"role": "column-header",
"from": {"data": "column_domain"},
"sort": {"field": "datum[\"year\"]", "order": "ascending"},
"title": {
"text": {
"signal": "isValid(parent[\"year\"]) ? parent[\"year\"] : \"\"+parent[\"year\"]"
},
"style": "guide-label",
"frame": "group",
"offset": 10
},
"encode": {"update": {"width": {"signal": "child_width"}}}
},
{
"name": "cell",
"type": "group",
"style": "view",
"from": {
"facet": {"name": "facet", "data": "source_0", "groupby": ["year"]}
},
"sort": {"field": ["datum[\"year\"]"], "order": ["ascending"]},
"encode": {
"update": {
"width": {"signal": "child_width"},
"height": {"signal": "child_height"}
}
},
"marks": [
{
"name": "child_marks",
"type": "arc",
"style": ["arc"],
"from": {"data": "facet"},
"encode": {
"update": {
"fill": {"scale": "color", "field": "site"},
"description": {
"signal": "\"Sum of yield: \" + (format(datum[\"sum_yield\"], \"\")) + \"; site: \" + (isValid(datum[\"site\"]) ? datum[\"site\"] : \"\"+datum[\"site\"])"
},
"x": {"signal": "child_width", "mult": 0.5},
"y": {"signal": "child_height", "mult": 0.5},
"outerRadius": {"signal": "min(child_width,child_height)/2"},
"innerRadius": {"value": 0},
"startAngle": {"scale": "child_theta", "field": "sum_yield_end"},
"endAngle": {"scale": "child_theta", "field": "sum_yield_start"}
}
}
}
],
"scales": [
{
"name": "child_theta",
"type": "linear",
"domain": {
"data": "facet",
"fields": ["sum_yield_start", "sum_yield_end"]
},
"range": [0, 6.283185307179586],
"zero": true
}
]
}
],
"scales": [
{
"name": "color",
"type": "ordinal",
"domain": {"data": "source_0", "field": "site", "sort": true},
"range": "category"
}
],
"legends": [{"fill": "color", "symbolType": "circle", "title": "site"}]
}