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[\"time\"])",
|
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": "detailDomain"
|
66
|
},
|
67
|
{
|
68
|
"name": "timeStep",
|
69
|
"value": 1800
|
70
|
}
|
71
|
],
|
72
|
|
73
|
"marks": [
|
74
|
{
|
75
|
"type": "group",
|
76
|
"name": "detail",
|
77
|
"encode": {
|
78
|
"enter": {
|
79
|
"height": {"value": 390},
|
80
|
"width": {"value": 800}
|
81
|
}
|
82
|
},
|
83
|
"scales": [
|
84
|
{
|
85
|
"name": "xDetail",
|
86
|
"type": "time",
|
87
|
"range": "width",
|
88
|
"domain": {"data": "table3", "fields": ["dateMin", "dateMax"]},
|
89
|
"domainRaw": {"signal": "detailDomain"}
|
90
|
},
|
91
|
{
|
92
|
"name": "yDetail",
|
93
|
"type": "linear",
|
94
|
"range": [390, 0],
|
95
|
"domain": {"data": "table", "field": "value"},
|
96
|
"nice": true, "zero": true
|
97
|
}
|
98
|
],
|
99
|
"axes": [
|
100
|
{"orient": "bottom", "scale": "xDetail"},
|
101
|
{"orient": "left", "scale": "yDetail"}
|
102
|
],
|
103
|
"marks": [
|
104
|
{
|
105
|
"type": "group",
|
106
|
"encode": {
|
107
|
"enter": {
|
108
|
"height": {"field": {"group": "height"}},
|
109
|
"width": {"field": {"group": "width"}},
|
110
|
"clip": {"value": true}
|
111
|
}
|
112
|
},
|
113
|
"marks": [
|
114
|
{
|
115
|
"type": "symbol",
|
116
|
"from": {"data":"table"},
|
117
|
"encode": {
|
118
|
"enter": {
|
119
|
"tooltip": {
|
120
|
"signal": "{title: timeFormat(datum.dateTime, '%B %d, %Y %H:%M') , 'gid': datum.gid , 'value': datum.value }"
|
121
|
}},
|
122
|
"update": {
|
123
|
"shape": {"value": "circle"},
|
124
|
"size": {"value": 30},
|
125
|
"x": {"scale": "xDetail", "field": "dateTime"},
|
126
|
"y": {"scale": "yDetail", "field": "value"},
|
127
|
"color": {"value": "both"},
|
128
|
"strokeWidth": {"value": 4},
|
129
|
"fill": {"value": "steelblue"}
|
130
|
},
|
131
|
"hover": {
|
132
|
"fill": {"value": "red"},
|
133
|
"size": {"value": 60}
|
134
|
}
|
135
|
}
|
136
|
},
|
137
|
{
|
138
|
"type": "rule",
|
139
|
"from": {
|
140
|
"data": "table2"
|
141
|
},
|
142
|
"encode": {
|
143
|
"update": {
|
144
|
"x": {
|
145
|
"scale": "xDetail",
|
146
|
"field": "unit0"
|
147
|
},
|
148
|
"x2": [
|
149
|
{
|
150
|
"test": "isValid(datum.obj)",
|
151
|
"scale": "xDetail",
|
152
|
"field": "obj.unit0"
|
153
|
},
|
154
|
{
|
155
|
"scale": "xDetail",
|
156
|
"field": "unit0"
|
157
|
}
|
158
|
],
|
159
|
"y": {
|
160
|
"scale": "yDetail",
|
161
|
"field": "value"
|
162
|
},
|
163
|
"y2": [
|
164
|
{
|
165
|
"test": "isValid(datum.obj)",
|
166
|
"scale": "yDetail",
|
167
|
"field": "obj.value"
|
168
|
},
|
169
|
{
|
170
|
"scale": "yDetail",
|
171
|
"field": "value"
|
172
|
}
|
173
|
],
|
174
|
"stroke": {
|
175
|
"value": "steelblue"
|
176
|
},
|
177
|
"strokeWidth": {
|
178
|
"value": 1
|
179
|
}
|
180
|
}
|
181
|
}
|
182
|
}
|
183
|
|
184
|
|
185
|
]
|
186
|
}
|
187
|
]
|
188
|
},
|
189
|
|
190
|
{
|
191
|
"type": "group",
|
192
|
"name": "overview",
|
193
|
"encode": {
|
194
|
"enter": {
|
195
|
"x": {"value": 0},
|
196
|
"y": {"value": 430},
|
197
|
"height": {"value": 70},
|
198
|
"width": {"value": 720},
|
199
|
"fill": {"value": "transparent"}
|
200
|
}
|
201
|
},
|
202
|
"signals": [
|
203
|
{
|
204
|
"name": "brush", "value": 0,
|
205
|
"on": [
|
206
|
{
|
207
|
"events": "@overview:mousedown",
|
208
|
"update": "[x(), x()]"
|
209
|
},
|
210
|
{
|
211
|
"events": "[@overview:mousedown, window:mouseup] > window:mousemove!",
|
212
|
"update": "[brush[0], clamp(x(), 0, width)]"
|
213
|
},
|
214
|
{
|
215
|
"events": {"signal": "delta"},
|
216
|
"update": "clampRange([anchor[0] + delta, anchor[1] + delta], 0, width)"
|
217
|
}
|
218
|
]
|
219
|
},
|
220
|
{
|
221
|
"name": "anchor", "value": null,
|
222
|
"on": [{"events": "@brush:mousedown", "update": "slice(brush)"}]
|
223
|
},
|
224
|
{
|
225
|
"name": "xdown", "value": 0,
|
226
|
"on": [{"events": "@brush:mousedown", "update": "x()"}]
|
227
|
},
|
228
|
{
|
229
|
"name": "delta", "value": 0,
|
230
|
"on": [
|
231
|
{
|
232
|
"events": "[@brush:mousedown, window:mouseup] > window:mousemove!",
|
233
|
"update": "x() - xdown"
|
234
|
}
|
235
|
]
|
236
|
},
|
237
|
{
|
238
|
"name": "detailDomain",
|
239
|
"push": "outer",
|
240
|
"on": [
|
241
|
{
|
242
|
"events": {"signal": "brush"},
|
243
|
"update": "span(brush) ? invert('xOverview', brush) : null"
|
244
|
}
|
245
|
]
|
246
|
}
|
247
|
],
|
248
|
"scales": [
|
249
|
{
|
250
|
"name": "xOverview",
|
251
|
"type": "time",
|
252
|
"range": "width",
|
253
|
"domain": {"data": "table3", "fields": ["dateMin", "dateMax"]}
|
254
|
},
|
255
|
{
|
256
|
"name": "yOverview",
|
257
|
"type": "linear",
|
258
|
"range": [70, 0],
|
259
|
"domain": {"data": "table", "field": "value"},
|
260
|
"nice": true, "zero": true
|
261
|
}
|
262
|
],
|
263
|
"axes": [
|
264
|
{"orient": "bottom", "scale": "xOverview"}
|
265
|
],
|
266
|
"marks": [
|
267
|
{
|
268
|
"type": "symbol",
|
269
|
"from": {"data":"table"},
|
270
|
"encode": {
|
271
|
"update": {
|
272
|
"shape": {"value": "circle"},
|
273
|
"size": {"value": 10},
|
274
|
"x": {"scale": "xOverview", "field": "dateTime"},
|
275
|
"y": {"scale": "yOverview", "field": "value"},
|
276
|
"color": {"value": "both"},
|
277
|
"strokeWidth": {"value": 4}
|
278
|
}
|
279
|
}
|
280
|
},
|
281
|
{
|
282
|
"type": "rule",
|
283
|
"from": {
|
284
|
"data": "table2"
|
285
|
},
|
286
|
"encode": {
|
287
|
"update": {
|
288
|
"x": {
|
289
|
"scale": "xOverview",
|
290
|
"field": "unit0"
|
291
|
},
|
292
|
"x2": [
|
293
|
{
|
294
|
"test": "isValid(datum.obj)",
|
295
|
"scale": "xOverview",
|
296
|
"field": "obj.unit0"
|
297
|
},
|
298
|
{
|
299
|
"scale": "xOverview",
|
300
|
"field": "unit0"
|
301
|
}
|
302
|
],
|
303
|
"y": {
|
304
|
"scale": "yOverview",
|
305
|
"field": "value"
|
306
|
},
|
307
|
"y2": [
|
308
|
{
|
309
|
"test": "isValid(datum.obj)",
|
310
|
"scale": "yOverview",
|
311
|
"field": "obj.value"
|
312
|
},
|
313
|
{
|
314
|
"scale": "yOverview",
|
315
|
"field": "value"
|
316
|
}
|
317
|
],
|
318
|
"stroke": {
|
319
|
"value": "steelblue"
|
320
|
},
|
321
|
"strokeWidth": {
|
322
|
"value": 1
|
323
|
}
|
324
|
}
|
325
|
}
|
326
|
},
|
327
|
|
328
|
{
|
329
|
"type": "rect",
|
330
|
"name": "brush",
|
331
|
"encode": {
|
332
|
"enter": {
|
333
|
"y": {"value": 0},
|
334
|
"height": {"value": 70},
|
335
|
"fill": {"value": "#333"},
|
336
|
"fillOpacity": {"value": 0.2}
|
337
|
},
|
338
|
"update": {
|
339
|
"x": {"signal": "brush[0]"},
|
340
|
"x2": {"signal": "brush[1]"}
|
341
|
}
|
342
|
}
|
343
|
},
|
344
|
{
|
345
|
"type": "rect",
|
346
|
"interactive": false,
|
347
|
"encode": {
|
348
|
"enter": {
|
349
|
"y": {"value": 0},
|
350
|
"height": {"value": 70},
|
351
|
"width": {"value": 1},
|
352
|
"fill": {"value": "firebrick"}
|
353
|
},
|
354
|
"update": {
|
355
|
"x": {"signal": "brush[0]"}
|
356
|
}
|
357
|
}
|
358
|
},
|
359
|
{
|
360
|
"type": "rect",
|
361
|
"interactive": false,
|
362
|
"encode": {
|
363
|
"enter": {
|
364
|
"y": {"value": 0},
|
365
|
"height": {"value": 70},
|
366
|
"width": {"value": 1},
|
367
|
"fill": {"value": "firebrick"}
|
368
|
},
|
369
|
"update": {
|
370
|
"x": {"signal": "brush[1]"}
|
371
|
}
|
372
|
}
|
373
|
}
|
374
|
]
|
375
|
}
|
376
|
]
|
377
|
}
|
378
|
|
379
|
|
380
|
|