Projekt

Obecné

Profil

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

    
7
  "data": [
8
    {
9
      "name": "table",
10
      "url": "data.json",
11
      "transform": [
12
        {
13
          "type": "formula",
14
          "expr": "toDate(datum[\"time_stamp\"])",
15
          "as": "dateTime"
16
        },
17
        {
18
          "type": "timeunit",
19
          "field": "dateTime",
20
          "units": ["year","month", "date", "hours"]
21
        }
22
      ]
23
    },
24
    {
25
      "name": "table2",
26
      "url": "data.json",
27
      "transform": [
28
        {
29
          "type": "formula",
30
          "expr": "toDate(datum[\"time_stamp\"])",
31
          "as": "dateTime"
32
        },
33
        {
34
          "type": "timeunit",
35
          "field": "dateTime",
36
          "units": ["year", "month","date", "hours"]
37
        },
38
        {
39
          "type": "lookup",
40
          "from": "table",
41
          "key": "unit0",
42
          "fields": ["unit1"],
43
          "as": ["obj"]
44
        }
45
      ]
46
    }
47
  ],
48

    
49
  "scales": [
50
    {
51
      "name": "xscale",
52
      "type": "time",
53
      "domain": {"data": "table", "fields": ["unit0", "unit1"]},
54
      "range": "width"
55
    },
56
    {
57
      "name": "yscale",
58
      "type": "linear",
59
      "domain": {"data": "table", "field": "sensors[0].value"},
60
      "nice": true,
61
      "range": "height"
62
    }
63
  ],
64

    
65
  "axes": [
66
    { "orient": "bottom", "scale": "xscale" },
67
    { "orient": "left", "scale": "yscale" }
68
  ],
69

    
70
  "marks": [
71
    {
72
      "type": "symbol",
73
      "from": {"data":"table"},
74
      "encode": {
75
        "enter": {
76
          "shape": {"value": "circle"},
77
          "size": {"value": 10},
78
          "x": {"scale": "xscale", "field": "dateTime"},
79
          "y": {"scale": "yscale", "field": "sensors[0].value"},
80
          "color": {"value": "both"},
81
          "strokeWidth": {"value": 4}
82
        }
83
      }
84
    },
85
    {
86
      "type": "rule",
87
      "from": {"data":"table2"},
88
      "encode": {
89
        "enter": {
90
          "x": {"scale": "xscale", "field": "unit0"},
91
          "x2":[
92
            {
93
              "test": "isValid(datum.obj)",
94
              "scale" : "xscale",
95
              "field" : "obj.unit0"
96
            },
97
            {
98
              "scale" : "xscale",
99
              "field" : "unit0"
100
            }
101
          ],
102
          "y": {"scale": "yscale", "field": "sensors[0].value"},
103
          "y2":[
104
            {
105
              "test": "isValid(datum.obj)",
106
              "scale" : "yscale",
107
              "field" : "obj.sensors[0].value"
108
            },
109
            {
110
              "scale" : "yscale",
111
              "field" : "sensors[0].value"
112
            }
113
          ]
114

    
115

    
116

    
117
        },
118
        "update": {
119
          "stroke": {"value": "steelblue"},
120
          "strokeWidth": {"value": 1}
121
        },
122
        "hover": {
123
          "stroke": {"value": "red"},
124
          "strokeWidth": {"value": 3}
125
        }
126
      }
127
    }
128
  ]
129

    
130
}
(6-6/8)