aframe-babia-components 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/components/filters/babia-selector.js +256 -79
  2. package/components/filters/babia-treebuilder.js +1 -2
  3. package/components/geometries/babia-cyl.js +180 -0
  4. package/components/others/assets/tooltip.png +0 -0
  5. package/components/others/babia-camera.js +195 -0
  6. package/components/others/babia-controls.js +56 -31
  7. package/components/others/babia-navigator.js +55 -49
  8. package/components/others/babia-range-selector.js +208 -0
  9. package/components/others/babia-slider.js +36 -8
  10. package/components/others/babia-ui.js +246 -73
  11. package/components/others/common.js +60 -73
  12. package/components/queriers/babia-querycsv.js +96 -0
  13. package/components/queriers/babia-queryes.js +203 -132
  14. package/components/visualizers/babia-bars.js +4 -35
  15. package/components/visualizers/babia-barsmap.js +2 -30
  16. package/components/visualizers/babia-boats.js +92 -100
  17. package/components/visualizers/babia-bubbles.js +9 -26
  18. package/components/visualizers/babia-cyls.js +197 -201
  19. package/components/visualizers/babia-cylsmap.js +171 -241
  20. package/components/visualizers/babia-doughnut.js +2 -28
  21. package/components/visualizers/babia-network.js +191 -124
  22. package/components/visualizers/babia-pie.js +2 -30
  23. package/dist/aframe-babia-components.js +21678 -19529
  24. package/dist/aframe-babia-components.min.js +7 -1
  25. package/dist/aframe-babia-components.min.js.map +1 -1
  26. package/docs/APIs/CHARTS.md +10 -4
  27. package/docs/APIs/DATAMANAGEMENT.md +7 -0
  28. package/docs/APIs/OTHERS.md +27 -0
  29. package/docs/APIs/QUERIERS.md +16 -0
  30. package/docs/RELEASE_NOTES.md +32 -21
  31. package/docs/Tutorials/multiuser.md +47 -2
  32. package/examples/assets/door/New Bitmap Image.jpg +0 -0
  33. package/examples/assets/door/door.mtl +26 -0
  34. package/examples/assets/door/door.obj +6927 -0
  35. package/examples/assets/popups/0.png +0 -0
  36. package/examples/assets/popups/1.png +0 -0
  37. package/examples/assets/popups/10.png +0 -0
  38. package/examples/assets/popups/2.png +0 -0
  39. package/examples/assets/popups/3.png +0 -0
  40. package/examples/assets/popups/4.png +0 -0
  41. package/examples/assets/popups/5.png +0 -0
  42. package/examples/assets/popups/6.png +0 -0
  43. package/examples/assets/popups/7.png +0 -0
  44. package/examples/assets/popups/8.png +0 -0
  45. package/examples/assets/popups/9.png +0 -0
  46. package/examples/assets/popups/close.jpg +0 -0
  47. package/examples/assets/popups/info.jpg +0 -0
  48. package/examples/assets/textures/brownwall.png +0 -0
  49. package/examples/assets/textures/concrete.png +0 -0
  50. package/examples/assets/textures/white-wall-texture.jpg +0 -0
  51. package/examples/charts/cyls/index.html +13 -4
  52. package/examples/charts/cyls/primitive.html +76 -0
  53. package/examples/charts/cylsmap/index.html +14 -5
  54. package/examples/charts_querier/bars_querier/data.csv +10 -0
  55. package/examples/charts_querier/bars_querier/index_csv.html +80 -0
  56. package/examples/dashboard/chaoss-dashboards.html +259 -0
  57. package/examples/dashboard/chaoss-issues.html +248 -0
  58. package/examples/dashboard/chaoss-pr.html +248 -0
  59. package/examples/dashboard/index.html +247 -0
  60. package/examples/dashboard/issues_queries/80-percent-open-time.json +123 -0
  61. package/examples/dashboard/issues_queries/issues-by-organization.json +107 -0
  62. package/examples/dashboard/issues_queries/issues.json +117 -0
  63. package/examples/dashboard/issues_queries/median-open-time.json +123 -0
  64. package/examples/dashboard/issues_queries/organizations.json +130 -0
  65. package/examples/dashboard/issues_queries/projects.json +130 -0
  66. package/examples/dashboard/issues_queries/repositories.json +130 -0
  67. package/examples/dashboard/issues_queries/status.json +107 -0
  68. package/examples/dashboard/issues_queries/submitter.json +125 -0
  69. package/examples/dashboard/issues_queries/submitters.json +113 -0
  70. package/examples/dashboard/pullrequests_queries/80-percent-open-time.json +123 -0
  71. package/examples/dashboard/pullrequests_queries/median-open-time.json +123 -0
  72. package/examples/dashboard/pullrequests_queries/organizations.json +130 -0
  73. package/examples/dashboard/pullrequests_queries/projects.json +130 -0
  74. package/examples/dashboard/pullrequests_queries/pull-requests-by-organization.json +107 -0
  75. package/examples/dashboard/pullrequests_queries/pull-requests.json +117 -0
  76. package/examples/dashboard/pullrequests_queries/repositories.json +130 -0
  77. package/examples/dashboard/pullrequests_queries/status.json +107 -0
  78. package/examples/dashboard/pullrequests_queries/submitter.json +125 -0
  79. package/examples/dashboard/pullrequests_queries/submitters.json +113 -0
  80. package/examples/dashboard/range.html +88 -0
  81. package/examples/dashboard/template.html +136 -0
  82. package/examples/demos/1.0.11/index_multiuser_ui.html +1 -1
  83. package/examples/multi_bars/data.json +14 -0
  84. package/examples/multi_bars/data2.json +15 -0
  85. package/examples/multi_bars/data3.json +23 -0
  86. package/examples/multi_bars/easyrtc.js +11984 -0
  87. package/examples/multi_bars/index.html +97 -0
  88. package/examples/multi_bars/index1.html +111 -0
  89. package/examples/multi_bars/index2.html +102 -0
  90. package/examples/multi_bars/index3.html +104 -0
  91. package/examples/multi_boats/data3.json +174 -0
  92. package/examples/multi_boats/data4.json +192 -0
  93. package/examples/multi_boats/{index.html → index_multi_boats.html} +50 -55
  94. package/examples/multi_boats/jetuml.html +124 -115
  95. package/examples/multi_boats/jetuml_evolution_experiment.html +419 -0
  96. package/examples/multi_boats/only_queryjson.html +132 -0
  97. package/examples/multi_boats/only_queryjson2.html +167 -0
  98. package/examples/multi_boats/only_queryjson3.html +165 -0
  99. package/examples/multi_boats/queryjson_treebuilder.html +132 -0
  100. package/examples/multi_boats/with_selector.html +121 -111
  101. package/examples/multiuser/choose_avatar/index.html +18 -8
  102. package/examples/selector_boats/jetuml_from_3_2_to_1_0.json +62382 -0
  103. package/examples/ui/network/data.json +123 -0
  104. package/examples/ui/network/links.json +13 -0
  105. package/examples/ui/network/network.html +75 -0
  106. package/examples/ui/network/network_nodes_links.html +82 -0
  107. package/examples/ui/network/nodes.json +12 -0
  108. package/index.html +69 -3
  109. package/index.js +6 -1
  110. package/package.json +4 -3
  111. package/tests/screenshots/other_snapshots.js/chaoss-issues.png +0 -0
  112. package/tests/screenshots/other_snapshots.js/chaoss-pr.png +0 -0
  113. package/tests/screenshots/other_snapshots.js/template.png +0 -0
  114. package/tests/ui.js +7 -0
  115. package/webpack.common.js +1 -1
  116. package/webpack.devnossl.js +16 -0
  117. package/.idea/vcs.xml +0 -6
  118. package/.idea/workspace.xml +0 -79
@@ -1,8 +1,12 @@
1
+ let parseJson = require('../others/common').parseJson;
2
+
1
3
  /* global AFRAME */
2
4
  if (typeof AFRAME === 'undefined') {
3
5
  throw new Error('Component attempted to register before AFRAME was available.');
4
6
  }
5
7
 
8
+ const NotiBuffer = require("../../common/noti-buffer").NotiBuffer;
9
+
6
10
  /**
7
11
  * A-Charts component for A-Frame.
8
12
  */
@@ -12,10 +16,14 @@ AFRAME.registerComponent('babia-queryes', {
12
16
  index: { type: 'string' },
13
17
  query: { type: 'string' },
14
18
  size: { type: 'int', default: 10 },
19
+ request: { type: 'string' },
15
20
  user: { type: 'string' },
16
21
  password: { type: 'string' },
17
22
  // data, for debugging, highest priority
18
- data: { type: 'string' }
23
+ data: { type: 'string' },
24
+ // ONLY BARS
25
+ tableBars: { type: 'boolean', default: false },
26
+ rangeSelector: { type: 'string'}
19
27
  },
20
28
 
21
29
  /**
@@ -26,7 +34,11 @@ AFRAME.registerComponent('babia-queryes', {
26
34
  /**
27
35
  * Called once when component is attached. Generally for initial setup.
28
36
  */
29
- init: function () { },
37
+ init: function () {
38
+ // Buffer for setting the data obtained and notifying consumers
39
+ this.notiBuffer = new NotiBuffer();
40
+ this.tableBars = this.data.tableBars;
41
+ },
30
42
 
31
43
  /**
32
44
  * Called when component is attached and when component data changes.
@@ -34,161 +46,220 @@ AFRAME.registerComponent('babia-queryes', {
34
46
  */
35
47
 
36
48
  update: function (oldData) {
49
+ this.oldData = oldData;
50
+ let notiData = ''
51
+ if (this.data.rangeSelector){
52
+ let prodElement = document.getElementById(this.data.rangeSelector);
53
+ if (prodElement.components['babia-range-selector']) {
54
+ this.prodComponent = prodElement.components['babia-range-selector']
55
+ }
56
+ if (this.prodComponent.notiBuffer) {
57
+ this.notiBufferId = this.prodComponent.notiBuffer
58
+ .register(this.updateQuerier.bind(this))
59
+ notiData = this.prodComponent.notiBuffer.data;
60
+ }
61
+ }
62
+ this.updateQuerier(notiData)
63
+ },
64
+
65
+ updateQuerier: function (received){
37
66
  let data = this.data;
38
- let el = this.el;
39
- let self = this;
67
+ let oldData = this.oldData;
40
68
 
41
69
  // Highest priority to data
42
70
  if (data.data && oldData.data !== data.data) {
43
- parseEmbeddedJSONData(data.data, el, self)
71
+ let _data = parseJson(data.data)
72
+ this.notiBuffer.set(_data);
44
73
  } else {
45
74
  if (data.elasticsearch_url !== oldData.elasticsearch_url ||
46
75
  data.index !== oldData.index ||
47
76
  data.query !== oldData.query ||
48
77
  data.size !== oldData.size) {
49
78
  if (data.elasticsearch_url && data.index) {
50
- requestJSONDataFromES(data, el, self)
79
+ this.getJSON(data, received);
51
80
  } else {
52
81
  console.error("elasicsearch_url and index must be defined")
53
82
  return
54
83
  }
84
+ } else if (received) {
85
+ this.getJSON(data, received);
55
86
  }
56
87
  }
57
88
  },
58
- /**
59
- * Called when a component is removed (e.g., via removeAttribute).
60
- * Generally undoes all modifications to the entity.
61
- */
62
- remove: function () { },
63
-
64
- /**
65
- * Called on each scene tick.
66
- */
67
- // tick: function (t) { },
68
-
69
- /**
70
- * Called when entity pauses.
71
- * Use to stop or remove any dynamic or background behavior such as events.
72
- */
73
- pause: function () { },
74
-
75
- /**
76
- * Called when entity resumes.
77
- * Use to continue or add any dynamic or background behavior such as events.
78
- */
79
- play: function () { },
80
-
81
- /**
82
- * Where the data is gonna be stored
83
- */
84
- babiaData: undefined,
85
-
86
- /**
87
- * Where the metaddata is gonna be stored
88
- */
89
- babiaMetadata: {
90
- id: 0
91
- },
92
89
 
93
- /**
94
- * Register function
95
- */
96
- register: function (interestedElem) {
97
- let el = this.el
98
- this.interestedElements.push(interestedElem)
90
+ getJSON: async function (data, received) {
91
+ let url;
92
+ let response;
99
93
 
100
- // Send the latest version of the data
101
- if (this.babiaData) {
102
- dispatchEventOnElement(interestedElem, "babiaData")
94
+ if (data.size && data.query) {
95
+ url = `${data.elasticsearch_url}/${data.index}/_search?size=${data.size}&${data.query}`;
96
+ if (data.user && data.password) {
97
+ let headers = new Headers();
98
+ headers.append('Authorization', 'Basic ' + btoa(data.user + ':' + data.password));
99
+ response = await fetch(url, { headers: headers })
100
+ } else {
101
+ response = await fetch(url);
102
+ }
103
+ } else if (data.request) {
104
+ url = `${data.elasticsearch_url}/${data.index}/_search`;
105
+ // Get request body
106
+ let request = await fetch(data.request);
107
+ if (request.status == 200) {
108
+ this.json = await request.json();
109
+ // TODO: Throw error if json is not in the right format
110
+ this.json = parseJson(this.json);
111
+ // Modify the request with new range
112
+ if (received){
113
+ // range index
114
+ let index
115
+ for (let i = 0; i < this.json['query']['bool']['must'].length; i++){
116
+ if (this.json['query']['bool']['must'][i]['range']){
117
+ index = i;
118
+ }
119
+ }
120
+ let range = this.json['query']['bool']['must'][index]['range'][Object.keys(this.json['query']['bool']['must'][index]['range'])[0]]
121
+ range['gte'] = received.from;
122
+ range['lte'] = received.to;
123
+ }
124
+ } else {
125
+ throw new Error(request.status);
126
+ }
127
+ //console.log(this.json['aggs'])
128
+ if (data.user && data.password) {
129
+ response = await fetch(url, {
130
+ method: 'POST',
131
+ mode: 'cors',
132
+ headers: {
133
+ 'Accept': 'application/json',
134
+ 'Content-Type': 'application/json',
135
+ 'Access-Control-Allow-Origin': '*',
136
+ 'Authorization': 'Basic ' + btoa(data.user + ':' + data.password),
137
+ },
138
+ body: JSON.stringify(this.json)
139
+ });
140
+ } else {
141
+ response = await fetch(url, {
142
+ method: 'POST',
143
+ mode: 'cors',
144
+ headers: {
145
+ 'Accept': 'application/json',
146
+ 'Content-Type': 'application/json',
147
+ 'Access-Control-Allow-Origin': '*'
148
+ },
149
+ body: JSON.stringify(this.json)
150
+ });
151
+ }
152
+
103
153
  }
104
- },
105
-
106
- /**
107
- * Unregister function
108
- */
109
- unregister: function (interestedElem) {
110
- const index = this.interestedElements.indexOf(interestedElem)
111
-
112
- // Remove from the interested elements if still there
113
- if (index > -1) {
114
- this.interestedElements.splice(index, 1);
154
+ if (response.status == 200) {
155
+ let json = await response.json();
156
+ //console.log(json);
157
+ json = this.parseDataES(json);
158
+ // TODO: throw error if json is not in the right format
159
+ this.notiBuffer.set(json);
160
+ return;
115
161
  }
162
+ throw new Error(response.status);
116
163
  },
117
164
 
118
- /**
119
- * Interested elements
120
- */
121
- interestedElements: [],
122
- })
123
-
124
-
125
- let requestJSONDataFromES = (data, el, self) => {
126
- // Create a new request object
127
- let request = new XMLHttpRequest();
128
-
129
- // Initialize a request
130
- request.open('get', `${data.elasticsearch_url}/${data.index}/_search?size=${data.size}&${data.query}`)
131
- // Send it
132
- request.onload = function () {
133
- if (this.status >= 200 && this.status < 300) {
134
- // Save data
135
- if (typeof request.response === 'string' || request.response instanceof String) {
136
- dataRaw = JSON.parse(request.response).hits.hits
137
- let dataRetrieved = []
138
- for (let i = 0; i < dataRaw.length; i++) {
139
- dataRetrieved[i] = dataRaw[i]._source
140
- }
141
- } else {
142
- // Why this case
143
- let dataRetrieved = []
144
- console.error("Unexpected response", request.response)
165
+ parseDataES: function (data) {
166
+ let save = []
167
+ console.log('REQUEST:', this.json);
168
+ console.log('REPLY:', data)
169
+ let aggs = Object.keys(data.aggregations)
170
+ if (this.json['aggs'] && aggs.length == 1 && !this.json['aggs'][aggs[0]]['aggs']) {
171
+ data = data.aggregations[aggs[0]].buckets
172
+ for (let i = 0; i < data.length; i++) {
173
+ save.push(data[i])
145
174
  }
146
-
147
- // Save
148
- self.babiaData = dataRetrieved
149
- self.babiaMetadata = {
150
- id: self.babiaMetadata.id++
175
+ } else if (this.json['aggs'] && aggs.length == 1 && this.json['aggs'][aggs[0]]['aggs']) {
176
+ data = data.aggregations[aggs[0]].buckets
177
+ for (let i = 0; i < data.length; i++) {
178
+ //console.log(data[0][Object.keys(data[0])[0]].buckets.length)
179
+ if (data[0][Object.keys(data[0])[0]].values) {
180
+ save.push({
181
+ key_as_string: data[i].key_as_string,
182
+ key: data[i].key,
183
+ doc_count: data[i].doc_count,
184
+ value: data[i][Object.keys(data[0])[0]].values[0].value
185
+ })
186
+ } else if (data[0][Object.keys(data[0])[0]].value && data[0][Object.keys(data[0])[0]].length == 1) {
187
+ save.push({
188
+ key_as_string: data[i].key_as_string,
189
+ key: data[i].key,
190
+ doc_count: data[i].doc_count,
191
+ value: data[i][Object.keys(data[0])[0]].value
192
+ })
193
+ } else if (data[0][Object.keys(data[0])[0]].buckets && data[0][Object.keys(data[0])[0]].buckets.length > 0) {
194
+ for (let j = 0; j < data[i][Object.keys(data[0])[0]].buckets.length; j++) {
195
+ save.push({
196
+ key_as_string: data[i].key_as_string,
197
+ key: data[i][Object.keys(data[0])[0]].buckets[j].key,
198
+ count: data[i][Object.keys(data[0])[0]].buckets[j].doc_count,
199
+ doc_count: data[i].doc_count,
200
+ value: data[i][Object.keys(data[0])[0]].value
201
+ })
202
+ }
203
+ } else if (Object.keys(data[0]).length > 1) {
204
+ if (this.tableBars == true) {
205
+ // ONLY FROM TABLE TO BARS
206
+ save.push({
207
+ key_as_string: aggs[0],
208
+ key: data[i].key,
209
+ value: data[i].doc_count
210
+ })
211
+ for (let j = 0; j < Object.keys(data[0]).length; j++) {
212
+ if (data[i][Object.keys(data[0])[j]].value) {
213
+ save.push({
214
+ key_as_string: Object.keys(data[0])[j],
215
+ key: data[i].key,
216
+ value: data[i][Object.keys(data[0])[j]].value
217
+ })
218
+ }
219
+ }
220
+ } else {
221
+ // DEFAULT TABLE
222
+ let element = {
223
+ key: data[i].key,
224
+ value: data[i].doc_count
225
+ };
226
+ if (data[i].key_as_string) {
227
+ element['key_as_string'] = data[i].key_as_string;
228
+ } else {
229
+ element['key_as_string'] = aggs[0];
230
+ }
231
+ for (let j = 0; j < Object.keys(data[0]).length; j++) {
232
+ if (data[i][Object.keys(data[0])[j]].value) {
233
+ element[Object.keys(data[0])[j]] = data[i][Object.keys(data[0])[j]].value;
234
+ }
235
+ }
236
+ if (data[0][Object.keys(data[0])[0]].buckets) {
237
+ for (let j = 0; j < Object.keys(data[0][Object.keys(data[0])[0]].buckets).length; j++) {
238
+ //console.log(Object.keys(data[i][Object.keys(data[i])[0]].buckets[Object.keys(data[i][Object.keys(data[i])[0]].buckets)[j]])[0])
239
+ if (data[i][Object.keys(data[i])[0]].buckets[Object.keys(data[i][Object.keys(data[i])[0]].buckets)[j]][Object.keys(data[i][Object.keys(data[i])[0]].buckets[Object.keys(data[i][Object.keys(data[i])[0]].buckets)[j]])[0]].value) {
240
+ element[Object.keys(data[i][Object.keys(data[i])[0]].buckets)[j]] = data[i][Object.keys(data[i])[0]].buckets[Object.keys(data[i][Object.keys(data[i])[0]].buckets)[j]][Object.keys(data[i][Object.keys(data[i])[0]].buckets[Object.keys(data[i][Object.keys(data[i])[0]].buckets)[j]])[0]].value;
241
+ } else {
242
+ element[Object.keys(data[i][Object.keys(data[i])[0]].buckets)[j]] = data[i][Object.keys(data[i])[0]].buckets[Object.keys(data[i][Object.keys(data[i])[0]].buckets)[j]].doc_count;
243
+ }
244
+ }
245
+ }
246
+ save.push(element);
247
+ }
248
+ } else {
249
+ save.push({
250
+ key_as_string: data[i].key_as_string,
251
+ key: data[i].key,
252
+ doc_count: data[i].doc_count
253
+ })
254
+ }
151
255
  }
152
-
153
- // Dispatch/Trigger/Fire the event
154
- dataReadyToSend("babiaData", self)
155
-
156
256
  } else {
157
- reject({
158
- status: this.status,
159
- statusText: xhr.statusText
160
- });
161
- console.error("Error during requesting data", this.status, xhr.statusText)
257
+ data = data.hits.hits;
258
+ for (let i = 0; i < data.length; i++) {
259
+ save[i] = data[i]._source
260
+ }
162
261
  }
163
- };
164
- request.onerror = function () {
165
- reject({
166
- status: this.status,
167
- statusText: xhr.statusText
168
- });
169
- console.error("Error during requesting data", this.status, xhr.statusText)
170
- };
171
- request.send();
172
- }
173
-
174
- let parseEmbeddedJSONData = (embedded, el, self) => {
175
- // Save data
176
- let dataRetrieved = JSON.parse(embedded)
177
- self.babiaData = dataRetrieved
178
- self.babiaMetadata = {
179
- id: self.babiaMetadata.id++
262
+ //console.log(save)
263
+ return save
180
264
  }
181
-
182
- // Dispatch/Trigger/Fire the event
183
- dataReadyToSend("babiaData", self)
184
- }
185
-
186
- let dataReadyToSend = (propertyName, self) => {
187
- self.interestedElements.forEach(element => {
188
- dispatchEventOnElement(element, propertyName)
189
- });
190
- }
191
-
192
- let dispatchEventOnElement = (element, propertyName) => {
193
- element.emit("babiaQuerierDataReady", propertyName)
194
- }
265
+ })
@@ -1,7 +1,6 @@
1
- let findProdComponent = require('../others/common').findProdComponent;
2
1
  let updateTitle = require('../others/common').updateTitle;
3
- let parseJson = require('../others/common').parseJson;
4
2
  const colors = require('../others/common').colors;
3
+ let updateFunction = require('../others/common').updateFunction;
5
4
 
6
5
  const NotiBuffer = require("../../common/noti-buffer").NotiBuffer;
7
6
 
@@ -74,40 +73,10 @@ AFRAME.registerComponent('babia-bars', {
74
73
  */
75
74
 
76
75
  update: function (oldData) {
77
- let data = this.data;
78
- let el = this.el;
79
-
80
- if (!data.index){
81
- data.index = data.x_axis
76
+ updateFunction(this, oldData)
77
+ if (this.data.uiLink){
78
+ createUiLink(el, this.data.uiLinkPosition)
82
79
  }
83
-
84
- console.log("Starting Bars");
85
- this.animation = data.animation
86
- this.bar_array = []
87
-
88
- if (data.data && oldData.data !== data.data) {
89
- let _data = parseJson(data.data);
90
- this.processData(_data);
91
- } else if (data.from !== oldData.from) {
92
- // Unregister from old producer
93
- if (this.prodComponent) {
94
- this.prodComponent.notiBuffer.unregister(this.notiBufferId)
95
- };
96
- this.prodComponent = findProdComponent(data, el)
97
- if (this.prodComponent.notiBuffer){
98
- this.notiBufferId = this.prodComponent.notiBuffer
99
- .register(this.processData.bind(this))
100
- }
101
- }
102
- // If changed whatever, re-print with the current data
103
- else if (data !== oldData && this.newData) {
104
- this.slice_array = []
105
- this.processData(this.newData);
106
- }
107
- if (data.uiLink){
108
- createUiLink(el, data.uiLinkPosition)
109
- }
110
-
111
80
  },
112
81
 
113
82
  /**
@@ -2,6 +2,7 @@ let findProdComponent = require('../others/common').findProdComponent;
2
2
  let updateTitle = require('../others/common').updateTitle;
3
3
  let parseJson = require('../others/common').parseJson;
4
4
  const colors = require('../others/common').colors;
5
+ let updateFunction = require('../others/common').updateFunction;
5
6
 
6
7
  const NotiBuffer = require("../../common/noti-buffer").NotiBuffer;
7
8
 
@@ -73,36 +74,7 @@ AFRAME.registerComponent('babia-barsmap', {
73
74
  */
74
75
 
75
76
  update: function (oldData) {
76
- let data = this.data;
77
- let el = this.el;
78
-
79
- if (!data.index){
80
- data.index = data.x_axis
81
- }
82
-
83
- console.log("Starting Barsmap");
84
- this.animation = data.animation
85
- this.bar_array = []
86
-
87
- if (data.data && oldData.data !== data.data) {
88
- let _data = parseJson(data.data);
89
- this.processData(_data);
90
- } else if (this.data.from !== oldData.from) {
91
- // Unregister from old producer
92
- if (this.prodComponent) {
93
- this.prodComponent.notiBuffer.unregister(this.notiBufferId)
94
- };
95
- this.prodComponent = findProdComponent(this.data, el)
96
- if (this.prodComponent.notiBuffer) {
97
- this.notiBufferId = this.prodComponent.notiBuffer
98
- .register(this.processData.bind(this))
99
- }
100
- }
101
- // If changed whatever, re-print with the current data
102
- else if (data !== oldData && this.newData) {
103
- this.slice_array = []
104
- this.processData(this.newData);
105
- }
77
+ updateFunction(this, oldData)
106
78
  },
107
79
 
108
80
  /**