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,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,19 +19,29 @@ AFRAME.registerComponent('babia-cyls', {
20
19
  radius: { type: 'string', default: 'radius' },
21
20
  x_axis: { type: 'string', default: 'x_axis' },
22
21
  from: { type: 'string' },
23
- legend: { type: 'boolean' },
22
+ legend: { type: 'boolean', default: false },
24
23
  axis: { type: 'boolean', default: true },
25
24
  // Name for axis
26
25
  axis_name: {type: 'boolean', default: false},
27
- animation: { type: 'boolean', default: false },
28
26
  palette: { type: 'string', default: 'ubuntu' },
29
27
  title: { type: 'string' },
30
28
  titleFont: { type: 'string' },
31
29
  titleColor: { type: 'string' },
32
- titlePosition: { type: 'string', default: "0 0 0" },
33
- scale: { type: 'number' },
34
- heightMax: { type: 'number' },
35
- radiusMax: { type: 'number' },
30
+ titlePosition: { type: 'vec3', default: {x: 0, y: 0, z: 0} },
31
+ // Height of the chart
32
+ chartHeight: { type: 'number', default: 10 },
33
+ // Maximun of the radius
34
+ radiusMax: { type: 'number', default: 2 },
35
+ // Keep height when updating data
36
+ keepHeight: { type: 'boolean', default: true},
37
+ incremental: { type: 'boolean', default: false},
38
+ index: { type: 'string' },
39
+ // Should this be animated
40
+ animation: { type: 'boolean', default: true},
41
+ // Duration of animations
42
+ dur: { type: 'number', default: 2000},
43
+ uiLink: {type: 'boolean', default: false},
44
+ uiLinkPosition: { type: 'vec3', default: {x: -4.5, y: 2, z: 2.5} },
36
45
  },
37
46
 
38
47
  /**
@@ -49,36 +58,25 @@ AFRAME.registerComponent('babia-cyls', {
49
58
  */
50
59
  init: function () {
51
60
  this.notiBuffer = new NotiBuffer();
61
+
62
+ // Build chartEl
63
+ this.chartEl = document.createElement('a-entity');
64
+ this.chartEl.classList.add('babiaxrChart')
65
+ this.el.appendChild(this.chartEl);
66
+
67
+ // Build titleEl
68
+ this.updateTitle()
69
+ this.el.appendChild(this.titleEl);
52
70
  },
53
71
  /**
54
72
  * Called when component is attached and when component data changes.
55
73
  * Generally modifies the entity based on the data.
56
74
  */
57
75
  update: function (oldData) {
58
- let data = this.data;
59
- let el = this.el;
60
-
61
- /**
62
- * Update or create chart component
63
- */
64
- if (data.data && oldData.data !== data.data) {
65
- let _data = parseJson(data.data);
66
- this.processData(_data);
67
- } else if (data.from !== oldData.from) {
68
- // Unregister from old producer
69
- if (this.prodComponent) {
70
- this.prodComponent.notiBuffer.unregister(this.notiBufferId)
71
- };
72
- this.prodComponent = findProdComponent (data, el)
73
- if (this.prodComponent.notiBuffer) {
74
- this.notiBufferId = this.prodComponent.notiBuffer
75
- .register(this.processData.bind(this))
76
- }
77
- }
78
- // If changed whatever, re-print with the current data
79
- else if (data !== oldData && this.newData) {
80
- this.processData(this.newData)
81
- }
76
+ updateFunction(this, oldData)
77
+ if (this.data.uiLink){
78
+ createUiLink(el, this.data.uiLinkPosition)
79
+ }
82
80
  },
83
81
 
84
82
  /**
@@ -96,6 +94,11 @@ AFRAME.registerComponent('babia-cyls', {
96
94
  */
97
95
  newData: undefined,
98
96
 
97
+ /**
98
+ * Where the previous state data is gonna be stored
99
+ */
100
+ currentData: undefined,
101
+
99
102
  /**
100
103
  * Where the metadata is gonna be stored
101
104
  */
@@ -103,136 +106,150 @@ AFRAME.registerComponent('babia-cyls', {
103
106
  id: 0
104
107
  },
105
108
 
109
+ /**
110
+ * Value max
111
+ */
112
+ valueMax: undefined,
113
+
114
+ xLabels: [],
115
+ xTicks: [],
116
+
106
117
  /*
107
118
  * Update title
108
119
  */
109
120
  updateTitle: function(){
110
121
  const titleRotation = { x: 0, y: 0, z: 0 }
111
- const titleEl = updateTitle(this.data, titleRotation);
112
- this.el.appendChild(titleEl);
122
+ this.titleEl = updateTitle(this.data, titleRotation);
113
123
  },
114
124
 
115
125
  /*
116
126
  * Update chart
117
127
  */
118
128
  updateChart: function () {
119
- const dataToPrint = this.newData;
129
+ let dataToPrint = this.newData;
130
+
131
+ if (this.currentData) {
132
+ dataToPrint = this.currentData;
133
+ } else {
134
+ dataToPrint = this.newData;
135
+ }
120
136
  console.log("Data babia-cyls:", dataToPrint)
121
137
 
122
138
  const data = this.data;
123
- const el = this.el;
139
+ const el = this.el;
124
140
 
125
- const animation = data.animation
126
- const palette = data.palette
127
- const scale = data.scale
141
+ //Print Title
142
+ this.updateTitle();
143
+
144
+ // Height Chart
145
+ let valueMax = Math.max.apply(Math, dataToPrint.map(function (o) { return o[data.height]; }))
146
+ if (!this.lengthY) {
147
+ this.lengthY = data.chartHeight;
148
+ } else if (!data.keepHeight) {
149
+ this.lengthY = this.lengthY * maxValue / this.maxValue;
150
+ };
151
+ this.maxValue = valueMax;
152
+
153
+ // Proportion of the radius
154
+ let maxRadius = Math.max.apply(Math, dataToPrint.map(function (o) { return o[data.radius]; }))
155
+ this.radius_scale = data.radiusMax / maxRadius;
156
+
157
+ // List current cylinders
158
+ let chartEl = this.chartEl;
159
+ let cyls = chartEl.querySelectorAll('a-entity[babia-cyl]');
160
+ let currentCyls = {};
161
+ for (let cyl of cyls) {
162
+ let cylName = cyl.getAttribute('babia-name');
163
+ currentCyls[cylName] = {'el': cyl, 'found': false};
164
+ };
128
165
 
129
- let heightMax = data.heightMax
130
- let radiusMax = data.radiusMax
131
-
132
166
  let xLabels = [];
133
167
  let xTicks = [];
134
168
  let colorId = 0
135
- let stepX = 1
136
- let firstradius = 0
137
- let lastradius = 0
138
-
139
- let valueMax = Math.max.apply(Math, dataToPrint.map(function (o) { return o[data.height]; }))
140
- let maxRadius = Math.max.apply(Math, dataToPrint.map(function (o) { return o[data.radius]; }))
141
-
142
- if (scale) {
143
- valueMax = valueMax / scale
144
- maxRadius = maxRadius / scale
145
- }
146
- if (!heightMax){
147
- heightMax = valueMax
148
- }
149
- proportion = heightMax / valueMax
150
-
151
- if (!radiusMax){
152
- radiusMax = maxRadius
153
- }
154
- radius_scale = radiusMax / maxRadius
155
-
156
- this.chartEl = document.createElement('a-entity');
157
- this.chartEl.classList.add('babiaxrChart')
158
- el.appendChild(this.chartEl)
159
-
160
- for (let cylinder of dataToPrint) {
161
- let xLabel = cylinder[data.x_axis]
162
- let radius = cylinder[data.radius]
163
- let height = cylinder[data.height]
164
-
165
- if (cylinder !== dataToPrint[0]) {
166
- //Calculate stepX
167
- if (scale) {
168
- stepX += lastradius + radius / scale + 0.5
169
- } else{
170
- stepX += lastradius + radius * radius_scale + 0.5
171
- }
172
-
169
+
170
+ let last_radius; // Needed to calculate separation between cyls
171
+ // Add or modify cyls for new data
172
+ for (let i = 0; i < dataToPrint.length; i++) {
173
+ let item = dataToPrint[i]
174
+
175
+ let xLabel = item[data.x_axis];
176
+ let posX;
177
+ if (i == 0){
178
+ posX = 0.5 + item[data.radius] * this.radius_scale;
173
179
  } else {
174
- if (scale) {
175
- firstradius = radius / scale
176
- } else {
177
- firstradius = radius * radius_scale
178
- }
179
- }
180
-
181
- let cylinderEntity = generateCylinder(height, radius, colorId, palette, stepX, animation, scale, proportion, radius_scale)
182
- cylinderEntity.classList.add("babiaxraycasterclass")
183
- this.chartEl.appendChild(cylinderEntity);
184
-
185
- //Prepare legend
186
- if (data.legend) {
187
- showLegend(data, cylinderEntity, cylinder, el, maxRadius)
188
- }
189
-
190
- // update lastradius
191
- if (!scale && !radius_scale) {
192
- lastradius = radius
180
+ posX = xTicks[i-1] + last_radius + 0.5 + item[data.radius] * this.radius_scale;
181
+ }
182
+ let cylEl;
183
+ if ( currentCyls[xLabel] && !item['_not'] ) {
184
+ cylEl = currentCyls[xLabel].el;
185
+ currentCyls[xLabel].found = true;
193
186
  } else {
194
- if (scale) {
195
- lastradius = radius / scale
196
- } else {
197
- lastradius = radius_scale * radius
198
- }
187
+ cylEl = document.createElement('a-entity');
188
+ cylEl.setAttribute('babia-name', xLabel);
189
+ cylEl.id = item[data.index];
190
+ cylEl.object3D.position.x = posX;
191
+ this.chartEl.appendChild(cylEl);
199
192
  }
193
+
194
+ createCylinder(this, cylEl, data, item, colorId, xLabel, posX, 0);
200
195
 
201
- xLabels.push(xLabel)
202
- xTicks.push(firstradius + stepX)
196
+ xLabels.push(xLabel);
197
+ xTicks.push(posX);
203
198
 
204
199
  //Increase color id
205
200
  colorId++
201
+
202
+ last_radius = item[data.radius] * this.radius_scale;
206
203
  }
204
+
205
+ // Remove old cyls (not in new data)
206
+ for (let name in currentCyls) {
207
+ if ( !currentCyls[name].found ) {
208
+ currentCyls[name].el.remove();
209
+ };
210
+ };
207
211
 
208
212
  //Print axis
209
213
  if (data.axis) {
210
- const lengthX = firstradius + stepX + lastradius + 0.5
211
- const lengthY = heightMax
212
- this.updateAxis(xLabels, xTicks, lengthX, firstradius, maxRadius, valueMax, lengthY);
214
+ const lengthX = xTicks[xTicks.length-1] + (dataToPrint[0][data.radius]+ dataToPrint[dataToPrint.length-1][data.radius])* this.radius_scale / 2 ;
215
+ this.updateAxis(xLabels, xTicks, lengthX, this.maxValue);
213
216
  }
214
-
215
- //Print Title
216
- this.updateTitle();
217
217
  },
218
218
 
219
219
  /*
220
220
  * Update axis
221
221
  */
222
- updateAxis: function (labels, ticks, lengthX, firstRadius, maxRadius, valueMax, lengthY) {
223
- let xAxisEl = document.createElement('a-entity');
224
- this.chartEl.appendChild(xAxisEl);
225
- xAxisEl.setAttribute('babia-axis-x',{'labels': labels, 'ticks': ticks, 'length': lengthX,'palette': this.data.palette});
226
- xAxisEl.setAttribute('position', {x: -firstRadius, y: 0, z: maxRadius + 1});
227
-
228
- let yAxisEl = document.createElement('a-entity');
229
- this.chartEl.appendChild(yAxisEl);
230
- yAxisEl.setAttribute('babia-axis-y',{'maxValue': valueMax, 'length': lengthY});
231
- yAxisEl.setAttribute('position', {x: -firstRadius, y: 0, z: maxRadius + 1});
232
-
233
- if (this.data.axis_name){
234
- xAxisEl.setAttribute('babia-axis-x', 'name', this.data.x_axis);
235
- yAxisEl.setAttribute('babia-axis-y', 'name', this.data.height);
222
+ updateAxis: function(labels, ticks, lengthX, maxValue) {
223
+ const data = this.data;
224
+ if (data.axis) {
225
+ if (!this.xAxisEl) {
226
+ this.xAxisEl = document.createElement('a-entity');
227
+ this.chartEl.appendChild(this.xAxisEl);
228
+ };
229
+ this.xAxisEl.setAttribute('babia-axis-x',
230
+ {'labels': labels, 'ticks': ticks, 'length': lengthX,
231
+ 'palette': data.palette});
232
+ this.xAxisEl.setAttribute('position', {
233
+ x: 0, y: 0, z: data.radiusMax + 0.25
234
+ });
235
+
236
+ if (!this.yAxisEl) {
237
+ this.yAxisEl = document.createElement('a-entity');
238
+ this.chartEl.appendChild(this.yAxisEl);
239
+ };
240
+ this.yAxisEl.setAttribute('babia-axis-y',
241
+ {'maxValue': maxValue, 'length': this.lengthY});
242
+ this.yAxisEl.setAttribute('position', {
243
+ x: 0, y: 0, z: data.radiusMax + 0.25
244
+ });
245
+ if (data.axis_name){
246
+ if (data.index) {
247
+ this.xAxisEl.setAttribute('babia-axis-x', 'name', data.index);
248
+ } else {
249
+ this.xAxisEl.setAttribute('babia-axis-x', 'name', data.x_axis);
250
+ }
251
+ this.yAxisEl.setAttribute('babia-axis-y', 'name', data.height);
252
+ }
236
253
  }
237
254
  },
238
255
 
@@ -243,92 +260,71 @@ AFRAME.registerComponent('babia-cyls', {
243
260
  console.log("processData", this);
244
261
  this.newData = data;
245
262
  this.babiaMetadata = { id: this.babiaMetadata.id++ };
246
- while (this.el.firstChild)
247
- this.el.firstChild.remove();
263
+ /*while (this.el.firstChild)
264
+ this.el.firstChild.remove();*/
248
265
  console.log("Generating cyls...")
249
266
  this.updateChart()
250
267
  this.notiBuffer.set(this.newData)
251
268
  }
252
269
  })
253
270
 
254
- function generateCylinder(height, radius, colorId, palette, position, animation, scale, proportion, radius_scale) {
255
- let color = colors.get(colorId, palette)
256
- let entity = document.createElement('a-cylinder');
257
- if (scale) {
258
- height = height / scale
259
- radius = radius / scale
260
- } else if (proportion || radius_scale) {
261
- if (proportion) {
262
- height = proportion * height
263
- }
264
- if (radius_scale) {
265
- radius = radius_scale * radius
266
- }
267
- }
268
- entity.setAttribute('color', color);
269
- entity.setAttribute('height', 0);
270
- entity.setAttribute('radius', radius);
271
- // Add animation
272
- if (animation) {
273
- var duration = 4000
274
- var increment = 20 * height / duration
275
- var size = 0
276
- var id = setInterval(animation, 1);
277
- function animation() {
278
- if (size >= height) {
279
- clearInterval(id);
271
+ let createCylinder = (self, cylEl, data, item, colorId, xLabel, posX, posZ, zLabel) => {
272
+ cylEl.setAttribute('babia-cyl', {
273
+ 'height': item[data.height] * self.lengthY / self.maxValue,
274
+ 'radius': item[data.radius] * self.radius_scale,
275
+ 'color': colors.get(colorId, data.palette),
276
+ 'label': 'events',
277
+ 'animation': data.animation
278
+ });
279
+ if (data.legend) {
280
+ if (!zLabel){
281
+ cylEl.setAttribute('babia-cyl', {
282
+ 'labelText': xLabel + '\nHeight: ' + item[data.height] + '\nRadius: ' + item[data.radius]
283
+ });
280
284
  } else {
281
- size += increment;
282
- entity.setAttribute('height', size);
283
- entity.setAttribute('position', { x: position, y: size / 2, z: 0 });
285
+ cylEl.setAttribute('babia-cyl', {
286
+ 'labelText': xLabel + ' | ' + zLabel + '\nHeight: ' + item[data.height] + '\nRadius: ' + item[data.radius]
287
+ });
284
288
  }
285
- }
286
- } else {
287
- entity.setAttribute('height', height);
288
- entity.setAttribute('position', { x: position, y: height / 2, z: 0 });
289
+ };
290
+ if (posX !== cylEl.object3D.position.x) {
291
+ if (data.animation) {
292
+ cylEl.setAttribute('animation', {
293
+ 'property': 'object3D.position.x',
294
+ 'to': posX,
295
+ 'dur': data.dur
296
+ });
297
+ } else {
298
+ cylEl.object3D.position.x = posX;
299
+ };
289
300
  }
290
- return entity;
301
+ if (posZ !== cylEl.object3D.position.z) {
302
+ if (data.animation) {
303
+ cylEl.setAttribute('animation', {
304
+ 'property': 'object3D.position.z',
305
+ 'to': posZ,
306
+ 'dur': data.dur
307
+ });
308
+ } else {
309
+ cylEl.object3D.position.z = posZ;
310
+ };
291
311
  }
292
-
293
-
294
- function showLegend(data, cylinderEntity, cylinder, el, maxRadius) {
295
- cylinderEntity.addEventListener('mouseenter', function () {
296
- this.setAttribute('scale', { x: 1.1, y: 1.1, z: 1.1 });
297
- legend = generateLegend(data, cylinder, cylinderEntity, maxRadius);
298
- el.appendChild(legend);
299
- });
300
-
301
- cylinderEntity.addEventListener('mouseleave', function () {
302
- this.setAttribute('scale', { x: 1, y: 1, z: 1 });
303
- el.removeChild(legend);
304
- });
312
+
305
313
  }
306
314
 
307
- function generateLegend(data, cylinder, cylinderEntity, maxRadius) {
308
- let text = cylinder[data.x_axis] + ': ' + cylinder[data.height];
309
- let width = 5;
310
- if (text.length > 16)
311
- width = text.length / 2;
312
-
313
- let cylinderPosition = cylinderEntity.getAttribute('position')
314
- let entity = document.createElement('a-plane');
315
- entity.setAttribute('position', {
316
- x: cylinderPosition.x, y: 2 * cylinderPosition.y + 2,
317
- z: cylinderPosition.z + maxRadius + 0.5
318
- });
319
- entity.setAttribute('rotation', { x: 0, y: 0, z: 0 });
320
- entity.setAttribute('height', '1.5');
321
- entity.setAttribute('width', width);
322
- entity.setAttribute('color', 'white');
323
- entity.setAttribute('text', {
324
- 'value': cylinder[data.x_axis] + ': ' + cylinder[data.height],
325
- 'align': 'center',
326
- 'width': 20,
327
- 'color': 'black'
328
- });
329
- entity.classList.add("babiaxrLegend")
330
- return entity;
315
+ let createUiLink = (el, position) => {
316
+ let ui_link = document.createElement('a-entity');
317
+ if (!el.id){
318
+ // Generate id
319
+ let id = 'bars' + Math.floor(Math.random() * 1000);
320
+ el.id = id
321
+ }
322
+ console.log('id:', el.id)
323
+ ui_link.setAttribute('babia-ui-link', {viz: el.id})
324
+ ui_link.setAttribute('position', {x: position.x, y: position.y, z:position.z})
325
+ el.appendChild(ui_link)
326
+ console.log('Create Button', el)
327
+ return
331
328
  }
332
329
 
333
-
334
-
330
+ module.exports.createCylinder = createCylinder;