Projekt

Obecné

Profil

Stáhnout (8.65 KB) Statistiky
| Větev: | Tag: | Revize:
1
{
2
  "data": [
3
    {},
4
    {},
5
    {},
6
    {},
7
    {},
8
    {
9
      "name": "ranks",
10
      "source": "table",
11
      "transform": [
12
        {
13
          "type": "window",
14
          "sort": {
15
            "field": "dateTime",
16
            "order": "ascending"
17
          },
18
          "ops": [
19
            "rank"
20
          ],
21
          "fields": [
22
            "value"
23
          ],
24
          "as": [
25
            "rank"
26
          ]
27
        },
28
        {
29
          "type": "formula",
30
          "expr": "datum.rank + 1",
31
          "as": "nextRank"
32
        },
33
        {
34
          "type": "formula",
35
          "expr": "datum.rank - 1",
36
          "as": "prevRank"
37
        }
38
      ]
39
    },
40
    {
41
      "name": "lookup",
42
      "source": "ranks",
43
      "transform": [
44
        {
45
          "type": "lookup",
46
          "from": "ranks",
47
          "key": "rank",
48
          "fields": [
49
            "nextRank"
50
          ],
51
          "as": [
52
            "nextObj"
53
          ]
54
        },
55
        {
56
          "type": "lookup",
57
          "from": "ranks",
58
          "key": "rank",
59
          "fields": [
60
            "prevRank"
61
          ],
62
          "as": [
63
            "prevObj"
64
          ]
65
        },
66
        {
67
          "type": "formula",
68
          "expr": "(datum.nextObj == null || datum.nextObj.dateTime - datum.dateTime > maxTimeDifference) ? null : datum.nextObj",
69
          "as": "obj"
70
        },
71
        {
72
          "type": "formula",
73
          "expr": "datum.prevObj == null ?  data('range')[0].dateMin : (time(datum.prevObj.dateTime) + time(datum.dateTime)) / 2",
74
          "as": "dateStart"
75
        },
76
        {
77
          "type": "formula",
78
          "expr": "datum.nextObj == null ?  data('range')[0].dateMax : (time(datum.nextObj.dateTime) + time(datum.dateTime)) / 2",
79
          "as": "dateEnd"
80
        }
81
      ]
82
    }
83
  ],
84

    
85
  "signals": [
86
    {},
87
    {
88
      "name": "tooltipSignal",
89
      "value": {},
90
      "on": [
91
        {
92
          "events": "@tooltip-hitarea:mouseover",
93
          "update": "datum"
94
        },
95
        {
96
          "events": "@tooltip-hitarea:mouseout",
97
          "update": "{}"
98
        }
99
      ]
100
    }
101
  ],
102

    
103
  "marks": [
104
    {
105
      "scales": [
106
        {},
107
        {
108
          "name": "yDetail",
109
          "type": "linear",
110
          "range": [390, 0],
111
          "domain": {
112
            "fields": [
113
              {"data": "range", "field": "valueMax"},
114
              {"data":  "table", "field": "value"}
115
            ]
116
          },
117
          "nice": true, "zero": true
118
        }
119
      ],
120
      "axes": [
121
        {},
122
        {"orient": "left", "scale": "yDetail"}
123
      ],
124
      "marks": [
125
        {
126
          "marks": [
127
            {
128
              "name": "tooltip-hitarea",
129
              "type": "rect",
130
              "interactive": true,
131
              "from": {
132
                "data": "lookup"
133
              },
134
              "encode": {
135
                "enter": {
136
                  "tooltip": {
137
                    "signal": null
138
                  }
139
                },
140
                "update": {
141
                  "x": {
142
                    "scale": "xDetail",
143
                    "field": "dateStart"
144
                  },
145
                  "x2": {
146
                    "scale": "xDetail",
147
                    "field": "dateEnd"
148
                  },
149
                  "y": {
150
                    "scale": "yDetail",
151
                    "band": 1
152
                  },
153
                  "y2": {
154
                    "scale": "yDetail",
155
                    "value": 0
156
                  },
157
                  "fill": {
158
                    "value": "#00ff00"
159
                  },
160
                  "fillOpacity": {
161
                    "value": 0.0
162
                  }
163
                }
164
              }
165
            },
166
            {
167
              "type": "symbol",
168
              "from": {"data":"lookup"},
169
              "encode": {
170
                "enter": {
171
                  "tooltip": {
172
                    "signal": "{title: timeFormat(datum.dateTime, '%A, %e. %B %Y, %X') }"
173
                  }},
174
                "update": {
175
                  "shape": {"value": "circle"},
176
                  "size": {"value": 30},
177
                  "x": {"scale": "xDetail", "field": "dateTime"},
178
                  "y": {"scale": "yDetail", "field": "value"},
179
                  "color": {"value": "both"},
180
                  "strokeWidth": {"value": 4},
181
                  "fill": {"value": "steelblue"}
182
                }
183
              }
184
            },
185
            {
186
              "type": "rule",
187
              "from": {
188
                "data": "lookup"
189
              },
190
              "encode": {
191
                "update": {
192
                  "x": {
193
                    "scale": "xDetail",
194
                    "field": "dateTime"
195
                  },
196
                  "x2": [
197
                    {
198
                      "test": "isValid(datum.obj)",
199
                      "scale": "xDetail",
200
                      "field": "obj.dateTime"
201
                    },
202
                    {
203
                      "scale": "xDetail",
204
                      "field": "dateTime"
205
                    }
206
                  ],
207
                  "y": {
208
                    "scale": "yDetail",
209
                    "field": "value"
210
                  },
211
                  "y2": [
212
                    {
213
                      "test": "isValid(datum.obj)",
214
                      "scale": "yDetail",
215
                      "field": "obj.value"
216
                    },
217
                    {
218
                      "scale": "yDetail",
219
                      "field": "value"
220
                    }
221
                  ],
222
                  "stroke": {
223
                    "value": "steelblue"
224
                  },
225
                  "strokeWidth": {
226
                    "value": 1
227
                  }
228
                }
229
              }
230
            },
231

    
232
            {
233
              "type": "rule",
234
              "interactive": false,
235
              "zindex": 20,
236
              "encode": {
237
                "enter": {
238
                },
239
                "update": {
240
                  "x": {
241
                    "scale": "xDetail",
242
                    "signal": "tooltipSignal.dateTime"
243
                  },
244
                  "y": {
245
                    "scale": "yDetail",
246
                    "band": 1
247
                  },
248
                  "y2": {
249
                    "scale": "yDetail",
250
                    "value": 0
251
                  },
252
                  "strokeOpacity": [
253
                    {
254
                      "test": "tooltipSignal.dateTime > 1",
255
                      "value": 1
256
                    },
257
                    {
258
                      "value": 0
259
                    }
260
                  ]
261
                }
262
              }
263
            }
264
          ]
265
        }
266
      ]
267
    },
268
    {
269
      "signals": [
270
        {
271
          "value": 0,
272
          "on": [
273
            {},
274
            {
275
              "events": "@overview:mousedown",
276
              "update": "[x(), x()]"
277
            },
278
            {
279
              "events": "[@overview:mousedown, window:mouseup] > window:mousemove!",
280
              "update": "[brush[0], clamp(x(), 0, width)]"
281
            }
282
          ]
283
        }
284
      ],
285
      "marks": [
286
        {},
287
        {},
288
        {},
289
        {
290
          "type": "symbol",
291
          "from": {"data":"table"},
292
          "encode": {
293
            "update": {
294
              "shape": {"value": "circle"},
295
              "size": {"value": 10},
296
              "x": {"scale": "xOverview", "field": "dateTime"},
297
              "y": {"scale": "yOverview", "field": "value"},
298
              "color": {"value": "both"},
299
              "strokeWidth": {"value": 4}
300
            }
301
          }
302
        },
303
        {
304
          "type": "rule",
305
          "from": {
306
            "data": "lookup"
307
          },
308
          "encode": {
309
            "update": {
310
              "x": {
311
                "scale": "xOverview",
312
                "field": "dateTime"
313
              },
314
              "x2": [
315
                {
316
                  "test": "isValid(datum.obj)",
317
                  "scale": "xOverview",
318
                  "field": "obj.dateTime"
319
                },
320
                {
321
                  "scale": "xOverview",
322
                  "field": "dateTime"
323
                }
324
              ],
325
              "y": {
326
                "scale": "yOverview",
327
                "field": "value"
328
              },
329
              "y2": [
330
                {
331
                  "test": "isValid(datum.obj)",
332
                  "scale": "yOverview",
333
                  "field": "obj.value"
334
                },
335
                {
336
                  "scale": "yOverview",
337
                  "field": "value"
338
                }
339
              ],
340
              "stroke": {
341
                "value": "steelblue"
342
              },
343
              "strokeWidth": {
344
                "value": 1
345
              }
346
            }
347
          }
348
        }
349
      ]
350
    }
351
  ]
352
}
(2-2/4)