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