1
|
{
|
2
|
"data": [
|
3
|
{},
|
4
|
{},
|
5
|
{},
|
6
|
{},
|
7
|
{
|
8
|
"name": "ranks",
|
9
|
"source": "table",
|
10
|
"transform": [
|
11
|
{
|
12
|
"type": "window",
|
13
|
"sort": {
|
14
|
"field": "dateTime",
|
15
|
"order": "ascending"
|
16
|
},
|
17
|
"ops": [
|
18
|
"rank"
|
19
|
],
|
20
|
"fields": [
|
21
|
"value"
|
22
|
],
|
23
|
"as": [
|
24
|
"rank"
|
25
|
]
|
26
|
},
|
27
|
{
|
28
|
"type": "formula",
|
29
|
"expr": "datum.rank + 1",
|
30
|
"as": "nextRank"
|
31
|
}
|
32
|
]
|
33
|
},
|
34
|
{
|
35
|
"name": "lookup",
|
36
|
"source": "ranks",
|
37
|
"transform": [
|
38
|
{
|
39
|
"type": "lookup",
|
40
|
"from": "table",
|
41
|
"key": "rank",
|
42
|
"fields": [
|
43
|
"nextRank"
|
44
|
],
|
45
|
"as": [
|
46
|
"nextObj"
|
47
|
]
|
48
|
},
|
49
|
{
|
50
|
"type": "lookup",
|
51
|
"from": "table",
|
52
|
"key": "rank",
|
53
|
"fields": [
|
54
|
"prevRank"
|
55
|
],
|
56
|
"as": [
|
57
|
"prevObj"
|
58
|
]
|
59
|
},
|
60
|
{
|
61
|
"type": "formula",
|
62
|
"expr": "(datum.nextObj == null || datum.nextObj.dateTime - datum.dateTime > maxTimeDifference) ? null : datum.nextObj",
|
63
|
"as": "obj"
|
64
|
},
|
65
|
{
|
66
|
"type": "formula",
|
67
|
"expr": "datum.prevObj == null ? data('range')[0].dateMin : (time(datum.prevObj.dateTime) + time(datum.dateTime)) / 2",
|
68
|
"as": "dateStart"
|
69
|
},
|
70
|
{
|
71
|
"type": "formula",
|
72
|
"expr": "datum.nextObj == null ? data('range')[0].dateMax : (time(datum.nextObj.dateTime) + time(datum.dateTime)) / 2",
|
73
|
"as": "dateEnd"
|
74
|
}
|
75
|
]
|
76
|
}
|
77
|
],
|
78
|
|
79
|
"signals": [
|
80
|
{},
|
81
|
{},
|
82
|
{
|
83
|
"name": "tooltipSignal",
|
84
|
"value": {},
|
85
|
"on": [
|
86
|
{
|
87
|
"events": "@tooltip-hitarea:mouseover",
|
88
|
"update": "datum"
|
89
|
},
|
90
|
{
|
91
|
"events": "@tooltip-hitarea:mouseout",
|
92
|
"update": "{}"
|
93
|
}
|
94
|
]
|
95
|
}
|
96
|
],
|
97
|
|
98
|
"marks": [
|
99
|
{
|
100
|
"scales": [
|
101
|
{},
|
102
|
{
|
103
|
"name": "yDetail",
|
104
|
"type": "linear",
|
105
|
"range": [390, 0],
|
106
|
"domain": {
|
107
|
"fields": [
|
108
|
{"data": "range", "field": "valueMax"},
|
109
|
{"data": "table", "field": "value"}
|
110
|
]
|
111
|
},
|
112
|
"nice": true, "zero": true
|
113
|
}
|
114
|
],
|
115
|
"axes": [
|
116
|
{},
|
117
|
{"orient": "left", "scale": "yDetail"}
|
118
|
],
|
119
|
"marks": [
|
120
|
{
|
121
|
"marks": [
|
122
|
{
|
123
|
"name": "tooltip-hitarea",
|
124
|
"type": "rect",
|
125
|
"interactive": true,
|
126
|
"from": {
|
127
|
"data": "lookup"
|
128
|
},
|
129
|
"encode": {
|
130
|
"enter": {
|
131
|
"tooltip": {
|
132
|
"signal": null
|
133
|
}
|
134
|
},
|
135
|
"update": {
|
136
|
"x": {
|
137
|
"scale": "xDetail",
|
138
|
"field": "dateStart"
|
139
|
},
|
140
|
"x2": {
|
141
|
"scale": "xDetail",
|
142
|
"field": "dateEnd"
|
143
|
},
|
144
|
"y": {
|
145
|
"scale": "yDetail",
|
146
|
"band": 1
|
147
|
},
|
148
|
"y2": {
|
149
|
"scale": "yDetail",
|
150
|
"value": 0
|
151
|
},
|
152
|
"fill": {
|
153
|
"value": "#00ff00"
|
154
|
},
|
155
|
"fillOpacity": {
|
156
|
"value": 0.0
|
157
|
}
|
158
|
}
|
159
|
}
|
160
|
},
|
161
|
{
|
162
|
"type": "symbol",
|
163
|
"from": {"data":"lookup"},
|
164
|
"encode": {
|
165
|
"enter": {
|
166
|
"tooltip": {
|
167
|
"signal": "{title: timeFormat(datum.dateTime, '%A, %e. %B %Y, %X') }"
|
168
|
}},
|
169
|
"update": {
|
170
|
"shape": {"value": "circle"},
|
171
|
"size": {"value": 30},
|
172
|
"x": {"scale": "xDetail", "field": "dateTime"},
|
173
|
"y": {"scale": "yDetail", "field": "value"},
|
174
|
"color": {"value": "both"},
|
175
|
"strokeWidth": {"value": 4},
|
176
|
"fill": {"value": "steelblue"}
|
177
|
}
|
178
|
}
|
179
|
},
|
180
|
{
|
181
|
"type": "rule",
|
182
|
"from": {
|
183
|
"data": "lookup"
|
184
|
},
|
185
|
"encode": {
|
186
|
"update": {
|
187
|
"x": {
|
188
|
"scale": "xDetail",
|
189
|
"field": "dateTime"
|
190
|
},
|
191
|
"x2": [
|
192
|
{
|
193
|
"test": "isValid(datum.obj)",
|
194
|
"scale": "xDetail",
|
195
|
"field": "obj.dateTime"
|
196
|
},
|
197
|
{
|
198
|
"scale": "xDetail",
|
199
|
"field": "dateTime"
|
200
|
}
|
201
|
],
|
202
|
"y": {
|
203
|
"scale": "yDetail",
|
204
|
"field": "value"
|
205
|
},
|
206
|
"y2": [
|
207
|
{
|
208
|
"test": "isValid(datum.obj)",
|
209
|
"scale": "yDetail",
|
210
|
"field": "obj.value"
|
211
|
},
|
212
|
{
|
213
|
"scale": "yDetail",
|
214
|
"field": "value"
|
215
|
}
|
216
|
],
|
217
|
"stroke": {
|
218
|
"value": "steelblue"
|
219
|
},
|
220
|
"strokeWidth": {
|
221
|
"value": 1
|
222
|
}
|
223
|
}
|
224
|
}
|
225
|
},
|
226
|
|
227
|
{
|
228
|
"type": "rule",
|
229
|
"interactive": false,
|
230
|
"zindex": 20,
|
231
|
"encode": {
|
232
|
"enter": {
|
233
|
},
|
234
|
"update": {
|
235
|
"x": {
|
236
|
"scale": "xDetail",
|
237
|
"signal": "tooltipSignal.dateTime"
|
238
|
},
|
239
|
"y": {
|
240
|
"scale": "yDetail",
|
241
|
"band": 1
|
242
|
},
|
243
|
"y2": {
|
244
|
"scale": "yDetail",
|
245
|
"value": 0
|
246
|
},
|
247
|
"strokeOpacity": [
|
248
|
{
|
249
|
"test": "tooltipSignal.dateTime > 1",
|
250
|
"value": 1
|
251
|
},
|
252
|
{
|
253
|
"value": 0
|
254
|
}
|
255
|
]
|
256
|
}
|
257
|
}
|
258
|
}
|
259
|
]
|
260
|
}
|
261
|
]
|
262
|
},
|
263
|
{
|
264
|
"signals": [
|
265
|
{
|
266
|
"value": 0,
|
267
|
"on": [
|
268
|
{},
|
269
|
{
|
270
|
"events": "@overview:mousedown",
|
271
|
"update": "[x(), x()]"
|
272
|
},
|
273
|
{
|
274
|
"events": "[@overview:mousedown, window:mouseup] > window:mousemove!",
|
275
|
"update": "[brush[0], clamp(x(), 0, width)]"
|
276
|
}
|
277
|
]
|
278
|
}
|
279
|
],
|
280
|
"marks": [
|
281
|
{},
|
282
|
{},
|
283
|
{},
|
284
|
{
|
285
|
"type": "symbol",
|
286
|
"from": {"data":"table"},
|
287
|
"encode": {
|
288
|
"update": {
|
289
|
"shape": {"value": "circle"},
|
290
|
"size": {"value": 10},
|
291
|
"x": {"scale": "xOverview", "field": "dateTime"},
|
292
|
"y": {"scale": "yOverview", "field": "value"},
|
293
|
"color": {"value": "both"},
|
294
|
"strokeWidth": {"value": 4}
|
295
|
}
|
296
|
}
|
297
|
},
|
298
|
{
|
299
|
"type": "rule",
|
300
|
"from": {
|
301
|
"data": "lookup"
|
302
|
},
|
303
|
"encode": {
|
304
|
"update": {
|
305
|
"x": {
|
306
|
"scale": "xOverview",
|
307
|
"field": "dateTime"
|
308
|
},
|
309
|
"x2": [
|
310
|
{
|
311
|
"test": "isValid(datum.obj)",
|
312
|
"scale": "xOverview",
|
313
|
"field": "obj.dateTime"
|
314
|
},
|
315
|
{
|
316
|
"scale": "xOverview",
|
317
|
"field": "dateTime"
|
318
|
}
|
319
|
],
|
320
|
"y": {
|
321
|
"scale": "yOverview",
|
322
|
"field": "value"
|
323
|
},
|
324
|
"y2": [
|
325
|
{
|
326
|
"test": "isValid(datum.obj)",
|
327
|
"scale": "yOverview",
|
328
|
"field": "obj.value"
|
329
|
},
|
330
|
{
|
331
|
"scale": "yOverview",
|
332
|
"field": "value"
|
333
|
}
|
334
|
],
|
335
|
"stroke": {
|
336
|
"value": "steelblue"
|
337
|
},
|
338
|
"strokeWidth": {
|
339
|
"value": 1
|
340
|
}
|
341
|
}
|
342
|
}
|
343
|
}
|
344
|
]
|
345
|
}
|
346
|
]
|
347
|
}
|