Projekt

Obecné

Profil

Stáhnout (6.31 KB) Statistiky
| Větev: | Tag: | Revize:
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
      "values": null,
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", "minutes", "seconds"],
21
          "step": {"signal": "timeStep"}
22
        },
23
        {
24
          "type": "formula",
25
          "expr": "time(datum[\"unit0\"] + (timeStep * 100))",
26
          "as": "barStart"
27
        },
28
        {
29
          "type": "formula",
30
          "expr": "time(datum[\"unit1\"] - (timeStep * 100))",
31
          "as": "barEnd"
32
        }
33
      ]
34
    },
35
    {
36
      "name": "table2",
37
      "source": "table",
38
      "transform":[
39
        {
40
          "type": "lookup",
41
          "from": "table",
42
          "key": "unit0",
43
          "fields": ["unit1"],
44
          "as": ["obj"]
45
        }
46

    
47
      ]
48

    
49
    }
50
  ],
51

    
52
  "signals": [
53
    {
54
      "name": "detailDomain"
55
    },
56
    {
57
      "name": "timeStep",
58
      "value": 1800
59
    }
60
  ],
61

    
62
  "marks": [
63
    {
64
      "type": "group",
65
      "name": "detail",
66
      "encode": {
67
        "enter": {
68
          "height": {"value": 390},
69
          "width": {"value": 800}
70
        }
71
      },
72
      "scales": [
73
        {
74
          "name": "xDetail",
75
          "type": "time",
76
          "range": "width",
77
          "domain": {"data": "table", "field": "dateTime"},
78
          "domainRaw": {"signal": "detailDomain"}
79
        },
80
        {
81
          "name": "yDetail",
82
          "type": "linear",
83
          "range": [390, 0],
84
          "domain": {"data": "table", "field": "value"},
85
          "nice": true, "zero": true
86
        }
87
      ],
88
      "axes": [
89
        {"orient": "bottom", "scale": "xDetail"},
90
        {"orient": "left", "scale": "yDetail"}
91
      ],
92
      "marks": [
93
        {
94
          "type": "group",
95
          "encode": {
96
            "enter": {
97
              "height": {"field": {"group": "height"}},
98
              "width": {"field": {"group": "width"}},
99
              "clip": {"value": true}
100
            }
101
          },
102
          "marks": [
103
            {
104
              "type": "rect",
105
              "from": {"data":"table"},
106
              "encode": {
107
                "enter": {
108
                  "tooltip": {
109
                    "signal": "{title: timeFormat(datum.dateTime, '%B %d, %Y %H:%M')  , 'gid': datum.gid , 'value': datum.value }"
110
                  }},
111
                "update": {
112
                  "x": {"scale": "xDetail", "field": "barStart"},
113
                  "x2": {"scale": "xDetail", "field": "barEnd"},
114
                  "y": {"scale": "yDetail", "field": "value"},
115
                  "y2": {"scale": "yDetail", "value": 0},
116
                  "color": {"value": "both"},
117
                  "fill": {"value": "steelblue"}
118
                },
119
                "hover": {
120
                  "fill": {"value": "red"},
121
                  "size": {"value": 60}
122
                }
123
              }
124
            }
125

    
126

    
127

    
128
          ]
129
        }
130
      ]
131
    },
132

    
133
    {
134
      "type": "group",
135
      "name": "overview",
136
      "encode": {
137
        "enter": {
138
          "x": {"value": 0},
139
          "y": {"value": 430},
140
          "height": {"value": 70},
141
          "width": {"value": 720},
142
          "fill": {"value": "transparent"}
143
        }
144
      },
145
      "signals": [
146
        {
147
          "name": "brush", "value": 0,
148
          "on": [
149
            {
150
              "events": "@overview:mousedown",
151
              "update": "[x(), x()]"
152
            },
153
            {
154
              "events": "[@overview:mousedown, window:mouseup] > window:mousemove!",
155
              "update": "[brush[0], clamp(x(), 0, width)]"
156
            },
157
            {
158
              "events": {"signal": "delta"},
159
              "update": "clampRange([anchor[0] + delta, anchor[1] + delta], 0, width)"
160
            }
161
          ]
162
        },
163
        {
164
          "name": "anchor", "value": null,
165
          "on": [{"events": "@brush:mousedown", "update": "slice(brush)"}]
166
        },
167
        {
168
          "name": "xdown", "value": 0,
169
          "on": [{"events": "@brush:mousedown", "update": "x()"}]
170
        },
171
        {
172
          "name": "delta", "value": 0,
173
          "on": [
174
            {
175
              "events": "[@brush:mousedown, window:mouseup] > window:mousemove!",
176
              "update": "x() - xdown"
177
            }
178
          ]
179
        },
180
        {
181
          "name": "detailDomain",
182
          "push": "outer",
183
          "on": [
184
            {
185
              "events": {"signal": "brush"},
186
              "update": "span(brush) ? invert('xOverview', brush) : null"
187
            }
188
          ]
189
        }
190
      ],
191
      "scales": [
192
        {
193
          "name": "xOverview",
194
          "type": "time",
195
          "range": "width",
196
          "domain": {"data": "table", "field": "dateTime"}
197
        },
198
        {
199
          "name": "yOverview",
200
          "type": "linear",
201
          "range": [70, 0],
202
          "domain": {"data": "table", "field": "value"},
203
          "nice": true, "zero": true
204
        }
205
      ],
206
      "axes": [
207
        {"orient": "bottom", "scale": "xOverview"}
208
      ],
209
      "marks": [
210

    
211

    
212
        {
213
          "type": "rect",
214
          "name": "brush",
215
          "encode": {
216
            "enter": {
217
              "y": {"value": 0},
218
              "height": {"value": 70},
219
              "fill": {"value": "#333"},
220
              "fillOpacity": {"value": 0.2}
221
            },
222
            "update": {
223
              "x": {"signal": "brush[0]"},
224
              "x2": {"signal": "brush[1]"}
225
            }
226
          }
227
        },
228
        {
229
          "type": "rect",
230
          "interactive": false,
231
          "encode": {
232
            "enter": {
233
              "y": {"value": 0},
234
              "height": {"value": 70},
235
              "width": {"value": 1},
236
              "fill": {"value": "firebrick"}
237
            },
238
            "update": {
239
              "x": {"signal": "brush[0]"}
240
            }
241
          }
242
        },
243
        {
244
          "type": "rect",
245
          "interactive": false,
246
          "encode": {
247
            "enter": {
248
              "y": {"value": 0},
249
              "height": {"value": 70},
250
              "width": {"value": 1},
251
              "fill": {"value": "firebrick"}
252
            },
253
            "update": {
254
              "x": {"signal": "brush[1]"}
255
            }
256
          }
257
        }
258
      ]
259
    }
260
  ]
261
}
262

    
263

    
264

    
(4-4/7)