Projekt

Obecné

Profil

Stáhnout (13.7 KB) Statistiky
| Větev: | Tag: | Revize:
1 ec939478 Štěpán Červenka
{
2
  "data": [
3 66c042f1 Štěpán Červenka
    {},
4 ec939478 Štěpán Červenka
    {},
5
    {
6
      "transform": [
7
        {
8
          "type": "flatten",
9
          "fields": [
10
            {
11
              "signal": "dataPath"
12
            }
13
          ]
14 e7b16d72 Štěpán Červenka
        }
15
      ]
16
    },
17
    {
18
      "transform": [
19 ec939478 Štěpán Červenka
        {
20 e7b16d72 Štěpán Červenka
          "type": "project",
21
          "fields": [
22 ec939478 Štěpán Červenka
            {
23 e7b16d72 Štěpán Červenka
              "signal": "valuePath"
24 ec939478 Štěpán Červenka
            },
25
            {
26 e7b16d72 Štěpán Červenka
              "signal": "timestampPath"
27
            },
28
            {
29
              "signal": "sensorPath"
30 ec939478 Štěpán Červenka
            }
31 e7b16d72 Štěpán Červenka
          ],
32
          "as": [
33
            "value",
34
            "timestamp",
35 66c042f1 Štěpán Červenka
            "sensor"
36 e7b16d72 Štěpán Červenka
          ]
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 ec939478 Štěpán Červenka
          ]
66
        },
67
        {
68 e7b16d72 Štěpán Červenka
          "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 ec939478 Štěpán Červenka
          ]
88
        },
89
        {
90 e7b16d72 Štěpán Červenka
          "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 ec939478 Štěpán Červenka
          ]
134
        },
135
        {
136 e7b16d72 Štěpán Červenka
          "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 ec939478 Štěpán Červenka
          ]
161
        },
162
        {
163 e7b16d72 Štěpán Červenka
          "type": "lookup",
164
          "from": "tooltipTmp2",
165
          "key": "rank",
166
          "fields": [
167
            "prevRank"
168
          ],
169
          "as": [
170
            "prevObj"
171 ec939478 Štěpán Červenka
          ]
172 e7b16d72 Štěpán Červenka
        },
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 c1664074 Štěpán Červenka
    {},
188
    {},
189 e7b16d72 Štěpán Červenka
    {},
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 ec939478 Štěpán Červenka
        }
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 c1664074 Štěpán Červenka
          "title": "Sensors:",
247 ec939478 Štěpán Červenka
          "offset": 0,
248
          "encode": {
249
            "symbols": {
250
              "update": {
251 e7b16d72 Štěpán Červenka
                "fillOpacity": {
252
                  "value": 0.5
253
                },
254
                "stroke": {
255
                  "value": "transparent"
256
                }
257 ec939478 Štěpán Červenka
              }
258
            }
259
          }
260
        }
261
      ],
262
      "axes": [
263
        {},
264
        {
265
          "orient": "left",
266 66c042f1 Štěpán Červenka
          "scale": "yDetail"
267 ec939478 Štěpán Červenka
        }
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 8cca41c0 Štěpán Červenka
                        "signal": null
374 ec939478 Štěpán Červenka
                      }
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
                        "value": 0
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 e7b16d72 Štěpán Červenka
                    "enter": {
408
                    },
409 ec939478 Štěpán Červenka
                    "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
                        "value": 0
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 e7b16d72 Štěpán Červenka
          "type": "group",
478
          "from": {
479
            "facet": {
480
              "name": "series",
481
              "data": "lookup",
482
              "groupby": "sensor"
483
            }
484
          },
485 ec939478 Štěpán Červenka
          "marks": [
486
            {
487 e7b16d72 Štěpán Červenka
              "type": "symbol",
488 ec939478 Štěpán Červenka
              "from": {
489 e7b16d72 Štěpán Červenka
                "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 ec939478 Štěpán Červenka
                }
518 e7b16d72 Štěpán Červenka
              }
519
            },
520
            {
521
              "type": "rule",
522
              "from": {
523
                "data": "series"
524 ec939478 Štěpán Červenka
              },
525 e7b16d72 Štěpán Červenka
              "encode": {
526
                "update": {
527
                  "x": {
528
                    "scale": "xOverview",
529
                    "field": "dateTime"
530 ec939478 Štěpán Červenka
                  },
531 e7b16d72 Štěpán Červenka
                  "x2": [
532
                    {
533
                      "test": "isValid(datum.obj)",
534
                      "scale": "xOverview",
535
                      "field": "obj.dateTime"
536
                    },
537
                    {
538
                      "scale": "xOverview",
539
                      "field": "dateTime"
540 ec939478 Štěpán Červenka
                    }
541 e7b16d72 Štěpán Červenka
                  ],
542
                  "y": {
543
                    "scale": "yOverview",
544
                    "field": "value"
545 ec939478 Štěpán Červenka
                  },
546 e7b16d72 Štěpán Červenka
                  "y2": [
547
                    {
548
                      "test": "isValid(datum.obj)",
549
                      "scale": "yOverview",
550
                      "field": "obj.value"
551
                    },
552
                    {
553
                      "scale": "yOverview",
554
                      "field": "value"
555 ec939478 Štěpán Červenka
                    }
556 e7b16d72 Štěpán Červenka
                  ],
557
                  "stroke": {
558
                    "scale": "color",
559
                    "field": "sensor"
560
                  },
561
                  "strokeWidth": {
562
                    "value": 1
563 ec939478 Štěpán Červenka
                  }
564
                }
565 e7b16d72 Štěpán Červenka
              }
566 ec939478 Štěpán Červenka
            }
567
          ]
568
        }
569
      ]
570
    }
571
  ]
572
}