Projekt

Obecné

Profil

Stáhnout (13.7 KB) Statistiky
| Větev: | Tag: | Revize:
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
    {},
190
    {
191
      "name": "tooltipSignal",
192
      "value": {},
193
      "on": [
194
        {
195
          "events": "@tooltip-hitarea:mouseover",
196
          "update": "datum"
197
        },
198
        {
199
          "events": "@tooltip-hitarea:mouseout",
200
          "update": "{}"
201
        }
202
      ]
203
    }
204
  ],
205
  "marks": [
206
    {
207
      "scales": [
208
        {},
209
        {
210
          "name": "yDetail",
211
          "type": "linear",
212
          "range": [
213
            390,
214
            0
215
          ],
216
          "domain": {
217
            "fields": [
218
              {
219
                "data": "range",
220
                "field": "valueMax"
221
              },
222
              {
223
                "data": "table",
224
                "field": "value"
225
              }
226
            ]
227
          },
228
          "nice": true,
229
          "zero": true
230
        },
231
        {
232
          "name": "color",
233
          "type": "ordinal",
234
          "range": {
235
            "scheme": "category20"
236
          },
237
          "domain": {
238
            "data": "table",
239
            "field": "sensor"
240
          }
241
        }
242
      ],
243
      "legends": [
244
        {
245
          "fill": "color",
246
          "title": "Sensors:",
247
          "offset": 0,
248
          "encode": {
249
            "symbols": {
250
              "update": {
251
                "fillOpacity": {
252
                  "value": 0.5
253
                },
254
                "stroke": {
255
                  "value": "transparent"
256
                }
257
              }
258
            }
259
          }
260
        }
261
      ],
262
      "axes": [
263
        {},
264
        {
265
          "orient": "left",
266
          "scale": "yDetail"
267
        }
268
      ],
269
      "marks": [
270
        {
271
          "marks": [
272
            {
273
              "type": "group",
274
              "from": {
275
                "facet": {
276
                  "name": "series",
277
                  "data": "lookup",
278
                  "groupby": "sensor"
279
                }
280
              },
281
              "marks": [
282
                {
283
                  "type": "symbol",
284
                  "from": {
285
                    "data": "series"
286
                  },
287
                  "encode": {
288
                    "update": {
289
                      "shape": {
290
                        "value": "circle"
291
                      },
292
                      "size": {
293
                        "value": 30
294
                      },
295
                      "x": {
296
                        "scale": "xDetail",
297
                        "field": "dateTime"
298
                      },
299
                      "y": {
300
                        "scale": "yDetail",
301
                        "field": "value"
302
                      },
303
                      "color": {
304
                        "value": "both"
305
                      },
306
                      "strokeWidth": {
307
                        "value": 4
308
                      },
309
                      "fill": {
310
                        "scale": "color",
311
                        "field": "sensor"
312
                      }
313
                    }
314
                  }
315
                },
316
                {
317
                  "type": "rule",
318
                  "from": {
319
                    "data": "series"
320
                  },
321
                  "encode": {
322
                    "update": {
323
                      "x": {
324
                        "scale": "xDetail",
325
                        "field": "dateTime"
326
                      },
327
                      "x2": [
328
                        {
329
                          "test": "isValid(datum.obj)",
330
                          "scale": "xDetail",
331
                          "field": "obj.dateTime"
332
                        },
333
                        {
334
                          "scale": "xDetail",
335
                          "field": "dateTime"
336
                        }
337
                      ],
338
                      "y": {
339
                        "scale": "yDetail",
340
                        "field": "value"
341
                      },
342
                      "y2": [
343
                        {
344
                          "test": "isValid(datum.obj)",
345
                          "scale": "yDetail",
346
                          "field": "obj.value"
347
                        },
348
                        {
349
                          "scale": "yDetail",
350
                          "field": "value"
351
                        }
352
                      ],
353
                      "stroke": {
354
                        "scale": "color",
355
                        "field": "sensor"
356
                      },
357
                      "strokeWidth": {
358
                        "value": 1
359
                      }
360
                    }
361
                  }
362
                },
363
                {
364
                  "name": "tooltip-hitarea",
365
                  "type": "rect",
366
                  "interactive": true,
367
                  "from": {
368
                    "data": "tooltip"
369
                  },
370
                  "encode": {
371
                    "enter": {
372
                      "tooltip": {
373
                        "signal": null
374
                      }
375
                    },
376
                    "update": {
377
                      "x": {
378
                        "scale": "xDetail",
379
                        "field": "dateStart"
380
                      },
381
                      "x2": {
382
                        "scale": "xDetail",
383
                        "field": "dateEnd"
384
                      },
385
                      "y": {
386
                        "scale": "yDetail",
387
                        "band": 1
388
                      },
389
                      "y2": {
390
                        "scale": "yDetail",
391
                        "signal": "-1e+36"
392
                      },
393
                      "fill": {
394
                        "value": "#00ff00"
395
                      },
396
                      "fillOpacity": {
397
                        "value": 0.0
398
                      }
399
                    }
400
                  }
401
                },
402
                {
403
                  "type": "rule",
404
                  "interactive": false,
405
                  "zindex": 20,
406
                  "encode": {
407
                    "enter": {
408
                    },
409
                    "update": {
410
                      "x": {
411
                        "scale": "xDetail",
412
                        "signal": "tooltipSignal.dateTime"
413
                      },
414
                      "y": {
415
                        "scale": "yDetail",
416
                        "band": 1
417
                      },
418
                      "y2": {
419
                        "scale": "yDetail",
420
                        "signal": "-1e+36"
421
                      },
422
                      "strokeOpacity": [
423
                        {
424
                          "test": "tooltipSignal.dateTime > 1",
425
                          "value": 1
426
                        },
427
                        {
428
                          "value": 0
429
                        }
430
                      ]
431
                    }
432
                  }
433
                }
434
              ]
435
            }
436
          ]
437
        }
438
      ]
439
    },
440
    {
441
      "signals": [
442
        {
443
          "value": 0,
444
          "on": [
445
            {},
446
            {
447
              "events": "@overview:mousedown",
448
              "update": "[x(), x()]"
449
            },
450
            {
451
              "events": "[@overview:mousedown, window:mouseup] > window:mousemove!",
452
              "update": "[brush[0], clamp(x(), 0, width)]"
453
            }
454
          ]
455
        }
456
      ],
457
      "scales": [
458
        {},
459
        {},
460
        {
461
          "name": "color",
462
          "type": "ordinal",
463
          "range": {
464
            "scheme": "category20"
465
          },
466
          "domain": {
467
            "data": "table",
468
            "field": "sensor"
469
          }
470
        }
471
      ],
472
      "marks": [
473
        {},
474
        {},
475
        {},
476
        {
477
          "type": "group",
478
          "from": {
479
            "facet": {
480
              "name": "series",
481
              "data": "lookup",
482
              "groupby": "sensor"
483
            }
484
          },
485
          "marks": [
486
            {
487
              "type": "symbol",
488
              "from": {
489
                "data": "series"
490
              },
491
              "encode": {
492
                "update": {
493
                  "shape": {
494
                    "value": "circle"
495
                  },
496
                  "size": {
497
                    "value": 30
498
                  },
499
                  "x": {
500
                    "scale": "xOverview",
501
                    "field": "dateTime"
502
                  },
503
                  "y": {
504
                    "scale": "yOverview",
505
                    "field": "value"
506
                  },
507
                  "color": {
508
                    "value": "both"
509
                  },
510
                  "strokeWidth": {
511
                    "value": 4
512
                  },
513
                  "fill": {
514
                    "scale": "color",
515
                    "field": "sensor"
516
                  }
517
                }
518
              }
519
            },
520
            {
521
              "type": "rule",
522
              "from": {
523
                "data": "series"
524
              },
525
              "encode": {
526
                "update": {
527
                  "x": {
528
                    "scale": "xOverview",
529
                    "field": "dateTime"
530
                  },
531
                  "x2": [
532
                    {
533
                      "test": "isValid(datum.obj)",
534
                      "scale": "xOverview",
535
                      "field": "obj.dateTime"
536
                    },
537
                    {
538
                      "scale": "xOverview",
539
                      "field": "dateTime"
540
                    }
541
                  ],
542
                  "y": {
543
                    "scale": "yOverview",
544
                    "field": "value"
545
                  },
546
                  "y2": [
547
                    {
548
                      "test": "isValid(datum.obj)",
549
                      "scale": "yOverview",
550
                      "field": "obj.value"
551
                    },
552
                    {
553
                      "scale": "yOverview",
554
                      "field": "value"
555
                    }
556
                  ],
557
                  "stroke": {
558
                    "scale": "color",
559
                    "field": "sensor"
560
                  },
561
                  "strokeWidth": {
562
                    "value": 1
563
                  }
564
                }
565
              }
566
            }
567
          ]
568
        }
569
      ]
570
    }
571
  ]
572
}
573

    
(3-3/4)