1
|
{
|
2
|
"data": [
|
3
|
{
|
4
|
"name": "source",
|
5
|
"values": null
|
6
|
},
|
7
|
{
|
8
|
"name": "flatten",
|
9
|
"source": "source"
|
10
|
},
|
11
|
{
|
12
|
"name": "table",
|
13
|
"source": "flatten",
|
14
|
"transform": [
|
15
|
{
|
16
|
"type": "project",
|
17
|
"fields": [
|
18
|
{"signal" : "valuePath"},
|
19
|
{"signal": "timestampPath"}
|
20
|
|
21
|
],
|
22
|
"as": [
|
23
|
"value",
|
24
|
"timestamp"
|
25
|
]
|
26
|
},
|
27
|
{
|
28
|
"type": "formula",
|
29
|
"expr": "utcParse(datum.timestamp, '%Y-%m-%d %H:%M:%S%Z')",
|
30
|
"as": "dateTime"
|
31
|
}
|
32
|
]
|
33
|
},
|
34
|
{
|
35
|
"name": "range",
|
36
|
"source": "table",
|
37
|
"transform": [
|
38
|
{
|
39
|
"type": "aggregate",
|
40
|
"fields": ["dateTime", "dateTime", "value"],
|
41
|
"ops": ["min", "max", "max"],
|
42
|
"as": ["dateMinTemp", "dateMaxTemp", "maxValueTemp"]
|
43
|
},
|
44
|
{
|
45
|
"type": "formula",
|
46
|
"expr":"time(datum[\"dateMinTemp\"]) - (timeStep * 500)",
|
47
|
"as": "dateMin"
|
48
|
},
|
49
|
{
|
50
|
"type": "formula",
|
51
|
"expr":"time(datum[\"dateMaxTemp\"]) + (timeStep * 500)",
|
52
|
"as": "dateMax"
|
53
|
},
|
54
|
{
|
55
|
"type": "formula",
|
56
|
"expr": "datum[\"maxValueTemp\"] * 1.05",
|
57
|
"as": "valueMax"
|
58
|
}
|
59
|
]
|
60
|
}
|
61
|
],
|
62
|
|
63
|
"signals": [
|
64
|
{
|
65
|
"name": "timeStep",
|
66
|
"value": null
|
67
|
},
|
68
|
{
|
69
|
"name": "detailDomain"
|
70
|
}
|
71
|
|
72
|
],
|
73
|
|
74
|
"marks": [
|
75
|
{
|
76
|
"type": "group",
|
77
|
"name": "detail",
|
78
|
"encode": {
|
79
|
"enter": {
|
80
|
"height": {"signal": "detailHeight"},
|
81
|
"width": {"signal": "width"}
|
82
|
}
|
83
|
},
|
84
|
|
85
|
"scales": [
|
86
|
{
|
87
|
"name": "xDetail",
|
88
|
"type": "time",
|
89
|
"range": "width",
|
90
|
"domain": {"data": "table", "field": "dateTime"},
|
91
|
"domainRaw": {"signal": "detailDomain"}
|
92
|
}
|
93
|
],
|
94
|
"axes": [
|
95
|
{"orient": "bottom", "scale": "xDetail"}
|
96
|
],
|
97
|
"marks": [
|
98
|
{
|
99
|
"type": "group",
|
100
|
"encode": {
|
101
|
"enter": {
|
102
|
"height": {
|
103
|
"field": {
|
104
|
"group": "height"
|
105
|
}
|
106
|
},
|
107
|
"width": {
|
108
|
"field": {
|
109
|
"group": "width"
|
110
|
}
|
111
|
},
|
112
|
"clip": {
|
113
|
"value": true
|
114
|
}
|
115
|
}
|
116
|
}
|
117
|
}
|
118
|
]
|
119
|
},
|
120
|
|
121
|
{
|
122
|
"type": "group",
|
123
|
"name": "overview",
|
124
|
"encode": {
|
125
|
"enter": {
|
126
|
"x": {"value": 0},
|
127
|
"y": {"value": 430},
|
128
|
"height": {"value": 70},
|
129
|
"width": {"value": 720},
|
130
|
"fill": {"value": "transparent"}
|
131
|
}
|
132
|
},
|
133
|
"signals": [
|
134
|
{
|
135
|
"name": "brush",
|
136
|
"on": [
|
137
|
{
|
138
|
"events": {"signal": "delta"},
|
139
|
"update": "clampRange([anchor[0] + delta, anchor[1] + delta], 0, width)"
|
140
|
}
|
141
|
]
|
142
|
},
|
143
|
{
|
144
|
"name": "anchor", "value": null,
|
145
|
"on": [{"events": "@brush:mousedown", "update": "slice(brush)"}]
|
146
|
},
|
147
|
{
|
148
|
"name": "xdown", "value": 0,
|
149
|
"on": [{"events": "@brush:mousedown", "update": "x()"}]
|
150
|
},
|
151
|
{
|
152
|
"name": "delta", "value": 0,
|
153
|
"on": [
|
154
|
{
|
155
|
"events": "[@brush:mousedown, window:mouseup] > window:mousemove!",
|
156
|
"update": "x() - xdown"
|
157
|
}
|
158
|
]
|
159
|
},
|
160
|
{
|
161
|
"name": "detailDomain",
|
162
|
"push": "outer",
|
163
|
"on": [
|
164
|
{
|
165
|
"events": {"signal": "brush"},
|
166
|
"update": "span(brush) ? invert('xOverview', brush) : null"
|
167
|
}
|
168
|
]
|
169
|
}
|
170
|
],
|
171
|
"scales": [
|
172
|
{
|
173
|
"name": "xOverview",
|
174
|
"type": "time",
|
175
|
"range": "width",
|
176
|
"domain": {"data": "range", "fields": ["dateMin", "dateMax"]}
|
177
|
},
|
178
|
{
|
179
|
"name": "yOverview",
|
180
|
"type": "linear",
|
181
|
"range": [70, 0],
|
182
|
"domain": {"data": "table", "field": "value"},
|
183
|
"nice": true, "zero": true
|
184
|
}
|
185
|
],
|
186
|
"axes": [
|
187
|
{"orient": "bottom", "scale": "xOverview"}
|
188
|
],
|
189
|
"marks": [
|
190
|
{
|
191
|
"type": "rect",
|
192
|
"name": "brush",
|
193
|
"encode": {
|
194
|
"enter": {
|
195
|
"y": {"value": 0},
|
196
|
"height": {"value": 70},
|
197
|
"fill": {"value": "#333"},
|
198
|
"fillOpacity": {"value": 0.2}
|
199
|
},
|
200
|
"update": {
|
201
|
"x": {"signal": "brush[0]"},
|
202
|
"x2": {"signal": "brush[1]"}
|
203
|
}
|
204
|
}
|
205
|
},
|
206
|
{
|
207
|
"type": "rect",
|
208
|
"interactive": false,
|
209
|
"encode": {
|
210
|
"enter": {
|
211
|
"y": {"value": 0},
|
212
|
"height": {"value": 70},
|
213
|
"width": {"value": 1},
|
214
|
"fill": {"value": "firebrick"}
|
215
|
},
|
216
|
"update": {
|
217
|
"x": {"signal": "brush[0]"}
|
218
|
}
|
219
|
}
|
220
|
},
|
221
|
{
|
222
|
"type": "rect",
|
223
|
"interactive": false,
|
224
|
"encode": {
|
225
|
"enter": {
|
226
|
"y": {"value": 0},
|
227
|
"height": {"value": 70},
|
228
|
"width": {"value": 1},
|
229
|
"fill": {"value": "firebrick"}
|
230
|
},
|
231
|
"update": {
|
232
|
"x": {"signal": "brush[1]"}
|
233
|
}
|
234
|
}
|
235
|
}
|
236
|
]
|
237
|
}
|
238
|
]
|
239
|
}
|
240
|
|
241
|
|
242
|
|