-
Notifications
You must be signed in to change notification settings - Fork 590
/
arc_ordinal_theta.vg.json
92 lines (92 loc) · 2.48 KB
/
arc_ordinal_theta.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
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"background": "white",
"padding": 5,
"width": 200,
"height": 200,
"style": "cell",
"data": [
{
"name": "source_0",
"values": [
{"dir": "1N", "strength": 1},
{"dir": "2NE", "strength": 2},
{"dir": "3E", "strength": 3},
{"dir": "4SE", "strength": 4},
{"dir": "5S", "strength": 5},
{"dir": "6SW", "strength": 6},
{"dir": "7W", "strength": 7},
{"dir": "8NW", "strength": 8}
]
},
{
"name": "data_0",
"source": "source_0",
"transform": [
{
"type": "stack",
"groupby": ["dir"],
"field": "strength",
"sort": {"field": [], "order": []},
"as": ["strength_start", "strength_end"],
"offset": "zero"
},
{
"type": "filter",
"expr": "isValid(datum[\"strength\"]) && isFinite(+datum[\"strength\"])"
}
]
}
],
"marks": [
{
"name": "marks",
"type": "arc",
"style": ["arc"],
"from": {"data": "data_0"},
"encode": {
"update": {
"fill": {"scale": "color", "field": "dir"},
"description": {
"signal": "\"dir: \" + (isValid(datum[\"dir\"]) ? datum[\"dir\"] : \"\"+datum[\"dir\"]) + \"; strength: \" + (format(datum[\"strength\"], \"\"))"
},
"x": {"signal": "width", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5},
"outerRadius": {"scale": "radius", "field": "strength_end"},
"innerRadius": {"scale": "radius", "field": "strength_start"},
"startAngle": {"scale": "theta", "field": "dir"},
"endAngle": {
"scale": "theta",
"field": "dir",
"offset": {"scale": "theta", "band": 1}
}
}
}
}
],
"scales": [
{
"name": "theta",
"type": "band",
"domain": {"data": "data_0", "field": "dir", "sort": true},
"range": [0, 6.283185307179586]
},
{
"name": "radius",
"type": "linear",
"domain": {
"data": "data_0",
"fields": ["strength_start", "strength_end"]
},
"range": [0, {"signal": "min(width,height)/2"}],
"zero": true
},
{
"name": "color",
"type": "ordinal",
"domain": {"data": "data_0", "field": "dir", "sort": true},
"range": "category"
}
],
"legends": [{"fill": "color", "symbolType": "circle", "title": "dir"}]
}