1
|
{
|
2
|
"data": [
|
3
|
{},
|
4
|
{},
|
5
|
{
|
6
|
"transform": [
|
7
|
{
|
8
|
"type": "flatten",
|
9
|
"fields": [
|
10
|
{
|
11
|
"signal": "dataPath"
|
12
|
}
|
13
|
]
|
14
|
}
|
15
|
]
|
16
|
},
|
17
|
{
|
18
|
"transform": [
|
19
|
{
|
20
|
"type": "project",
|
21
|
"fields": [
|
22
|
{
|
23
|
"signal": "valuePath"
|
24
|
},
|
25
|
{
|
26
|
"signal": "timestampPath"
|
27
|
},
|
28
|
{
|
29
|
"signal": "sensorPath"
|
30
|
}
|
31
|
],
|
32
|
"as": [
|
33
|
"value",
|
34
|
"timestamp",
|
35
|
"sensor"
|
36
|
]
|
37
|
}
|
38
|
]
|
39
|
},
|
40
|
{},
|
41
|
{
|
42
|
"name": "ranks",
|
43
|
"source": "table",
|
44
|
"transform": [
|
45
|
{
|
46
|
"type": "window",
|
47
|
"sort": {
|
48
|
"field": [
|
49
|
"sensor",
|
50
|
"dateTime"
|
51
|
],
|
52
|
"order": [
|
53
|
"ascending",
|
54
|
"ascending"
|
55
|
]
|
56
|
},
|
57
|
"ops": [
|
58
|
"rank"
|
59
|
],
|
60
|
"fields": [
|
61
|
"value"
|
62
|
],
|
63
|
"as": [
|
64
|
"rank"
|
65
|
]
|
66
|
},
|
67
|
{
|
68
|
"type": "formula",
|
69
|
"expr": "datum.rank + 1",
|
70
|
"as": "nextRank"
|
71
|
}
|
72
|
]
|
73
|
},
|
74
|
{
|
75
|
"name": "lookup",
|
76
|
"source": "ranks",
|
77
|
"transform": [
|
78
|
{
|
79
|
"type": "lookup",
|
80
|
"from": "ranks",
|
81
|
"key": "rank",
|
82
|
"fields": [
|
83
|
"nextRank"
|
84
|
],
|
85
|
"as": [
|
86
|
"tempObj"
|
87
|
]
|
88
|
},
|
89
|
{
|
90
|
"type": "formula",
|
91
|
"expr": "(datum.tempObj == null || datum.tempObj.sensor != datum.sensor || datum.tempObj.dateTime - datum.dateTime > maxTimeDifference) ? null : datum.tempObj",
|
92
|
"as": "obj"
|
93
|
}
|
94
|
]
|
95
|
},
|
96
|
{
|
97
|
"name": "tooltipTmp1",
|
98
|
"source": "lookup",
|
99
|
"transform": [
|
100
|
{
|
101
|
"type": "pivot",
|
102
|
"groupby": [
|
103
|
"dateTime"
|
104
|
],
|
105
|
"field": "sensor",
|
106
|
"value": "value",
|
107
|
"op": "median"
|
108
|
}
|
109
|
]
|
110
|
},
|
111
|
{
|
112
|
"name": "tooltipTmp2",
|
113
|
"source": "tooltipTmp1",
|
114
|
"transform": [
|
115
|
{
|
116
|
"type": "window",
|
117
|
"sort": {
|
118
|
"field": [
|
119
|
"dateTime"
|
120
|
],
|
121
|
"order": [
|
122
|
"ascending"
|
123
|
]
|
124
|
},
|
125
|
"ops": [
|
126
|
"rank"
|
127
|
],
|
128
|
"fields": [
|
129
|
"value"
|
130
|
],
|
131
|
"as": [
|
132
|
"rank"
|
133
|
]
|
134
|
},
|
135
|
{
|
136
|
"type": "formula",
|
137
|
"expr": "datum.rank - 1",
|
138
|
"as": "prevRank"
|
139
|
},
|
140
|
{
|
141
|
"type": "formula",
|
142
|
"expr": "datum.rank + 1",
|
143
|
"as": "nextRank"
|
144
|
}
|
145
|
]
|
146
|
},
|
147
|
{
|
148
|
"name": "tooltip",
|
149
|
"source": "tooltipTmp2",
|
150
|
"transform": [
|
151
|
{
|
152
|
"type": "lookup",
|
153
|
"from": "tooltipTmp2",
|
154
|
"key": "rank",
|
155
|
"fields": [
|
156
|
"nextRank"
|
157
|
],
|
158
|
"as": [
|
159
|
"nextObj"
|
160
|
]
|
161
|
},
|
162
|
{
|
163
|
"type": "lookup",
|
164
|
"from": "tooltipTmp2",
|
165
|
"key": "rank",
|
166
|
"fields": [
|
167
|
"prevRank"
|
168
|
],
|
169
|
"as": [
|
170
|
"prevObj"
|
171
|
]
|
172
|
},
|
173
|
{
|
174
|
"type": "formula",
|
175
|
"expr": "datum.prevObj == null ? data('range')[0].dateMin : (time(datum.prevObj.dateTime) + time(datum.dateTime)) / 2",
|
176
|
"as": "dateStart"
|
177
|
},
|
178
|
{
|
179
|
"type": "formula",
|
180
|
"expr": "datum.nextObj == null ? data('range')[0].dateMax : (time(datum.nextObj.dateTime) + time(datum.dateTime)) / 2",
|
181
|
"as": "dateEnd"
|
182
|
}
|
183
|
]
|
184
|
}
|
185
|
],
|
186
|
"signals": [
|
187
|
{},
|
188
|
{
|
189
|
"name": "tooltipSignal",
|
190
|
"value": {},
|
191
|
"on": [
|
192
|
{
|
193
|
"events": "@tooltip-hitarea:mouseover",
|
194
|
"update": "datum"
|
195
|
},
|
196
|
{
|
197
|
"events": "@tooltip-hitarea:mouseout",
|
198
|
"update": "{}"
|
199
|
}
|
200
|
]
|
201
|
}
|
202
|
],
|
203
|
"marks": [
|
204
|
{
|
205
|
"scales": [
|
206
|
{},
|
207
|
{
|
208
|
"name": "yDetail",
|
209
|
"type": "linear",
|
210
|
"range": [
|
211
|
390,
|
212
|
0
|
213
|
],
|
214
|
"domain": {
|
215
|
"fields": [
|
216
|
{
|
217
|
"data": "range",
|
218
|
"field": "valueMax"
|
219
|
},
|
220
|
{
|
221
|
"data": "table",
|
222
|
"field": "value"
|
223
|
}
|
224
|
]
|
225
|
},
|
226
|
"nice": true,
|
227
|
"zero": true
|
228
|
},
|
229
|
{
|
230
|
"name": "color",
|
231
|
"type": "ordinal",
|
232
|
"range": {
|
233
|
"scheme": "category20"
|
234
|
},
|
235
|
"domain": {
|
236
|
"data": "table",
|
237
|
"field": "sensor"
|
238
|
}
|
239
|
}
|
240
|
],
|
241
|
"legends": [
|
242
|
{
|
243
|
"fill": "color",
|
244
|
"title": "Sensory",
|
245
|
"offset": 0,
|
246
|
"encode": {
|
247
|
"symbols": {
|
248
|
"update": {
|
249
|
"fillOpacity": {
|
250
|
"value": 0.5
|
251
|
},
|
252
|
"stroke": {
|
253
|
"value": "transparent"
|
254
|
}
|
255
|
}
|
256
|
}
|
257
|
}
|
258
|
}
|
259
|
],
|
260
|
"axes": [
|
261
|
{},
|
262
|
{
|
263
|
"orient": "left",
|
264
|
"scale": "yDetail"
|
265
|
}
|
266
|
],
|
267
|
"marks": [
|
268
|
{
|
269
|
"marks": [
|
270
|
{
|
271
|
"type": "group",
|
272
|
"from": {
|
273
|
"facet": {
|
274
|
"name": "series",
|
275
|
"data": "lookup",
|
276
|
"groupby": "sensor"
|
277
|
}
|
278
|
},
|
279
|
"marks": [
|
280
|
{
|
281
|
"type": "symbol",
|
282
|
"from": {
|
283
|
"data": "series"
|
284
|
},
|
285
|
"encode": {
|
286
|
"update": {
|
287
|
"shape": {
|
288
|
"value": "circle"
|
289
|
},
|
290
|
"size": {
|
291
|
"value": 30
|
292
|
},
|
293
|
"x": {
|
294
|
"scale": "xDetail",
|
295
|
"field": "dateTime"
|
296
|
},
|
297
|
"y": {
|
298
|
"scale": "yDetail",
|
299
|
"field": "value"
|
300
|
},
|
301
|
"color": {
|
302
|
"value": "both"
|
303
|
},
|
304
|
"strokeWidth": {
|
305
|
"value": 4
|
306
|
},
|
307
|
"fill": {
|
308
|
"scale": "color",
|
309
|
"field": "sensor"
|
310
|
}
|
311
|
}
|
312
|
}
|
313
|
},
|
314
|
{
|
315
|
"type": "rule",
|
316
|
"from": {
|
317
|
"data": "series"
|
318
|
},
|
319
|
"encode": {
|
320
|
"update": {
|
321
|
"x": {
|
322
|
"scale": "xDetail",
|
323
|
"field": "dateTime"
|
324
|
},
|
325
|
"x2": [
|
326
|
{
|
327
|
"test": "isValid(datum.obj)",
|
328
|
"scale": "xDetail",
|
329
|
"field": "obj.dateTime"
|
330
|
},
|
331
|
{
|
332
|
"scale": "xDetail",
|
333
|
"field": "dateTime"
|
334
|
}
|
335
|
],
|
336
|
"y": {
|
337
|
"scale": "yDetail",
|
338
|
"field": "value"
|
339
|
},
|
340
|
"y2": [
|
341
|
{
|
342
|
"test": "isValid(datum.obj)",
|
343
|
"scale": "yDetail",
|
344
|
"field": "obj.value"
|
345
|
},
|
346
|
{
|
347
|
"scale": "yDetail",
|
348
|
"field": "value"
|
349
|
}
|
350
|
],
|
351
|
"stroke": {
|
352
|
"scale": "color",
|
353
|
"field": "sensor"
|
354
|
},
|
355
|
"strokeWidth": {
|
356
|
"value": 1
|
357
|
}
|
358
|
}
|
359
|
}
|
360
|
},
|
361
|
{
|
362
|
"name": "tooltip-hitarea",
|
363
|
"type": "rect",
|
364
|
"interactive": true,
|
365
|
"from": {
|
366
|
"data": "tooltip"
|
367
|
},
|
368
|
"encode": {
|
369
|
"enter": {
|
370
|
"tooltip": {
|
371
|
"signal": null
|
372
|
}
|
373
|
},
|
374
|
"update": {
|
375
|
"x": {
|
376
|
"scale": "xDetail",
|
377
|
"field": "dateStart"
|
378
|
},
|
379
|
"x2": {
|
380
|
"scale": "xDetail",
|
381
|
"field": "dateEnd"
|
382
|
},
|
383
|
"y": {
|
384
|
"scale": "yDetail",
|
385
|
"band": 1
|
386
|
},
|
387
|
"y2": {
|
388
|
"scale": "yDetail",
|
389
|
"value": 0
|
390
|
},
|
391
|
"fill": {
|
392
|
"value": "#00ff00"
|
393
|
},
|
394
|
"fillOpacity": {
|
395
|
"value": 0.0
|
396
|
}
|
397
|
}
|
398
|
}
|
399
|
},
|
400
|
{
|
401
|
"type": "rule",
|
402
|
"interactive": false,
|
403
|
"zindex": 20,
|
404
|
"encode": {
|
405
|
"enter": {
|
406
|
},
|
407
|
"update": {
|
408
|
"x": {
|
409
|
"scale": "xDetail",
|
410
|
"signal": "tooltipSignal.dateTime"
|
411
|
},
|
412
|
"y": {
|
413
|
"scale": "yDetail",
|
414
|
"band": 1
|
415
|
},
|
416
|
"y2": {
|
417
|
"scale": "yDetail",
|
418
|
"value": 0
|
419
|
},
|
420
|
"strokeOpacity": [
|
421
|
{
|
422
|
"test": "tooltipSignal.dateTime > 1",
|
423
|
"value": 1
|
424
|
},
|
425
|
{
|
426
|
"value": 0
|
427
|
}
|
428
|
]
|
429
|
}
|
430
|
}
|
431
|
}
|
432
|
]
|
433
|
}
|
434
|
]
|
435
|
}
|
436
|
]
|
437
|
},
|
438
|
{
|
439
|
"signals": [
|
440
|
{
|
441
|
"value": 0,
|
442
|
"on": [
|
443
|
{},
|
444
|
{
|
445
|
"events": "@overview:mousedown",
|
446
|
"update": "[x(), x()]"
|
447
|
},
|
448
|
{
|
449
|
"events": "[@overview:mousedown, window:mouseup] > window:mousemove!",
|
450
|
"update": "[brush[0], clamp(x(), 0, width)]"
|
451
|
}
|
452
|
]
|
453
|
}
|
454
|
],
|
455
|
"scales": [
|
456
|
{},
|
457
|
{},
|
458
|
{
|
459
|
"name": "color",
|
460
|
"type": "ordinal",
|
461
|
"range": {
|
462
|
"scheme": "category20"
|
463
|
},
|
464
|
"domain": {
|
465
|
"data": "table",
|
466
|
"field": "sensor"
|
467
|
}
|
468
|
}
|
469
|
],
|
470
|
"marks": [
|
471
|
{},
|
472
|
{},
|
473
|
{},
|
474
|
{
|
475
|
"type": "group",
|
476
|
"from": {
|
477
|
"facet": {
|
478
|
"name": "series",
|
479
|
"data": "lookup",
|
480
|
"groupby": "sensor"
|
481
|
}
|
482
|
},
|
483
|
"marks": [
|
484
|
{
|
485
|
"type": "symbol",
|
486
|
"from": {
|
487
|
"data": "series"
|
488
|
},
|
489
|
"encode": {
|
490
|
"update": {
|
491
|
"shape": {
|
492
|
"value": "circle"
|
493
|
},
|
494
|
"size": {
|
495
|
"value": 30
|
496
|
},
|
497
|
"x": {
|
498
|
"scale": "xOverview",
|
499
|
"field": "dateTime"
|
500
|
},
|
501
|
"y": {
|
502
|
"scale": "yOverview",
|
503
|
"field": "value"
|
504
|
},
|
505
|
"color": {
|
506
|
"value": "both"
|
507
|
},
|
508
|
"strokeWidth": {
|
509
|
"value": 4
|
510
|
},
|
511
|
"fill": {
|
512
|
"scale": "color",
|
513
|
"field": "sensor"
|
514
|
}
|
515
|
}
|
516
|
}
|
517
|
},
|
518
|
{
|
519
|
"type": "rule",
|
520
|
"from": {
|
521
|
"data": "series"
|
522
|
},
|
523
|
"encode": {
|
524
|
"update": {
|
525
|
"x": {
|
526
|
"scale": "xOverview",
|
527
|
"field": "dateTime"
|
528
|
},
|
529
|
"x2": [
|
530
|
{
|
531
|
"test": "isValid(datum.obj)",
|
532
|
"scale": "xOverview",
|
533
|
"field": "obj.dateTime"
|
534
|
},
|
535
|
{
|
536
|
"scale": "xOverview",
|
537
|
"field": "dateTime"
|
538
|
}
|
539
|
],
|
540
|
"y": {
|
541
|
"scale": "yOverview",
|
542
|
"field": "value"
|
543
|
},
|
544
|
"y2": [
|
545
|
{
|
546
|
"test": "isValid(datum.obj)",
|
547
|
"scale": "yOverview",
|
548
|
"field": "obj.value"
|
549
|
},
|
550
|
{
|
551
|
"scale": "yOverview",
|
552
|
"field": "value"
|
553
|
}
|
554
|
],
|
555
|
"stroke": {
|
556
|
"scale": "color",
|
557
|
"field": "sensor"
|
558
|
},
|
559
|
"strokeWidth": {
|
560
|
"value": 1
|
561
|
}
|
562
|
}
|
563
|
}
|
564
|
}
|
565
|
]
|
566
|
}
|
567
|
]
|
568
|
}
|
569
|
]
|
570
|
}
|
571
|
|