Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 8cca41c0

Přidáno uživatelem Štěpán Červenka před více než 3 roky(ů)

Re #8775 - Agregovat grafy se stejným typem sensoru

  • graph loading decomposition
  • some bugs fixed

Zobrazit rozdíly:

src/vega/body/linechart.json
5 5
    {},
6 6
    {},
7 7
    {
8
      "name": "timeunit",
8
      "name": "ranks",
9 9
      "source": "table",
10 10
      "transform": [
11 11
        {
12
          "type": "timeunit",
13
          "field": "dateTime",
14
          "units": ["year","month", "date", "hours", "minutes", "seconds"],
15
          "step": {"signal": "timeStep"}
12
          "type": "window",
13
          "sort": {
14
            "field": "dateTime",
15
            "order": "ascending"
16
          },
17
          "ops": [
18
            "rank"
19
          ],
20
          "fields": [
21
            "value"
22
          ],
23
          "as": [
24
            "rank"
25
          ]
26
        },
27
        {
28
          "type": "formula",
29
          "expr": "datum.rank + 1",
30
          "as": "nextRank"
16 31
        }
17 32
      ]
18 33
    },
19 34
    {
20 35
      "name": "lookup",
21
      "source": "timeunit",
22
      "transform":[
36
      "source": "ranks",
37
      "transform": [
23 38
        {
24 39
          "type": "lookup",
25
          "from": "timeunit",
26
          "key": "unit0",
27
          "fields": ["unit1"],
28
          "as": ["obj"]
40
          "from": "table",
41
          "key": "rank",
42
          "fields": [
43
            "nextRank"
44
          ],
45
          "as": [
46
            "nextObj"
47
          ]
48
        },
49
        {
50
          "type": "lookup",
51
          "from": "table",
52
          "key": "rank",
53
          "fields": [
54
            "prevRank"
55
          ],
56
          "as": [
57
            "prevObj"
58
          ]
59
        },
60
        {
61
          "type": "formula",
62
          "expr": "(datum.nextObj == null || datum.nextObj.dateTime - datum.dateTime > maxTimeDifference) ? null : datum.nextObj",
63
          "as": "obj"
64
        },
65
        {
66
          "type": "formula",
67
          "expr": "datum.prevObj == null ?  data('range')[0].dateMin : (time(datum.prevObj.dateTime) + time(datum.dateTime)) / 2",
68
          "as": "dateStart"
69
        },
70
        {
71
          "type": "formula",
72
          "expr": "datum.nextObj == null ?  data('range')[0].dateMax : (time(datum.nextObj.dateTime) + time(datum.dateTime)) / 2",
73
          "as": "dateEnd"
29 74
        }
30 75
      ]
31 76
    }
32 77
  ],
78

  
79
  "signals": [
80
    {},
81
    {},
82
    {
83
      "name": "tooltipSignal",
84
      "value": {},
85
      "on": [
86
        {
87
          "events": "@tooltip-hitarea:mouseover",
88
          "update": "datum"
89
        },
90
        {
91
          "events": "@tooltip-hitarea:mouseout",
92
          "update": "{}"
93
        }
94
      ]
95
    }
96
  ],
97

  
33 98
  "marks": [
34 99
    {
35 100
      "scales": [
......
38 103
          "name": "yDetail",
39 104
          "type": "linear",
40 105
          "range": [390, 0],
41
          "domain": {"data": "range", "field": "valueMax"},
106
          "domain": {
107
            "fields": [
108
              {"data": "range", "field": "valueMax"},
109
              {"data":  "table", "field": "value"}
110
            ]
111
          },
42 112
          "nice": true, "zero": true
43 113
        }
44 114
      ],
......
49 119
      "marks": [
50 120
        {
51 121
          "marks": [
122
            {
123
              "name": "tooltip-hitarea",
124
              "type": "rect",
125
              "interactive": true,
126
              "from": {
127
                "data": "lookup"
128
              },
129
              "encode": {
130
                "enter": {
131
                  "tooltip": {
132
                    "signal": null
133
                  }
134
                },
135
                "update": {
136
                  "x": {
137
                    "scale": "xDetail",
138
                    "field": "dateStart"
139
                  },
140
                  "x2": {
141
                    "scale": "xDetail",
142
                    "field": "dateEnd"
143
                  },
144
                  "y": {
145
                    "scale": "yDetail",
146
                    "band": 1
147
                  },
148
                  "y2": {
149
                    "scale": "yDetail",
150
                    "value": 0
151
                  },
152
                  "fill": {
153
                    "value": "#00ff00"
154
                  },
155
                  "fillOpacity": {
156
                    "value": 0.0
157
                  }
158
                }
159
              }
160
            },
52 161
            {
53 162
              "type": "symbol",
54
              "from": {"data":"table"},
163
              "from": {"data":"lookup"},
55 164
              "encode": {
56 165
                "enter": {
57 166
                  "tooltip": {
......
65 174
                  "color": {"value": "both"},
66 175
                  "strokeWidth": {"value": 4},
67 176
                  "fill": {"value": "steelblue"}
68
                },
69
                "hover": {
70
                  "fill": {"value": "red"},
71
                  "size": {"value": 60}
72 177
                }
73 178
              }
74 179
            },
......
81 186
                "update": {
82 187
                  "x": {
83 188
                    "scale": "xDetail",
84
                    "field": "unit0"
189
                    "field": "dateTime"
85 190
                  },
86 191
                  "x2": [
87 192
                    {
88 193
                      "test": "isValid(datum.obj)",
89 194
                      "scale": "xDetail",
90
                      "field": "obj.unit0"
195
                      "field": "obj.dateTime"
91 196
                    },
92 197
                    {
93 198
                      "scale": "xDetail",
94
                      "field": "unit0"
199
                      "field": "dateTime"
95 200
                    }
96 201
                  ],
97 202
                  "y": {
......
117 222
                  }
118 223
                }
119 224
              }
225
            },
226

  
227
            {
228
              "type": "rule",
229
              "interactive": false,
230
              "zindex": 20,
231
              "encode": {
232
                "enter": {
233
                },
234
                "update": {
235
                  "x": {
236
                    "scale": "xDetail",
237
                    "signal": "tooltipSignal.dateTime"
238
                  },
239
                  "y": {
240
                    "scale": "yDetail",
241
                    "band": 1
242
                  },
243
                  "y2": {
244
                    "scale": "yDetail",
245
                    "value": 0
246
                  },
247
                  "strokeOpacity": [
248
                    {
249
                      "test": "tooltipSignal.dateTime > 1",
250
                      "value": 1
251
                    },
252
                    {
253
                      "value": 0
254
                    }
255
                  ]
256
                }
257
              }
120 258
            }
121 259
          ]
122 260
        }
......
166 304
            "update": {
167 305
              "x": {
168 306
                "scale": "xOverview",
169
                "field": "unit0"
307
                "field": "dateTime"
170 308
              },
171 309
              "x2": [
172 310
                {
173 311
                  "test": "isValid(datum.obj)",
174 312
                  "scale": "xOverview",
175
                  "field": "obj.unit0"
313
                  "field": "obj.dateTime"
176 314
                },
177 315
                {
178 316
                  "scale": "xOverview",
179
                  "field": "unit0"
317
                  "field": "dateTime"
180 318
                }
181 319
              ],
182 320
              "y": {

Také k dispozici: Unified diff