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