Projekt

Obecné

Profil

Stáhnout (5.99 KB) Statistiky
| Větev: | Tag: | Revize:
1
{
2
  "$schema": "https://vega.github.io/schema/vega/v5.json",
3
  "width": 720,
4
  "height": 200,
5
  "padding": 5,
6

    
7

    
8

    
9
  "data": [
10
    {
11
      "name": "table",
12
      "values": null,
13
      "transform": [
14
        {
15
          "type": "formula",
16
          "expr": "toDate(datum[\"timestamp\"])",
17
          "as": "dateTime"
18
        }]
19

    
20
    },
21
    {
22
      "name": "table2",
23
      "source": "table",
24
      "transform": [
25
        {
26
          "type": "aggregate",
27
          "fields": ["dateTime", "dateTime"],
28
          "ops": ["min", "max"],
29
          "as": ["dateMinTemp", "dateMaxTemp"]
30
        },
31
        {
32
          "type": "formula",
33
          "expr":"time(datum[\"dateMinTemp\"] - (timeStep * 1000))",
34
          "as": "dateMin"
35
        },
36
        {
37
          "type": "formula",
38
          "expr":"time(datum[\"dateMaxTemp\"] + (timeStep * 1000))",
39
          "as": "dateMax"
40
        },
41
        {
42
          "type": "formula",
43
          "expr":"time(datum[\"dateMax\"]) - time(datum[\"dateMin\"])",
44
          "as": "range"
45
        }
46
      ]
47
    }
48
  ],
49

    
50
  "signals": [
51
    {
52
      "name": "timeStep",
53
      "value": null
54
    },
55
    {
56
      "name": "arrowCount",
57
      "value": 25
58
    },
59
    {
60
      "name": "selectionWidth",
61
      "update": "floor((arrowCount * (timeStep * 1000) * width) / data('table2')[0].range)"
62
    },
63
    {
64
      "name": "detailDomain",
65
      "update": "[time(data('table2')[0].dateMin), time(data('table2')[0].dateMin) + ((timeStep * 1000) * arrowCount)] "
66
    }
67
  ],
68

    
69
  "marks": [
70
    {
71
      "type": "group",
72
      "name": "detail",
73
      "encode": {
74
        "enter": {
75
          "height": {"value": 60},
76
          "width": {"value": 720}
77
        }
78
      },
79
      "scales": [
80
        {
81
          "name": "xDetail",
82
          "type": "time",
83
          "range": "width",
84
          "domain": {"signal": "detailDomain"}
85
        }
86
      ],
87
      "axes": [
88
        {"orient": "bottom", "scale": "xDetail"}
89
      ],
90
      "marks": [
91
        {
92
          "type": "group",
93
          "encode": {
94
            "enter": {
95
              "height": {"field": {"group": "height"}},
96
              "width": {"field": {"group": "width"}},
97
              "clip": {"value": true}
98
            }
99
          },
100
          "marks": [
101
            {
102
              "type": "symbol",
103
              "from": {"data": "table"},
104
              "encode": {
105
                "enter": {
106
                  "tooltip": {
107
                    "signal": "{title: timeFormat(datum.dateTime, '%B %d, %Y %H:%M') , 'avg': datum.avg, 'sum': datum.sum, 'max': datum.max, 'min': datum.min}"
108
                  }
109
                },
110
                "hover": { "fill": {"value": "red"} },
111
                "update": {
112
                  "shape": {"value": "arrow"},
113
                  "size": {"value": 500},
114
                  "x": {"scale": "xDetail", "field": "dateTime"},
115
                  "y": {"value":30},
116
                  "angle":{"field": "avg"},
117
                  "color": {"value": "both"},
118
                  "strokeWidth": {"value": 1},
119
                  "fill": {"value": "steelblue"}
120

    
121
                }
122

    
123
              }
124
            }
125
          ]
126
        }
127
      ]
128
    },
129

    
130
    {
131
      "type": "group",
132
      "name": "overview",
133
      "encode": {
134
        "enter": {
135
          "x": {"value": 0},
136
          "y": {"value": 100},
137
          "height": {"value": 70},
138
          "width": {"value": 720},
139
          "fill": {"value": "transparent"}
140
        }
141
      },
142
      "signals": [
143
        {
144
          "name": "brush",
145
          "update": "[0,selectionWidth]",
146
          "on": [
147
            {
148
              "events": {"signal": "delta"},
149
              "update": "clampRange([anchor[0] + delta, anchor[1] + delta], 0, width)"
150
            }
151

    
152
          ]
153
        },
154
        {
155
          "name": "anchor", "value": null,
156
          "on": [{"events": "@brush:mousedown", "update": "slice(brush)"}]
157
        },
158
        {
159
          "name": "xdown", "value": 0,
160
          "on": [{"events": "@brush:mousedown", "update": "x()"}]
161
        },
162
        {
163
          "name": "delta", "value": 0,
164
          "on": [
165
            {
166
              "events": "[@brush:mousedown, window:mouseup] > window:mousemove!",
167
              "update": "x() - xdown"
168
            }
169
          ]
170
        },
171
        {
172
          "name": "detailDomain",
173
          "push": "outer",
174
          "on": [
175
            {
176
              "events": {"signal": "brush"},
177
              "update": "invert('xOverview', brush)"
178
            }
179
          ]
180
        }],
181
      "scales": [
182
        {
183
          "name": "xOverview",
184
          "type": "time",
185
          "range": "width",
186
          "domain": {"data": "table2", "fields": ["dateMin", "dateMax"]}
187
        },
188
        {
189
          "name": "yOverview",
190
          "type": "linear",
191
          "range": [70, 0],
192
          "nice": true, "zero": true
193
        }
194
      ],
195
      "axes": [
196
        {"orient": "bottom", "scale": "xOverview"}
197
      ],
198
      "marks": [
199

    
200
        {
201
          "type": "rect",
202
          "name": "brush",
203
          "encode": {
204
            "enter": {
205
              "y": {"value": 0},
206
              "height": {"value": 70},
207
              "fill": {"value": "#333"},
208
              "fillOpacity": {"value": 0.2}
209
            },
210
            "update": {
211
              "x": {"signal": "brush[0]"},
212
              "x2": {"signal": "brush[1]"}
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[0]"}
228
            }
229
          }
230
        },
231
        {
232
          "type": "rect",
233
          "interactive": false,
234
          "encode": {
235
            "enter": {
236
              "y": {"value": 0},
237
              "height": {"value": 70},
238
              "width": {"value": 1},
239
              "fill": {"value": "firebrick"}
240
            },
241
            "update": {
242
              "x": {"signal": "brush[1]"}
243
            }
244
          }
245
        }
246

    
247

    
248
      ]
249
    }
250

    
251

    
252

    
253

    
254

    
255

    
256
  ]
257
}
(3-3/7)