aframe-babia-components 1.2.2 → 1.2.5

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 (120) 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-bar.js +13 -1
  4. package/components/geometries/babia-cyl.js +189 -0
  5. package/components/others/assets/tooltip.png +0 -0
  6. package/components/others/babia-camera.js +195 -0
  7. package/components/others/babia-controls.js +56 -31
  8. package/components/others/babia-navigator.js +55 -49
  9. package/components/others/babia-range-selector.js +218 -0
  10. package/components/others/babia-slider.js +36 -8
  11. package/components/others/babia-ui.js +246 -73
  12. package/components/others/common.js +91 -83
  13. package/components/queriers/babia-querycsv.js +96 -0
  14. package/components/queriers/babia-queryes.js +209 -131
  15. package/components/visualizers/babia-bars.js +15 -38
  16. package/components/visualizers/babia-barsmap.js +19 -34
  17. package/components/visualizers/babia-boats.js +221 -134
  18. package/components/visualizers/babia-bubbles.js +13 -26
  19. package/components/visualizers/babia-cyls.js +203 -201
  20. package/components/visualizers/babia-cylsmap.js +173 -241
  21. package/components/visualizers/babia-doughnut.js +6 -28
  22. package/components/visualizers/babia-network.js +191 -124
  23. package/components/visualizers/babia-pie.js +6 -30
  24. package/dist/aframe-babia-components.js +21913 -19571
  25. package/dist/aframe-babia-components.min.js +7 -1
  26. package/dist/aframe-babia-components.min.js.map +1 -1
  27. package/docs/APIs/CHARTS.md +33 -14
  28. package/docs/APIs/DATAMANAGEMENT.md +7 -0
  29. package/docs/APIs/OTHERS.md +42 -0
  30. package/docs/APIs/QUERIERS.md +18 -0
  31. package/docs/RELEASE_NOTES.md +58 -21
  32. package/docs/Tutorials/multiuser.md +47 -2
  33. package/examples/assets/door/New Bitmap Image.jpg +0 -0
  34. package/examples/assets/door/door.mtl +26 -0
  35. package/examples/assets/door/door.obj +6927 -0
  36. package/examples/assets/popups/0.png +0 -0
  37. package/examples/assets/popups/1.png +0 -0
  38. package/examples/assets/popups/10.png +0 -0
  39. package/examples/assets/popups/2.png +0 -0
  40. package/examples/assets/popups/3.png +0 -0
  41. package/examples/assets/popups/4.png +0 -0
  42. package/examples/assets/popups/5.png +0 -0
  43. package/examples/assets/popups/6.png +0 -0
  44. package/examples/assets/popups/7.png +0 -0
  45. package/examples/assets/popups/8.png +0 -0
  46. package/examples/assets/popups/9.png +0 -0
  47. package/examples/assets/popups/close.jpg +0 -0
  48. package/examples/assets/popups/info.jpg +0 -0
  49. package/examples/assets/textures/brownwall.png +0 -0
  50. package/examples/assets/textures/concrete.png +0 -0
  51. package/examples/assets/textures/white-wall-texture.jpg +0 -0
  52. package/examples/charts/cyls/index.html +13 -4
  53. package/examples/charts/cyls/primitive.html +76 -0
  54. package/examples/charts/cylsmap/index.html +14 -5
  55. package/examples/charts_querier/bars_querier/data.csv +10 -0
  56. package/examples/charts_querier/bars_querier/index_csv.html +80 -0
  57. package/examples/charts_querier/multichart_querier/manual_colors.html +81 -0
  58. package/examples/dashboard/chaoss-dashboards.html +259 -0
  59. package/examples/dashboard/chaoss-issues.html +248 -0
  60. package/examples/dashboard/chaoss-pr.html +248 -0
  61. package/examples/dashboard/index.html +247 -0
  62. package/examples/dashboard/issues_queries/80-percent-open-time.json +123 -0
  63. package/examples/dashboard/issues_queries/issues-by-organization.json +107 -0
  64. package/examples/dashboard/issues_queries/issues.json +117 -0
  65. package/examples/dashboard/issues_queries/median-open-time.json +123 -0
  66. package/examples/dashboard/issues_queries/organizations.json +130 -0
  67. package/examples/dashboard/issues_queries/projects.json +130 -0
  68. package/examples/dashboard/issues_queries/repositories.json +130 -0
  69. package/examples/dashboard/issues_queries/status.json +107 -0
  70. package/examples/dashboard/issues_queries/submitter.json +125 -0
  71. package/examples/dashboard/issues_queries/submitters.json +113 -0
  72. package/examples/dashboard/pullrequests_queries/80-percent-open-time.json +123 -0
  73. package/examples/dashboard/pullrequests_queries/median-open-time.json +123 -0
  74. package/examples/dashboard/pullrequests_queries/organizations.json +130 -0
  75. package/examples/dashboard/pullrequests_queries/projects.json +130 -0
  76. package/examples/dashboard/pullrequests_queries/pull-requests-by-organization.json +107 -0
  77. package/examples/dashboard/pullrequests_queries/pull-requests.json +117 -0
  78. package/examples/dashboard/pullrequests_queries/repositories.json +130 -0
  79. package/examples/dashboard/pullrequests_queries/status.json +107 -0
  80. package/examples/dashboard/pullrequests_queries/submitter.json +125 -0
  81. package/examples/dashboard/pullrequests_queries/submitters.json +113 -0
  82. package/examples/dashboard/range.html +88 -0
  83. package/examples/dashboard/template.html +136 -0
  84. package/examples/demos/1.0.11/index_multiuser_ui.html +1 -1
  85. package/examples/multi_bars/data.json +14 -0
  86. package/examples/multi_bars/data2.json +15 -0
  87. package/examples/multi_bars/data3.json +23 -0
  88. package/examples/multi_bars/easyrtc.js +11984 -0
  89. package/examples/multi_bars/index.html +97 -0
  90. package/examples/multi_bars/index1.html +111 -0
  91. package/examples/multi_bars/index2.html +102 -0
  92. package/examples/multi_bars/index3.html +104 -0
  93. package/examples/multi_boats/data3.json +174 -0
  94. package/examples/multi_boats/data4.json +192 -0
  95. package/examples/multi_boats/{index.html → index_multi_boats.html} +50 -55
  96. package/examples/multi_boats/jetuml.html +124 -115
  97. package/examples/multi_boats/jetuml_evolution_experiment.html +419 -0
  98. package/examples/multi_boats/only_queryjson.html +132 -0
  99. package/examples/multi_boats/only_queryjson2.html +167 -0
  100. package/examples/multi_boats/only_queryjson3.html +165 -0
  101. package/examples/multi_boats/queryjson_treebuilder.html +132 -0
  102. package/examples/multi_boats/with_selector.html +121 -111
  103. package/examples/multiuser/choose_avatar/index.html +18 -8
  104. package/examples/selector_boats/jetuml_from_3_2_to_1_0.json +62382 -0
  105. package/examples/ui/network/data.json +123 -0
  106. package/examples/ui/network/links.json +13 -0
  107. package/examples/ui/network/network.html +75 -0
  108. package/examples/ui/network/network_nodes_links.html +82 -0
  109. package/examples/ui/network/nodes.json +12 -0
  110. package/index.html +69 -3
  111. package/index.js +6 -1
  112. package/package.json +4 -3
  113. package/tests/screenshots/other_snapshots.js/chaoss-issues.png +0 -0
  114. package/tests/screenshots/other_snapshots.js/chaoss-pr.png +0 -0
  115. package/tests/screenshots/other_snapshots.js/template.png +0 -0
  116. package/tests/ui.js +7 -0
  117. package/webpack.common.js +1 -1
  118. package/webpack.devnossl.js +16 -0
  119. package/.idea/vcs.xml +0 -6
  120. package/.idea/workspace.xml +0 -79
@@ -0,0 +1,96 @@
1
+ let parseCSV = require('papaparse').parse;
2
+
3
+ /* global AFRAME */
4
+ if (typeof AFRAME === 'undefined') {
5
+ throw new Error('Component attempted to register before AFRAME was available.');
6
+ }
7
+
8
+ const NotiBuffer = require("../../common/noti-buffer").NotiBuffer;
9
+
10
+ /**
11
+ * Babia QueryCSV component for A-Frame.
12
+ */
13
+ AFRAME.registerComponent('babia-querycsv', {
14
+ schema: {
15
+ url: { type: 'string' },
16
+ // data, for debugging, highest priority
17
+ data: { type: 'string' }
18
+ },
19
+
20
+ /**
21
+ * Set if component needs multiple instancing.
22
+ */
23
+ multiple: false,
24
+
25
+ /**
26
+ * Called once when component is attached. Generally for initial setup.
27
+ */
28
+ init: function () {
29
+ // Buffer for setting the data obtained and notifying consumers
30
+ this.notiBuffer = new NotiBuffer();
31
+ },
32
+
33
+ /**
34
+ * Called when component is attached and when component data changes.
35
+ * Generally modifies the entity based on the data.
36
+ */
37
+
38
+ update: function (oldData) {
39
+ let data = this.data;
40
+
41
+ // Highest priority to data
42
+ if (data.data && oldData.data !== data.data) {
43
+ let _data = parseCSV(data.data, {
44
+ header: true, dynamicTyping: true,
45
+ skipEmptyLines: true
46
+ });
47
+ this.notiBuffer.set(_data['data']);
48
+ } else if (oldData.url !== data.url) {
49
+ this.getCSV(data.url);
50
+ }
51
+ },
52
+ /**
53
+ * Called when a component is removed (e.g., via removeAttribute).
54
+ * Generally undoes all modifications to the entity.
55
+ */
56
+ remove: function () { },
57
+
58
+ /**
59
+ * Called on each scene tick.
60
+ */
61
+ // tick: function (t) { },
62
+
63
+ /**
64
+ * Called when entity pauses.
65
+ * Use to stop or remove any dynamic or background behavior such as events.
66
+ */
67
+ pause: function () { },
68
+
69
+ /**
70
+ * Called when entity resumes.
71
+ * Use to continue or add any dynamic or background behavior such as events.
72
+ */
73
+ play: function () { },
74
+
75
+ /*
76
+ * Asynchronous function to get a JSON document.
77
+ * Returns a promise that resolves to the object corresponding to the
78
+ * retrieved JSON document, or to undefined, if some error happened.
79
+ * It is non blocking, since it gives a promise. No value has to be
80
+ * obtained once fulfilled and all the synchronous code is inside the
81
+ * function (two awaits that block the code until promises are fulfilled)
82
+ */
83
+
84
+ getCSV: async function(url) {
85
+ let notiBuffer = this.notiBuffer
86
+ parseCSV(url, {
87
+ download: true, header: true, skipEmptyLines: true,
88
+ dynamicTyping: true,
89
+ complete: function(response) {
90
+ notiBuffer.set(response['data']);
91
+ }
92
+ });
93
+ },// TODO: Try-catch to get and print errors outside
94
+
95
+
96
+ })
@@ -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,227 @@ 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
89
 
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 () { },
90
+ getJSON: async function (data, received) {
91
+ let url;
92
+ let response;
74
93
 
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
-
93
- /**
94
- * Register function
95
- */
96
- register: function (interestedElem) {
97
- let el = this.el
98
- this.interestedElements.push(interestedElem)
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;
99
123
 
100
- // Send the latest version of the data
101
- if (this.babiaData) {
102
- dispatchEventOnElement(interestedElem, "babiaData")
124
+ // Interval para date_histograms
125
+ if (this.json['aggs']['2']){
126
+ if(this.json['aggs']['2']['date_histogram']){
127
+ this.json['aggs']['2']['date_histogram']['interval'] = received.interval
128
+ }
129
+ }
130
+ }
131
+ } else {
132
+ throw new Error(request.status);
133
+ }
134
+ //console.log(this.json['aggs'])
135
+ if (data.user && data.password) {
136
+ response = await fetch(url, {
137
+ method: 'POST',
138
+ mode: 'cors',
139
+ headers: {
140
+ 'Accept': 'application/json',
141
+ 'Content-Type': 'application/json',
142
+ 'Access-Control-Allow-Origin': '*',
143
+ 'Authorization': 'Basic ' + btoa(data.user + ':' + data.password),
144
+ },
145
+ body: JSON.stringify(this.json)
146
+ });
147
+ } else {
148
+ response = await fetch(url, {
149
+ method: 'POST',
150
+ mode: 'cors',
151
+ headers: {
152
+ 'Accept': 'application/json',
153
+ 'Content-Type': 'application/json',
154
+ 'Access-Control-Allow-Origin': '*'
155
+ },
156
+ body: JSON.stringify(this.json)
157
+ });
158
+ }
159
+
103
160
  }
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);
161
+ if (response.status == 200) {
162
+ let json = await response.json();
163
+ //console.log(json);
164
+ json = this.parseDataES(json);
165
+ // TODO: throw error if json is not in the right format
166
+ this.notiBuffer.set(json);
167
+ return;
115
168
  }
169
+ throw new Error(response.status);
116
170
  },
117
171
 
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)
172
+ parseDataES: function (data) {
173
+ let save = []
174
+ console.log('REQUEST:', this.json);
175
+ console.log('REPLY:', data)
176
+ let aggs = Object.keys(data.aggregations)
177
+ if (this.json['aggs'] && aggs.length == 1 && !this.json['aggs'][aggs[0]]['aggs']) {
178
+ data = data.aggregations[aggs[0]].buckets
179
+ for (let i = 0; i < data.length; i++) {
180
+ save.push(data[i])
145
181
  }
146
-
147
- // Save
148
- self.babiaData = dataRetrieved
149
- self.babiaMetadata = {
150
- id: self.babiaMetadata.id++
182
+ } else if (this.json['aggs'] && aggs.length == 1 && this.json['aggs'][aggs[0]]['aggs']) {
183
+ data = data.aggregations[aggs[0]].buckets
184
+ for (let i = 0; i < data.length; i++) {
185
+ //console.log(data[0][Object.keys(data[0])[0]].buckets.length)
186
+ if (data[0][Object.keys(data[0])[0]].values) {
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]].values[0].value
192
+ })
193
+ } else if (data[0][Object.keys(data[0])[0]].value && data[0][Object.keys(data[0])[0]].length == 1) {
194
+ save.push({
195
+ key_as_string: data[i].key_as_string,
196
+ key: data[i].key,
197
+ doc_count: data[i].doc_count,
198
+ value: data[i][Object.keys(data[0])[0]].value
199
+ })
200
+ } else if (data[0][Object.keys(data[0])[0]].buckets && data[0][Object.keys(data[0])[0]].buckets.length > 0) {
201
+ for (let j = 0; j < data[i][Object.keys(data[0])[0]].buckets.length; j++) {
202
+ save.push({
203
+ key_as_string: data[i].key_as_string,
204
+ key: data[i][Object.keys(data[0])[0]].buckets[j].key,
205
+ count: data[i][Object.keys(data[0])[0]].buckets[j].doc_count,
206
+ doc_count: data[i].doc_count,
207
+ value: data[i][Object.keys(data[0])[0]].value
208
+ })
209
+ }
210
+ } else if (Object.keys(data[0]).length > 1) {
211
+ if (this.tableBars == true) {
212
+ // ONLY FROM TABLE TO BARS
213
+ save.push({
214
+ key_as_string: aggs[0],
215
+ key: data[i].key,
216
+ value: data[i].doc_count
217
+ })
218
+ for (let j = 0; j < Object.keys(data[0]).length; j++) {
219
+ if (data[i][Object.keys(data[0])[j]].value) {
220
+ save.push({
221
+ key_as_string: Object.keys(data[0])[j],
222
+ key: data[i].key,
223
+ value: data[i][Object.keys(data[0])[j]].value
224
+ })
225
+ }
226
+ }
227
+ } else {
228
+ // DEFAULT TABLE
229
+ let element = {
230
+ key: data[i].key,
231
+ value: data[i].doc_count
232
+ };
233
+ if (data[i].key_as_string) {
234
+ element['key_as_string'] = data[i].key_as_string;
235
+ } else {
236
+ element['key_as_string'] = aggs[0];
237
+ }
238
+ for (let j = 0; j < Object.keys(data[0]).length; j++) {
239
+ if (data[i][Object.keys(data[0])[j]].value) {
240
+ element[Object.keys(data[0])[j]] = data[i][Object.keys(data[0])[j]].value;
241
+ }
242
+ }
243
+ if (data[0][Object.keys(data[0])[0]].buckets) {
244
+ for (let j = 0; j < Object.keys(data[0][Object.keys(data[0])[0]].buckets).length; j++) {
245
+ //console.log(Object.keys(data[i][Object.keys(data[i])[0]].buckets[Object.keys(data[i][Object.keys(data[i])[0]].buckets)[j]])[0])
246
+ 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) {
247
+ 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;
248
+ } else {
249
+ 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;
250
+ }
251
+ }
252
+ }
253
+ save.push(element);
254
+ }
255
+ } else {
256
+ save.push({
257
+ key_as_string: data[i].key_as_string,
258
+ key: data[i].key,
259
+ doc_count: data[i].doc_count
260
+ })
261
+ }
151
262
  }
152
-
153
- // Dispatch/Trigger/Fire the event
154
- dataReadyToSend("babiaData", self)
155
-
156
263
  } else {
157
- reject({
158
- status: this.status,
159
- statusText: xhr.statusText
160
- });
161
- console.error("Error during requesting data", this.status, xhr.statusText)
264
+ data = data.hits.hits;
265
+ for (let i = 0; i < data.length; i++) {
266
+ save[i] = data[i]._source
267
+ }
162
268
  }
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++
269
+ //console.log(save)
270
+ return save
180
271
  }
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
- }
272
+ })
@@ -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
 
@@ -20,6 +19,8 @@ AFRAME.registerComponent('babia-bars', {
20
19
  x_axis: { type: 'string', default: 'x_axis' },
21
20
  from: { type: 'string' },
22
21
  legend: { type: 'boolean', default: false },
22
+ legend_lookat: { type: 'string', default: "[camera]" },
23
+ legend_scale: { type: 'number', default: 1 },
23
24
  axis: { type: 'boolean', default: true },
24
25
  // Name for axis
25
26
  axis_name: {type: 'boolean', default: false},
@@ -74,40 +75,10 @@ AFRAME.registerComponent('babia-bars', {
74
75
  */
75
76
 
76
77
  update: function (oldData) {
77
- let data = this.data;
78
- let el = this.el;
79
-
80
- if (!data.index){
81
- data.index = data.x_axis
78
+ updateFunction(this, oldData)
79
+ if (this.data.uiLink){
80
+ createUiLink(el, this.data.uiLinkPosition)
82
81
  }
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
82
  },
112
83
 
113
84
  /**
@@ -273,7 +244,9 @@ AFRAME.registerComponent('babia-bars', {
273
244
  });
274
245
  if (data.legend) {
275
246
  barEl.setAttribute('babia-bar', {
276
- 'labelText': xLabel + ': ' + item[data.height]
247
+ 'labelText': xLabel + ': ' + item[data.height],
248
+ 'labelLookat': data.legend_lookat,
249
+ 'labelScale': data.legend_scale
277
250
  });
278
251
  };
279
252
  if (posX !== barEl.object3D.position.x) {
@@ -348,7 +321,9 @@ AFRAME.registerComponent('babia-bars', {
348
321
  this.chartEl.querySelector('#' + bar[data.index]).setAttribute('babia-bar',
349
322
  {
350
323
  'height': bar[data.height] * data.chartHeight / this.maxValue,
351
- 'labelText': bar[data.index] + ': ' + bar[data.height]
324
+ 'labelText': bar[data.index] + ': ' + bar[data.height],
325
+ 'labelLookat': data.legend_lookat,
326
+ 'labelScale': data.legend_scale
352
327
  })
353
328
  } else {
354
329
  // Find last bar and get its position
@@ -393,7 +368,9 @@ let generateBar = (self, data, item, colorId, palette, stepX ) => {
393
368
  });
394
369
  if (data.legend) {
395
370
  bar.setAttribute('babia-bar', {
396
- 'labelText': item[self.data.x_axis] + ': ' + item[self.data.height]
371
+ 'labelText': item[self.data.x_axis] + ': ' + item[self.data.height],
372
+ 'labelLookat': data.legend_lookat,
373
+ 'labelScale': data.legend_scale
397
374
  });
398
375
  };
399
376
  bar.setAttribute('position', { x: stepX, y: 0, z: 0 });