Projekt

Obecné

Profil

Stáhnout (5.59 KB) Statistiky
| Větev: | Tag: | Revize:
1
{
2
  "data": [
3
    {
4
      "name": "legend",
5
      "values": null
6
    },
7
    {
8
      "name": "source",
9
      "values": null
10
    },
11
    {
12
      "name": "flatten",
13
      "source": "source"
14
    },
15
    {
16
      "name": "table",
17
      "source": "flatten",
18
      "transform": [
19
        {
20
          "type": "project",
21
          "fields": [
22
            {"signal" :  "valuePath"},
23
            {"signal":  "timestampPath"}
24

    
25
          ],
26
          "as": [
27
            "value",
28
            "timestamp"
29
          ]
30
        },
31
        {
32
          "type": "formula",
33
          "expr": "utcParse(datum.timestamp, '%Y-%m-%d %H:%M:%S%Z')",
34
          "as": "dateTime"
35
        }
36
      ]
37
    },
38
    {
39
      "name": "range",
40
      "source": "table",
41
      "transform": [
42
        {
43
          "type": "aggregate",
44
          "fields": ["dateTime", "dateTime", "value"],
45
          "ops": ["min", "max", "max"],
46
          "as": ["dateMinTemp", "dateMaxTemp", "maxValueTemp"]
47
        },
48
        {
49
          "type": "formula",
50
          "expr":"time(datum[\"dateMinTemp\"]) - timeWindow",
51
          "as": "dateMin"
52
        },
53
        {
54
          "type": "formula",
55
          "expr":"time(datum[\"dateMaxTemp\"]) + timeWindow",
56
          "as": "dateMax"
57
        },
58
        {
59
          "type": "formula",
60
          "expr": "datum[\"maxValueTemp\"] * 1.05",
61
          "as": "valueMax"
62
        }
63
      ]
64
    }
65
  ],
66

    
67
  "signals": [
68

    
69
    {
70
      "name": "timeWindow",
71
      "value": null
72
    },
73
    {
74
      "name":  "maxTimeDifference",
75
      "update": "timeWindow * 5"
76
    },
77
    {
78
      "name": "detailDomain"
79
    }
80

    
81
  ],
82

    
83
  "marks": [
84
    {
85
      "type": "group",
86
      "name": "detail",
87
      "encode": {
88
        "enter": {
89
          "height": {"signal": "detailHeight"},
90
          "width": {"signal": "width"}
91
        }
92
      },
93

    
94
      "scales": [
95
        {
96
          "name": "xDetail",
97
          "type": "time",
98
          "range": "width",
99
          "domain": {
100
          "data": "range",
101
          "fields": [
102
            "dateMin",
103
            "dateMax"
104
          ]
105
        },
106
          "domainRaw": {"signal": "detailDomain"}
107
        }
108
      ],
109
      "axes": [
110
        {"orient": "bottom", "scale": "xDetail"}
111
      ],
112
      "marks": [
113
        {
114
          "type": "group",
115
          "encode": {
116
            "enter": {
117
              "height": {
118
                "field": {
119
                  "group": "height"
120
                }
121
              },
122
              "width": {
123
                "field": {
124
                  "group": "width"
125
                }
126
              },
127
              "clip": {
128
                "value": true
129
              }
130
            }
131
          }
132
        }
133
      ]
134
    },
135

    
136
    {
137
      "type": "group",
138
      "name": "overview",
139
      "encode": {
140
        "enter": {
141
          "x": {"value": 0},
142
          "y": {"signal":  "overviewHeightStart"},
143
          "height": {"signal": "overviewHeight"},
144
          "width": {"signal":  "width"},
145
          "fill": {"value": "transparent"}
146
        }
147
      },
148
      "signals": [
149
        {
150
          "name": "brush",
151
          "on": [
152
            {
153
              "events": {"signal": "delta"},
154
              "update": "clampRange([anchor[0] + delta, anchor[1] + delta], 0, width)"
155
            }
156
          ]
157
        },
158
        {
159
          "name": "anchor", "value": null,
160
          "on": [{"events": "@brush:mousedown", "update": "slice(brush)"}]
161
        },
162
        {
163
          "name": "xdown", "value": 0,
164
          "on": [{"events": "@brush:mousedown", "update": "x()"}]
165
        },
166
        {
167
          "name": "delta", "value": 0,
168
          "on": [
169
            {
170
              "events": "[@brush:mousedown, window:mouseup] > window:mousemove!",
171
              "update": "x() - xdown"
172
            }
173
          ]
174
        },
175
        {
176
          "name": "detailDomain",
177
          "push": "outer",
178
          "on": [
179
            {
180
              "events": {"signal": "brush"},
181
              "update": "span(brush) ? invert('xOverview', brush) : null"
182
            }
183
          ]
184
        }
185
      ],
186
      "scales": [
187
        {
188
          "name": "xOverview",
189
          "type": "time",
190
          "range": "width",
191
          "domain": {"data": "range", "fields": ["dateMin", "dateMax"]}
192
        },
193
        {
194
          "name": "yOverview",
195
          "type": "linear",
196
          "range": [70, 0],
197
          "domain": {"data": "table", "field": "value"},
198
          "nice": true, "zero": true
199
        }
200
      ],
201
      "axes": [
202
        {"orient": "bottom", "scale": "xOverview"}
203
      ],
204
      "marks": [
205
        {
206
          "type": "rect",
207
          "name": "brush",
208
          "encode": {
209
            "enter": {
210
              "y": {"value": 0},
211
              "height": {"value": 70},
212
              "fill": {"value": "#333"},
213
              "fillOpacity": {"value": 0.2}
214
            },
215
            "update": {
216
              "x": {"signal": "brush[0]"},
217
              "x2": {"signal": "brush[1]"}
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[0]"}
233
            }
234
          }
235
        },
236
        {
237
          "type": "rect",
238
          "interactive": false,
239
          "encode": {
240
            "enter": {
241
              "y": {"value": 0},
242
              "height": {"value": 70},
243
              "width": {"value": 1},
244
              "fill": {"value": "firebrick"}
245
            },
246
            "update": {
247
              "x": {"signal": "brush[1]"}
248
            }
249
          }
250
        }
251
      ]
252
    }
253
  ]
254
}
255

    
256

    
257

    
(1-1/2)