1 |
e2996682
|
Štěpán Červenka
|
{
|
2 |
|
|
"$schema": "https://vega.github.io/schema/vega/v5.json",
|
3 |
|
|
"width": 1200,
|
4 |
|
|
"height": 200,
|
5 |
|
|
"padding": 5,
|
6 |
|
|
|
7 |
|
|
"signals": [
|
8 |
|
|
{
|
9 |
|
|
"name": "length",
|
10 |
a7285540
|
hlavja
|
"value": ["year","month", "date"],
|
11 |
e2996682
|
Štěpán Červenka
|
"bind": {
|
12 |
|
|
"input": "select",
|
13 |
|
|
"options": [
|
14 |
|
|
["year"],
|
15 |
|
|
["year","month"],
|
16 |
|
|
["year","week"],
|
17 |
|
|
["year","month", "date"]
|
18 |
|
|
],
|
19 |
|
|
"labels": [
|
20 |
|
|
"year",
|
21 |
|
|
"month",
|
22 |
|
|
"week",
|
23 |
|
|
"day"
|
24 |
|
|
]
|
25 |
|
|
}
|
26 |
|
|
},
|
27 |
|
|
{
|
28 |
|
|
"name": "operation",
|
29 |
|
|
"value": "average",
|
30 |
|
|
"bind": {
|
31 |
|
|
"input": "select",
|
32 |
|
|
"options": [
|
33 |
|
|
"average",
|
34 |
|
|
"count",
|
35 |
|
|
"sum",
|
36 |
|
|
"median",
|
37 |
|
|
"min",
|
38 |
|
|
"max"
|
39 |
|
|
]
|
40 |
|
|
}
|
41 |
|
|
}
|
42 |
|
|
],
|
43 |
|
|
|
44 |
|
|
"data": [
|
45 |
|
|
{
|
46 |
|
|
"name": "table",
|
47 |
|
|
"values" : null,
|
48 |
|
|
"transform": [
|
49 |
|
|
{
|
50 |
|
|
"type": "formula",
|
51 |
a7285540
|
hlavja
|
"expr": "toDate(datum[\"timestamp\"])",
|
52 |
e2996682
|
Štěpán Červenka
|
"as": "dateTime"
|
53 |
|
|
},
|
54 |
|
|
{
|
55 |
|
|
"type": "timeunit",
|
56 |
|
|
"field": "dateTime",
|
57 |
|
|
"units": {"signal": "length"}
|
58 |
|
|
},
|
59 |
|
|
{
|
60 |
|
|
"type": "aggregate",
|
61 |
a7285540
|
hlavja
|
"fields": ["max"],
|
62 |
e2996682
|
Štěpán Červenka
|
"ops": [{"signal" : "operation"}],
|
63 |
|
|
"groupby": ["unit0"],
|
64 |
|
|
"as": ["avg"]
|
65 |
|
|
},
|
66 |
|
|
{
|
67 |
|
|
"type": "timeunit",
|
68 |
|
|
"field": "unit0",
|
69 |
|
|
"units": {"signal": "length"}
|
70 |
|
|
}
|
71 |
|
|
]
|
72 |
|
|
},
|
73 |
|
|
{
|
74 |
|
|
"name": "table2",
|
75 |
|
|
"source": "table",
|
76 |
|
|
"transform":[
|
77 |
|
|
{
|
78 |
|
|
"type": "lookup",
|
79 |
|
|
"from": "table",
|
80 |
|
|
"key": "unit0",
|
81 |
|
|
"fields": ["unit1"],
|
82 |
|
|
"as": ["obj"]
|
83 |
|
|
}
|
84 |
|
|
]
|
85 |
|
|
}
|
86 |
|
|
],
|
87 |
|
|
|
88 |
|
|
"scales": [
|
89 |
|
|
{
|
90 |
|
|
"name": "xscale",
|
91 |
|
|
"type": "time",
|
92 |
|
|
"domain": {"data": "table", "fields": ["unit0", "unit1"]},
|
93 |
|
|
"range": "width"
|
94 |
|
|
},
|
95 |
|
|
{
|
96 |
|
|
"name": "yscale",
|
97 |
|
|
"type": "linear",
|
98 |
|
|
"domain": {"data": "table", "field": "avg"},
|
99 |
|
|
"nice": true,
|
100 |
|
|
"range": "height"
|
101 |
|
|
}
|
102 |
|
|
],
|
103 |
|
|
|
104 |
|
|
"axes": [
|
105 |
|
|
{ "orient": "bottom", "scale": "xscale", "tickCount": 6 },
|
106 |
|
|
{ "orient": "left", "scale": "yscale" }
|
107 |
|
|
],
|
108 |
|
|
|
109 |
|
|
"marks": [
|
110 |
|
|
{
|
111 |
|
|
"type": "symbol",
|
112 |
|
|
"from": {"data":"table"},
|
113 |
|
|
"encode": {
|
114 |
|
|
"update": {
|
115 |
|
|
"shape": {"value": "circle"},
|
116 |
|
|
"size": {"value": 20},
|
117 |
|
|
"x": {"scale": "xscale", "field": "unit0"},
|
118 |
|
|
"y": {"scale": "yscale", "field": "avg"},
|
119 |
|
|
"color": {"value": "both"},
|
120 |
|
|
"strokeWidth": {"value": 1}
|
121 |
|
|
}
|
122 |
|
|
}
|
123 |
|
|
},
|
124 |
|
|
{
|
125 |
|
|
"type": "rule",
|
126 |
|
|
"from": {"data":"table2"},
|
127 |
|
|
"encode": {
|
128 |
|
|
"enter": {
|
129 |
|
|
"x": {"scale": "xscale", "field": "unit0"},
|
130 |
|
|
"x2":[
|
131 |
|
|
{
|
132 |
|
|
"test": "isValid(datum.obj)",
|
133 |
|
|
"scale" : "xscale",
|
134 |
|
|
"field" : "obj.unit0"
|
135 |
|
|
},
|
136 |
|
|
{
|
137 |
|
|
"scale" : "xscale",
|
138 |
|
|
"field" : "unit0"
|
139 |
|
|
}
|
140 |
|
|
],
|
141 |
|
|
"y": {"scale": "yscale", "field": "avg"},
|
142 |
|
|
"y2":[
|
143 |
|
|
{
|
144 |
|
|
"test": "isValid(datum.obj)",
|
145 |
|
|
"scale" : "yscale",
|
146 |
|
|
"field" : "obj.avg"
|
147 |
|
|
},
|
148 |
|
|
{
|
149 |
|
|
"scale" : "yscale",
|
150 |
|
|
"field" : "avg"
|
151 |
|
|
}
|
152 |
|
|
]
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
},
|
157 |
|
|
"update": {
|
158 |
|
|
"stroke": {"value": "steelblue"},
|
159 |
|
|
"strokeWidth": {"value": 1}
|
160 |
|
|
},
|
161 |
|
|
"hover": {
|
162 |
|
|
"stroke": {"value": "red"},
|
163 |
|
|
"strokeWidth": {"value": 3}
|
164 |
|
|
}
|
165 |
|
|
}
|
166 |
|
|
}
|
167 |
|
|
]
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
}
|