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
|
{},
|
89
|
{
|
90
|
"name": "tooltipSignal",
|
91
|
"value": {},
|
92
|
"on": [
|
93
|
{
|
94
|
"events": "@tooltip-hitarea:mouseover",
|
95
|
"update": "datum"
|
96
|
},
|
97
|
{
|
98
|
"events": "@tooltip-hitarea:mouseout",
|
99
|
"update": "{}"
|
100
|
}
|
101
|
]
|
102
|
}
|
103
|
],
|
104
|
|
105
|
"marks": [
|
106
|
{
|
107
|
"scales": [
|
108
|
{},
|
109
|
{
|
110
|
"name": "yDetail",
|
111
|
"type": "linear",
|
112
|
"range": [390, 0],
|
113
|
"domain": {
|
114
|
"fields": [
|
115
|
{"data": "range", "field": "valueMax"},
|
116
|
{"data": "table", "field": "value"}
|
117
|
]
|
118
|
},
|
119
|
"nice": true, "zero": true
|
120
|
}
|
121
|
],
|
122
|
"axes": [
|
123
|
{},
|
124
|
{"orient": "left", "scale": "yDetail"}
|
125
|
],
|
126
|
"marks": [
|
127
|
{
|
128
|
"marks": [
|
129
|
{
|
130
|
"name": "tooltip-hitarea",
|
131
|
"type": "rect",
|
132
|
"interactive": true,
|
133
|
"from": {
|
134
|
"data": "lookup"
|
135
|
},
|
136
|
"encode": {
|
137
|
"enter": {
|
138
|
"tooltip": {
|
139
|
"signal": null
|
140
|
}
|
141
|
},
|
142
|
"update": {
|
143
|
"x": {
|
144
|
"scale": "xDetail",
|
145
|
"field": "dateStart"
|
146
|
},
|
147
|
"x2": {
|
148
|
"scale": "xDetail",
|
149
|
"field": "dateEnd"
|
150
|
},
|
151
|
"y": {
|
152
|
"scale": "yDetail",
|
153
|
"band": 1
|
154
|
},
|
155
|
"y2": {
|
156
|
"scale": "yDetail",
|
157
|
"value": 0
|
158
|
},
|
159
|
"fill": {
|
160
|
"value": "#00ff00"
|
161
|
},
|
162
|
"fillOpacity": {
|
163
|
"value": 0.0
|
164
|
}
|
165
|
}
|
166
|
}
|
167
|
},
|
168
|
{
|
169
|
"type": "symbol",
|
170
|
"from": {"data":"lookup"},
|
171
|
"encode": {
|
172
|
"update": {
|
173
|
"shape": {"value": "circle"},
|
174
|
"size": {"value": 30},
|
175
|
"x": {"scale": "xDetail", "field": "dateTime"},
|
176
|
"y": {"scale": "yDetail", "field": "value"},
|
177
|
"color": {"value": "both"},
|
178
|
"strokeWidth": {"value": 4},
|
179
|
"fill": {"value": "steelblue"}
|
180
|
}
|
181
|
}
|
182
|
},
|
183
|
{
|
184
|
"type": "rule",
|
185
|
"from": {
|
186
|
"data": "lookup"
|
187
|
},
|
188
|
"encode": {
|
189
|
"update": {
|
190
|
"x": {
|
191
|
"scale": "xDetail",
|
192
|
"field": "dateTime"
|
193
|
},
|
194
|
"x2": [
|
195
|
{
|
196
|
"test": "isValid(datum.obj)",
|
197
|
"scale": "xDetail",
|
198
|
"field": "obj.dateTime"
|
199
|
},
|
200
|
{
|
201
|
"scale": "xDetail",
|
202
|
"field": "dateTime"
|
203
|
}
|
204
|
],
|
205
|
"y": {
|
206
|
"scale": "yDetail",
|
207
|
"field": "value"
|
208
|
},
|
209
|
"y2": [
|
210
|
{
|
211
|
"test": "isValid(datum.obj)",
|
212
|
"scale": "yDetail",
|
213
|
"field": "obj.value"
|
214
|
},
|
215
|
{
|
216
|
"scale": "yDetail",
|
217
|
"field": "value"
|
218
|
}
|
219
|
],
|
220
|
"stroke": {
|
221
|
"value": "steelblue"
|
222
|
},
|
223
|
"strokeWidth": {
|
224
|
"value": 1
|
225
|
}
|
226
|
}
|
227
|
}
|
228
|
},
|
229
|
|
230
|
{
|
231
|
"type": "rule",
|
232
|
"interactive": false,
|
233
|
"zindex": 20,
|
234
|
"encode": {
|
235
|
"update": {
|
236
|
"x": {
|
237
|
"scale": "xDetail",
|
238
|
"signal": "tooltipSignal.dateTime"
|
239
|
},
|
240
|
"y": {
|
241
|
"scale": "yDetail",
|
242
|
"value": 1000000
|
243
|
},
|
244
|
"y2": {
|
245
|
"scale": "yDetail",
|
246
|
"value": -1000000
|
247
|
},
|
248
|
"strokeOpacity": [
|
249
|
{
|
250
|
"test": "tooltipSignal.dateTime > 1",
|
251
|
"value": 1
|
252
|
},
|
253
|
{
|
254
|
"value": 0
|
255
|
}
|
256
|
]
|
257
|
}
|
258
|
}
|
259
|
}
|
260
|
]
|
261
|
}
|
262
|
]
|
263
|
},
|
264
|
{
|
265
|
"signals": [
|
266
|
{
|
267
|
"value": 0,
|
268
|
"on": [
|
269
|
{},
|
270
|
{
|
271
|
"events": "@overview:mousedown",
|
272
|
"update": "[x(), x()]"
|
273
|
},
|
274
|
{
|
275
|
"events": "[@overview:mousedown, window:mouseup] > window:mousemove!",
|
276
|
"update": "[brush[0], clamp(x(), 0, width)]"
|
277
|
}
|
278
|
]
|
279
|
}
|
280
|
],
|
281
|
"marks": [
|
282
|
{},
|
283
|
{},
|
284
|
{},
|
285
|
{
|
286
|
"type": "symbol",
|
287
|
"from": {"data":"table"},
|
288
|
"encode": {
|
289
|
"update": {
|
290
|
"shape": {"value": "circle"},
|
291
|
"size": {"value": 10},
|
292
|
"x": {"scale": "xOverview", "field": "dateTime"},
|
293
|
"y": {"scale": "yOverview", "field": "value"},
|
294
|
"color": {"value": "both"},
|
295
|
"strokeWidth": {"value": 4}
|
296
|
}
|
297
|
}
|
298
|
},
|
299
|
{
|
300
|
"type": "rule",
|
301
|
"from": {
|
302
|
"data": "lookup"
|
303
|
},
|
304
|
"encode": {
|
305
|
"update": {
|
306
|
"x": {
|
307
|
"scale": "xOverview",
|
308
|
"field": "dateTime"
|
309
|
},
|
310
|
"x2": [
|
311
|
{
|
312
|
"test": "isValid(datum.obj)",
|
313
|
"scale": "xOverview",
|
314
|
"field": "obj.dateTime"
|
315
|
},
|
316
|
{
|
317
|
"scale": "xOverview",
|
318
|
"field": "dateTime"
|
319
|
}
|
320
|
],
|
321
|
"y": {
|
322
|
"scale": "yOverview",
|
323
|
"field": "value"
|
324
|
},
|
325
|
"y2": [
|
326
|
{
|
327
|
"test": "isValid(datum.obj)",
|
328
|
"scale": "yOverview",
|
329
|
"field": "obj.value"
|
330
|
},
|
331
|
{
|
332
|
"scale": "yOverview",
|
333
|
"field": "value"
|
334
|
}
|
335
|
],
|
336
|
"stroke": {
|
337
|
"value": "steelblue"
|
338
|
},
|
339
|
"strokeWidth": {
|
340
|
"value": 1
|
341
|
}
|
342
|
}
|
343
|
}
|
344
|
}
|
345
|
]
|
346
|
}
|
347
|
]
|
348
|
}
|