Revize 6842a0b0
Přidáno uživatelem Štěpán Červenka před více než 3 roky(ů)
src/app/sensor/components/sensor.component.ts | ||
---|---|---|
126 | 126 |
).subscribe( |
127 | 127 |
observations => { |
128 | 128 |
if (observations) { |
129 |
GraphLoader.getGraph(this.sensorId, observations, this.sensor, '#view', true);
|
|
129 |
GraphLoader.getGraphWithInterval(this.sensorId, observations[this.sensorId].data, observations[this.sensorId].interval * 1000, this.sensor, '#view', true);
|
|
130 | 130 |
} else { |
131 | 131 |
GraphLoader.getGraph(null, null, null, '#view', null); |
132 | 132 |
} |
src/app/shared/graph-loading/graphloader.ts | ||
---|---|---|
55 | 55 |
.hover() |
56 | 56 |
.runAsync(); |
57 | 57 |
} |
58 |
|
|
59 |
|
|
60 |
|
|
61 | 58 |
} |
src/app/unit/components/unit.component.ts | ||
---|---|---|
137 | 137 |
getAnalytics(range: Date[], changedDate: boolean, changedSensorId: string) { |
138 | 138 |
if (changedDate) { // if changed date we need new data for all sensors |
139 | 139 |
this.selectedSensors.forEach(selectSens => { |
140 |
this.analyticsData = []; //empty analytics data |
|
140 | 141 |
this.analyticsEndpointRequest(selectSens, range); |
141 | 142 |
}); |
142 | 143 |
} else { // add data for selected sensor |
... | ... | |
165 | 166 |
}) |
166 | 167 |
).subscribe(data => { |
167 | 168 |
if (data) { |
168 |
this.analyticsData.push({sensorId, data: data[sensorId].data, interval: data[sensorId].interval}); |
|
169 |
this.analyticsData.push({sensorId, data: data[sensorId].data, interval: data[sensorId].interval, |
|
170 |
sensor: this.sensors.find(sens => sens.sensorId.toString() === sensorId.toString())}); |
|
169 | 171 |
if (data[sensorId].data) { |
170 | 172 |
const groupId = sensorId.slice(0, 5); |
171 | 173 |
const view = '#vega_container_' + groupId; |
172 | 174 |
if (this.selectedSensors.some(sens => sens.toString() === sensorId)) { |
173 | 175 |
// GraphLoader.getAnalyticsGraph(key, data[key].data, data[key].interval, view); |
174 |
GraphLoader.getGraph(this.selectedSensors, this.analyticsData, this.filteredSensorsInfos(groupId), view, true);
|
|
176 |
GraphLoader.getGraphWithInterval(this.filteredSelectedSensors(groupId), this.filteredAnalyticsData(groupId), this.filteredAnalyticsData(groupId)[0]['interval'] * 1000, this.filteredSensorsInfos(groupId)[0], view, true);
|
|
175 | 177 |
} else { |
176 | 178 |
// GraphLoader.getAnalyticsGraph(null, null, null, view); |
177 | 179 |
GraphLoader.getGraph(null, null, null, view, null); |
... | ... | |
198 | 200 |
if (this.analyticsData.some(sens => sens.sensorId === sensorId)) { // if already data for selected sensor in memory |
199 | 201 |
// GraphLoader.getAnalyticsGraph(sensorId, this.analyticsData.find(sens => sens.sensorId === sensorId).data, |
200 | 202 |
// this.analyticsData.find((sens => sens.sensorId === sensorId).interval, sensorGroupElement); |
201 |
GraphLoader.getGraph(this.selectedSensors, this.analyticsData, this.filteredSensorsInfos(groupId), sensorGroupElement, true); |
|
203 |
//GraphLoader.getGraph(this.selectedSensors, this.analyticsData, this.filteredSensorsInfos(groupId), sensorGroupElement, true); |
|
204 |
GraphLoader.getGraphWithInterval(this.filteredSelectedSensors(groupId), this.filteredAnalyticsData(groupId), this.filteredAnalyticsData(groupId)[0]['interval'] * 1000, this.filteredSensorsInfos(groupId)[0], sensorGroupElement, true); |
|
202 | 205 |
|
203 | 206 |
} else { // get data from server for added sensor and show graph for selected sensors |
204 | 207 |
this.showGraph(false, sensorId); |
... | ... | |
206 | 209 |
} else { // remove sensor from graph |
207 | 210 |
// GraphLoader.getAnalyticsGraph(sensorId, this.analyticsData.find(sens => sens.sensorId === sensorId).data, |
208 | 211 |
// this.analyticsData.find(sens => sens.sensorId === sensorId).interval, sensorGroupElement); |
209 |
GraphLoader.getGraph(this.selectedSensors, this.analyticsData, this.filteredSensorsInfos(groupId), sensorGroupElement, true);
|
|
212 |
GraphLoader.getGraphWithInterval(this.filteredSelectedSensors(groupId), this.filteredAnalyticsData(groupId), this.filteredAnalyticsData(groupId)[0]['interval'] * 1000, this.filteredSensorsInfos(groupId)[0], sensorGroupElement, true);
|
|
210 | 213 |
|
211 | 214 |
} |
212 | 215 |
} else { // use observations data |
src/vega/body/linechart.json | ||
---|---|---|
154 | 154 |
}, |
155 | 155 |
"y2": { |
156 | 156 |
"scale": "yDetail", |
157 |
"value": 0
|
|
157 |
"signal": "-1e+36"
|
|
158 | 158 |
}, |
159 | 159 |
"fill": { |
160 | 160 |
"value": "#00ff00" |
... | ... | |
239 | 239 |
}, |
240 | 240 |
"y": { |
241 | 241 |
"scale": "yDetail", |
242 |
"value": 1000000
|
|
242 |
"band": 1
|
|
243 | 243 |
}, |
244 | 244 |
"y2": { |
245 | 245 |
"scale": "yDetail", |
246 |
"value": -1000000
|
|
246 |
"signal": "-1e+36"
|
|
247 | 247 |
}, |
248 | 248 |
"strokeOpacity": [ |
249 | 249 |
{ |
src/vega/body/multilinechart.json | ||
---|---|---|
388 | 388 |
}, |
389 | 389 |
"y2": { |
390 | 390 |
"scale": "yDetail", |
391 |
"value": 0
|
|
391 |
"signal": "-1e+36"
|
|
392 | 392 |
}, |
393 | 393 |
"fill": { |
394 | 394 |
"value": "#00ff00" |
... | ... | |
417 | 417 |
}, |
418 | 418 |
"y2": { |
419 | 419 |
"scale": "yDetail", |
420 |
"value": 0
|
|
420 |
"signal": "-1e+36"
|
|
421 | 421 |
}, |
422 | 422 |
"strokeOpacity": [ |
423 | 423 |
{ |
src/vega/trashbin/linechart.json | ||
---|---|---|
1 |
{ |
|
2 |
"data": [ |
|
3 |
{}, |
|
4 |
{}, |
|
5 |
{}, |
|
6 |
{}, |
|
7 |
{ |
|
8 |
"name": "timeunit", |
|
9 |
"source": "table", |
|
10 |
"transform": [ |
|
11 |
{ |
|
12 |
"type": "timeunit", |
|
13 |
"field": "dateTime", |
|
14 |
"units": ["year","month", "date", "hours", "minutes", "seconds"], |
|
15 |
"step": {"signal": "timeStep"} |
|
16 |
} |
|
17 |
] |
|
18 |
}, |
|
19 |
{ |
|
20 |
"name": "lookup", |
|
21 |
"source": "timeunit", |
|
22 |
"transform":[ |
|
23 |
{ |
|
24 |
"type": "lookup", |
|
25 |
"from": "timeunit", |
|
26 |
"key": "unit0", |
|
27 |
"fields": ["unit1"], |
|
28 |
"as": ["obj"] |
|
29 |
} |
|
30 |
] |
|
31 |
} |
|
32 |
], |
|
33 |
"marks": [ |
|
34 |
{ |
|
35 |
"scales": [ |
|
36 |
{}, |
|
37 |
{ |
|
38 |
"name": "yDetail", |
|
39 |
"type": "linear", |
|
40 |
"range": [390, 0], |
|
41 |
"domain": {"data": "range", "field": "valueMax"}, |
|
42 |
"nice": true, "zero": true |
|
43 |
} |
|
44 |
], |
|
45 |
"axes": [ |
|
46 |
{}, |
|
47 |
{"orient": "left", "scale": "yDetail"} |
|
48 |
], |
|
49 |
"marks": [ |
|
50 |
{ |
|
51 |
"marks": [ |
|
52 |
{ |
|
53 |
"type": "symbol", |
|
54 |
"from": {"data":"table"}, |
|
55 |
"encode": { |
|
56 |
"enter": { |
|
57 |
"tooltip": { |
|
58 |
"signal": "{title: timeFormat(datum.dateTime, '%A, %e. %B %Y, %X') }" |
|
59 |
}}, |
|
60 |
"update": { |
|
61 |
"shape": {"value": "circle"}, |
|
62 |
"size": {"value": 30}, |
|
63 |
"x": {"scale": "xDetail", "field": "dateTime"}, |
|
64 |
"y": {"scale": "yDetail", "field": "value"}, |
|
65 |
"color": {"value": "both"}, |
|
66 |
"strokeWidth": {"value": 4}, |
|
67 |
"fill": {"value": "steelblue"} |
|
68 |
}, |
|
69 |
"hover": { |
|
70 |
"fill": {"value": "red"}, |
|
71 |
"size": {"value": 60} |
|
72 |
} |
|
73 |
} |
|
74 |
}, |
|
75 |
{ |
|
76 |
"type": "rule", |
|
77 |
"from": { |
|
78 |
"data": "lookup" |
|
79 |
}, |
|
80 |
"encode": { |
|
81 |
"update": { |
|
82 |
"x": { |
|
83 |
"scale": "xDetail", |
|
84 |
"field": "unit0" |
|
85 |
}, |
|
86 |
"x2": [ |
|
87 |
{ |
|
88 |
"test": "isValid(datum.obj)", |
|
89 |
"scale": "xDetail", |
|
90 |
"field": "obj.unit0" |
|
91 |
}, |
|
92 |
{ |
|
93 |
"scale": "xDetail", |
|
94 |
"field": "unit0" |
|
95 |
} |
|
96 |
], |
|
97 |
"y": { |
|
98 |
"scale": "yDetail", |
|
99 |
"field": "value" |
|
100 |
}, |
|
101 |
"y2": [ |
|
102 |
{ |
|
103 |
"test": "isValid(datum.obj)", |
|
104 |
"scale": "yDetail", |
|
105 |
"field": "obj.value" |
|
106 |
}, |
|
107 |
{ |
|
108 |
"scale": "yDetail", |
|
109 |
"field": "value" |
|
110 |
} |
|
111 |
], |
|
112 |
"stroke": { |
|
113 |
"value": "steelblue" |
|
114 |
}, |
|
115 |
"strokeWidth": { |
|
116 |
"value": 1 |
|
117 |
} |
|
118 |
} |
|
119 |
} |
|
120 |
} |
|
121 |
] |
|
122 |
} |
|
123 |
] |
|
124 |
}, |
|
125 |
{ |
|
126 |
"signals": [ |
|
127 |
{ |
|
128 |
"value": 0, |
|
129 |
"on": [ |
|
130 |
{}, |
|
131 |
{ |
|
132 |
"events": "@overview:mousedown", |
|
133 |
"update": "[x(), x()]" |
|
134 |
}, |
|
135 |
{ |
|
136 |
"events": "[@overview:mousedown, window:mouseup] > window:mousemove!", |
|
137 |
"update": "[brush[0], clamp(x(), 0, width)]" |
|
138 |
} |
|
139 |
] |
|
140 |
} |
|
141 |
], |
|
142 |
"marks": [ |
|
143 |
{}, |
|
144 |
{}, |
|
145 |
{}, |
|
146 |
{ |
|
147 |
"type": "symbol", |
|
148 |
"from": {"data":"table"}, |
|
149 |
"encode": { |
|
150 |
"update": { |
|
151 |
"shape": {"value": "circle"}, |
|
152 |
"size": {"value": 10}, |
|
153 |
"x": {"scale": "xOverview", "field": "dateTime"}, |
|
154 |
"y": {"scale": "yOverview", "field": "value"}, |
|
155 |
"color": {"value": "both"}, |
|
156 |
"strokeWidth": {"value": 4} |
|
157 |
} |
|
158 |
} |
|
159 |
}, |
|
160 |
{ |
|
161 |
"type": "rule", |
|
162 |
"from": { |
|
163 |
"data": "lookup" |
|
164 |
}, |
|
165 |
"encode": { |
|
166 |
"update": { |
|
167 |
"x": { |
|
168 |
"scale": "xOverview", |
|
169 |
"field": "unit0" |
|
170 |
}, |
|
171 |
"x2": [ |
|
172 |
{ |
|
173 |
"test": "isValid(datum.obj)", |
|
174 |
"scale": "xOverview", |
|
175 |
"field": "obj.unit0" |
|
176 |
}, |
|
177 |
{ |
|
178 |
"scale": "xOverview", |
|
179 |
"field": "unit0" |
|
180 |
} |
|
181 |
], |
|
182 |
"y": { |
|
183 |
"scale": "yOverview", |
|
184 |
"field": "value" |
|
185 |
}, |
|
186 |
"y2": [ |
|
187 |
{ |
|
188 |
"test": "isValid(datum.obj)", |
|
189 |
"scale": "yOverview", |
|
190 |
"field": "obj.value" |
|
191 |
}, |
|
192 |
{ |
|
193 |
"scale": "yOverview", |
|
194 |
"field": "value" |
|
195 |
} |
|
196 |
], |
|
197 |
"stroke": { |
|
198 |
"value": "steelblue" |
|
199 |
}, |
|
200 |
"strokeWidth": { |
|
201 |
"value": 1 |
|
202 |
} |
|
203 |
} |
|
204 |
} |
|
205 |
} |
|
206 |
] |
|
207 |
} |
|
208 |
] |
|
209 |
} |
Také k dispozici: Unified diff
Re #8928 - Oprava chyb vzniklých v průběhu iterace