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