1
|
{
|
2
|
"$schema": "https://vega.github.io/schema/vega/v5.json",
|
3
|
"width": 800,
|
4
|
"height": 200,
|
5
|
"padding": 5,
|
6
|
|
7
|
"data": [
|
8
|
{
|
9
|
"name": "table",
|
10
|
"values": null,
|
11
|
"transform": [
|
12
|
{
|
13
|
"type": "formula",
|
14
|
"expr": "toDate(datum[\"timestamp\"])",
|
15
|
"as": "dateTime"
|
16
|
},
|
17
|
{
|
18
|
"type": "timeunit",
|
19
|
"field": "dateTime",
|
20
|
"units": ["year","month", "date", "hours", "minutes", "seconds"],
|
21
|
"step": {"signal": "timeStep"}
|
22
|
}
|
23
|
]
|
24
|
},
|
25
|
{
|
26
|
"name": "table2",
|
27
|
"source": "table",
|
28
|
"transform":[
|
29
|
{
|
30
|
"type": "lookup",
|
31
|
"from": "table",
|
32
|
"key": "unit0",
|
33
|
"fields": ["unit1"],
|
34
|
"as": ["obj"]
|
35
|
}
|
36
|
|
37
|
]
|
38
|
},
|
39
|
{
|
40
|
"name": "table3",
|
41
|
"source": "table",
|
42
|
"transform": [
|
43
|
{
|
44
|
"type": "aggregate",
|
45
|
"fields": ["dateTime", "dateTime"],
|
46
|
"ops": ["min", "max"],
|
47
|
"as": ["dateMinTemp", "dateMaxTemp"]
|
48
|
},
|
49
|
{
|
50
|
"type": "formula",
|
51
|
"expr":"time(datum[\"dateMinTemp\"] - (timeStep * 500))",
|
52
|
"as": "dateMin"
|
53
|
},
|
54
|
{
|
55
|
"type": "formula",
|
56
|
"expr":"time(datum[\"dateMaxTemp\"] + (timeStep * 500))",
|
57
|
"as": "dateMax"
|
58
|
}
|
59
|
]
|
60
|
}
|
61
|
],
|
62
|
|
63
|
"signals": [
|
64
|
{
|
65
|
"name": "timeStep",
|
66
|
"value": null
|
67
|
},
|
68
|
{
|
69
|
"name": "detailDomain"
|
70
|
}
|
71
|
|
72
|
],
|
73
|
|
74
|
"marks": [
|
75
|
{
|
76
|
"type": "group",
|
77
|
"name": "detail",
|
78
|
"encode": {
|
79
|
"enter": {
|
80
|
"height": {"value": 390},
|
81
|
"width": {"value": 800}
|
82
|
}
|
83
|
},
|
84
|
"scales": [
|
85
|
{
|
86
|
"name": "xDetail",
|
87
|
"type": "time",
|
88
|
"range": "width",
|
89
|
"domain": {"data": "table3", "fields": ["dateMin", "dateMax"]},
|
90
|
"domainRaw": {"signal": "detailDomain"}
|
91
|
},
|
92
|
{
|
93
|
"name": "yDetail",
|
94
|
"type": "linear",
|
95
|
"range": [390, 0],
|
96
|
"domain": {"data": "table", "field": "avg"},
|
97
|
"nice": true, "zero": true
|
98
|
}
|
99
|
],
|
100
|
"axes": [
|
101
|
{"orient": "bottom", "scale": "xDetail"},
|
102
|
{"orient": "left", "scale": "yDetail"}
|
103
|
],
|
104
|
"marks": [
|
105
|
{
|
106
|
"type": "group",
|
107
|
"encode": {
|
108
|
"enter": {
|
109
|
"height": {"field": {"group": "height"}},
|
110
|
"width": {"field": {"group": "width"}},
|
111
|
"clip": {"value": true}
|
112
|
}
|
113
|
},
|
114
|
"marks": [
|
115
|
{
|
116
|
"type": "symbol",
|
117
|
"from": {"data":"table"},
|
118
|
"encode": {
|
119
|
"enter": {
|
120
|
"tooltip": {
|
121
|
"signal": "{title: timeFormat(datum.dateTime, '%A, %e. %B %Y, %X') , 'avg': datum.avg, 'sum': datum.sum, 'max': datum.max, 'min': datum.min }"
|
122
|
}},
|
123
|
"update": {
|
124
|
"shape": {"value": "circle"},
|
125
|
"size": {"value": 30},
|
126
|
"x": {"scale": "xDetail", "field": "dateTime"},
|
127
|
"y": {"scale": "yDetail", "field": "avg"},
|
128
|
"color": {"value": "both"},
|
129
|
"strokeWidth": {"value": 4},
|
130
|
"fill": {"value": "steelblue"}
|
131
|
},
|
132
|
"hover": {
|
133
|
"fill": {"value": "red"},
|
134
|
"size": {"value": 60}
|
135
|
}
|
136
|
}
|
137
|
},
|
138
|
{
|
139
|
"type": "rule",
|
140
|
"from": {
|
141
|
"data": "table2"
|
142
|
},
|
143
|
"encode": {
|
144
|
"update": {
|
145
|
"x": {
|
146
|
"scale": "xDetail",
|
147
|
"field": "unit0"
|
148
|
},
|
149
|
"x2": [
|
150
|
{
|
151
|
"test": "isValid(datum.obj)",
|
152
|
"scale": "xDetail",
|
153
|
"field": "obj.unit0"
|
154
|
},
|
155
|
{
|
156
|
"scale": "xDetail",
|
157
|
"field": "unit0"
|
158
|
}
|
159
|
],
|
160
|
"y": {
|
161
|
"scale": "yDetail",
|
162
|
"field": "avg"
|
163
|
},
|
164
|
"y2": [
|
165
|
{
|
166
|
"test": "isValid(datum.obj)",
|
167
|
"scale": "yDetail",
|
168
|
"field": "obj.avg"
|
169
|
},
|
170
|
{
|
171
|
"scale": "yDetail",
|
172
|
"field": "avg"
|
173
|
}
|
174
|
],
|
175
|
"stroke": {
|
176
|
"value": "steelblue"
|
177
|
},
|
178
|
"strokeWidth": {
|
179
|
"value": 1
|
180
|
}
|
181
|
}
|
182
|
}
|
183
|
}
|
184
|
|
185
|
|
186
|
]
|
187
|
}
|
188
|
]
|
189
|
},
|
190
|
|
191
|
{
|
192
|
"type": "group",
|
193
|
"name": "overview",
|
194
|
"encode": {
|
195
|
"enter": {
|
196
|
"x": {"value": 0},
|
197
|
"y": {"value": 430},
|
198
|
"height": {"value": 70},
|
199
|
"width": {"value": 720},
|
200
|
"fill": {"value": "transparent"}
|
201
|
}
|
202
|
},
|
203
|
"signals": [
|
204
|
{
|
205
|
"name": "brush", "value": 0,
|
206
|
"on": [
|
207
|
{
|
208
|
"events": "@overview:mousedown",
|
209
|
"update": "[x(), x()]"
|
210
|
},
|
211
|
{
|
212
|
"events": "[@overview:mousedown, window:mouseup] > window:mousemove!",
|
213
|
"update": "[brush[0], clamp(x(), 0, width)]"
|
214
|
},
|
215
|
{
|
216
|
"events": {"signal": "delta"},
|
217
|
"update": "clampRange([anchor[0] + delta, anchor[1] + delta], 0, width)"
|
218
|
}
|
219
|
]
|
220
|
},
|
221
|
{
|
222
|
"name": "anchor", "value": null,
|
223
|
"on": [{"events": "@brush:mousedown", "update": "slice(brush)"}]
|
224
|
},
|
225
|
{
|
226
|
"name": "xdown", "value": 0,
|
227
|
"on": [{"events": "@brush:mousedown", "update": "x()"}]
|
228
|
},
|
229
|
{
|
230
|
"name": "delta", "value": 0,
|
231
|
"on": [
|
232
|
{
|
233
|
"events": "[@brush:mousedown, window:mouseup] > window:mousemove!",
|
234
|
"update": "x() - xdown"
|
235
|
}
|
236
|
]
|
237
|
},
|
238
|
{
|
239
|
"name": "detailDomain",
|
240
|
"push": "outer",
|
241
|
"on": [
|
242
|
{
|
243
|
"events": {"signal": "brush"},
|
244
|
"update": "span(brush) ? invert('xOverview', brush) : null"
|
245
|
}
|
246
|
]
|
247
|
}
|
248
|
],
|
249
|
"scales": [
|
250
|
{
|
251
|
"name": "xOverview",
|
252
|
"type": "time",
|
253
|
"range": "width",
|
254
|
"domain": {"data": "table3", "fields": ["dateMin", "dateMax"]}
|
255
|
},
|
256
|
{
|
257
|
"name": "yOverview",
|
258
|
"type": "linear",
|
259
|
"range": [70, 0],
|
260
|
"domain": {"data": "table", "field": "avg"},
|
261
|
"nice": true, "zero": true
|
262
|
}
|
263
|
],
|
264
|
"axes": [
|
265
|
{"orient": "bottom", "scale": "xOverview"}
|
266
|
],
|
267
|
"marks": [
|
268
|
{
|
269
|
"type": "symbol",
|
270
|
"from": {"data":"table"},
|
271
|
"encode": {
|
272
|
"update": {
|
273
|
"shape": {"value": "circle"},
|
274
|
"size": {"value": 10},
|
275
|
"x": {"scale": "xOverview", "field": "dateTime"},
|
276
|
"y": {"scale": "yOverview", "field": "avg"},
|
277
|
"color": {"value": "both"},
|
278
|
"strokeWidth": {"value": 4}
|
279
|
}
|
280
|
}
|
281
|
},
|
282
|
{
|
283
|
"type": "rule",
|
284
|
"from": {
|
285
|
"data": "table2"
|
286
|
},
|
287
|
"encode": {
|
288
|
"update": {
|
289
|
"x": {
|
290
|
"scale": "xOverview",
|
291
|
"field": "unit0"
|
292
|
},
|
293
|
"x2": [
|
294
|
{
|
295
|
"test": "isValid(datum.obj)",
|
296
|
"scale": "xOverview",
|
297
|
"field": "obj.unit0"
|
298
|
},
|
299
|
{
|
300
|
"scale": "xOverview",
|
301
|
"field": "unit0"
|
302
|
}
|
303
|
],
|
304
|
"y": {
|
305
|
"scale": "yOverview",
|
306
|
"field": "avg"
|
307
|
},
|
308
|
"y2": [
|
309
|
{
|
310
|
"test": "isValid(datum.obj)",
|
311
|
"scale": "yOverview",
|
312
|
"field": "obj.avg"
|
313
|
},
|
314
|
{
|
315
|
"scale": "yOverview",
|
316
|
"field": "avg"
|
317
|
}
|
318
|
],
|
319
|
"stroke": {
|
320
|
"value": "steelblue"
|
321
|
},
|
322
|
"strokeWidth": {
|
323
|
"value": 1
|
324
|
}
|
325
|
}
|
326
|
}
|
327
|
},
|
328
|
|
329
|
{
|
330
|
"type": "rect",
|
331
|
"name": "brush",
|
332
|
"encode": {
|
333
|
"enter": {
|
334
|
"y": {"value": 0},
|
335
|
"height": {"value": 70},
|
336
|
"fill": {"value": "#333"},
|
337
|
"fillOpacity": {"value": 0.2}
|
338
|
},
|
339
|
"update": {
|
340
|
"x": {"signal": "brush[0]"},
|
341
|
"x2": {"signal": "brush[1]"}
|
342
|
}
|
343
|
}
|
344
|
},
|
345
|
{
|
346
|
"type": "rect",
|
347
|
"interactive": false,
|
348
|
"encode": {
|
349
|
"enter": {
|
350
|
"y": {"value": 0},
|
351
|
"height": {"value": 70},
|
352
|
"width": {"value": 1},
|
353
|
"fill": {"value": "firebrick"}
|
354
|
},
|
355
|
"update": {
|
356
|
"x": {"signal": "brush[0]"}
|
357
|
}
|
358
|
}
|
359
|
},
|
360
|
{
|
361
|
"type": "rect",
|
362
|
"interactive": false,
|
363
|
"encode": {
|
364
|
"enter": {
|
365
|
"y": {"value": 0},
|
366
|
"height": {"value": 70},
|
367
|
"width": {"value": 1},
|
368
|
"fill": {"value": "firebrick"}
|
369
|
},
|
370
|
"update": {
|
371
|
"x": {"signal": "brush[1]"}
|
372
|
}
|
373
|
}
|
374
|
}
|
375
|
]
|
376
|
}
|
377
|
]
|
378
|
}
|
379
|
|
380
|
|
381
|
|