aframe-babia-components 1.2.0 → 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 (127) hide show
  1. package/components/filters/babia-selector.js +256 -79
  2. package/components/filters/babia-treebuilder.js +4 -5
  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 +62 -37
  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 +291 -279
  17. package/components/visualizers/babia-bubbles.js +9 -26
  18. package/components/visualizers/babia-city.js +19 -9
  19. package/components/visualizers/babia-cyls.js +197 -201
  20. package/components/visualizers/babia-cylsmap.js +171 -241
  21. package/components/visualizers/babia-doughnut.js +2 -28
  22. package/components/visualizers/babia-network.js +191 -124
  23. package/components/visualizers/babia-pie.js +2 -30
  24. package/dist/aframe-babia-components.js +6785 -5626
  25. package/dist/aframe-babia-components.min.js +7 -1
  26. package/dist/aframe-babia-components.min.js.map +1 -0
  27. package/docs/APIs/CHARTS.md +11 -4
  28. package/docs/APIs/DATAMANAGEMENT.md +7 -0
  29. package/docs/APIs/OTHERS.md +27 -0
  30. package/docs/APIs/QUERIERS.md +16 -0
  31. package/docs/RELEASE_NOTES.md +44 -23
  32. package/docs/Tutorials/multiuser.md +47 -2
  33. package/docs/Tutorials/temporal_evol_with_boats.md +4 -4
  34. package/examples/assets/door/New Bitmap Image.jpg +0 -0
  35. package/examples/assets/door/door.mtl +26 -0
  36. package/examples/assets/door/door.obj +6927 -0
  37. package/examples/assets/popups/0.png +0 -0
  38. package/examples/assets/popups/1.png +0 -0
  39. package/examples/assets/popups/10.png +0 -0
  40. package/examples/assets/popups/2.png +0 -0
  41. package/examples/assets/popups/3.png +0 -0
  42. package/examples/assets/popups/4.png +0 -0
  43. package/examples/assets/popups/5.png +0 -0
  44. package/examples/assets/popups/6.png +0 -0
  45. package/examples/assets/popups/7.png +0 -0
  46. package/examples/assets/popups/8.png +0 -0
  47. package/examples/assets/popups/9.png +0 -0
  48. package/examples/assets/popups/close.jpg +0 -0
  49. package/examples/assets/popups/info.jpg +0 -0
  50. package/examples/assets/textures/brownwall.png +0 -0
  51. package/examples/assets/textures/concrete.png +0 -0
  52. package/examples/assets/textures/white-wall-texture.jpg +0 -0
  53. package/examples/boats/boats_new_element/data1.json +18 -18
  54. package/examples/boats/boats_new_element/data2.json +19 -19
  55. package/examples/boats/boats_new_element/index.html +1 -1
  56. package/examples/charts/cyls/index.html +13 -4
  57. package/examples/charts/cyls/primitive.html +76 -0
  58. package/examples/charts/cylsmap/index.html +14 -5
  59. package/examples/charts_querier/bars_querier/data.csv +10 -0
  60. package/examples/charts_querier/bars_querier/index_csv.html +80 -0
  61. package/examples/dashboard/chaoss-dashboards.html +259 -0
  62. package/examples/dashboard/chaoss-issues.html +248 -0
  63. package/examples/dashboard/chaoss-pr.html +248 -0
  64. package/examples/dashboard/index.html +247 -0
  65. package/examples/dashboard/issues_queries/80-percent-open-time.json +123 -0
  66. package/examples/dashboard/issues_queries/issues-by-organization.json +107 -0
  67. package/examples/dashboard/issues_queries/issues.json +117 -0
  68. package/examples/dashboard/issues_queries/median-open-time.json +123 -0
  69. package/examples/dashboard/issues_queries/organizations.json +130 -0
  70. package/examples/dashboard/issues_queries/projects.json +130 -0
  71. package/examples/dashboard/issues_queries/repositories.json +130 -0
  72. package/examples/dashboard/issues_queries/status.json +107 -0
  73. package/examples/dashboard/issues_queries/submitter.json +125 -0
  74. package/examples/dashboard/issues_queries/submitters.json +113 -0
  75. package/examples/dashboard/pullrequests_queries/80-percent-open-time.json +123 -0
  76. package/examples/dashboard/pullrequests_queries/median-open-time.json +123 -0
  77. package/examples/dashboard/pullrequests_queries/organizations.json +130 -0
  78. package/examples/dashboard/pullrequests_queries/projects.json +130 -0
  79. package/examples/dashboard/pullrequests_queries/pull-requests-by-organization.json +107 -0
  80. package/examples/dashboard/pullrequests_queries/pull-requests.json +117 -0
  81. package/examples/dashboard/pullrequests_queries/repositories.json +130 -0
  82. package/examples/dashboard/pullrequests_queries/status.json +107 -0
  83. package/examples/dashboard/pullrequests_queries/submitter.json +125 -0
  84. package/examples/dashboard/pullrequests_queries/submitters.json +113 -0
  85. package/examples/dashboard/range.html +88 -0
  86. package/examples/dashboard/template.html +136 -0
  87. package/examples/demos/1.0.11/index_multiuser_ui.html +1 -1
  88. package/examples/multi_bars/data.json +14 -0
  89. package/examples/multi_bars/data2.json +15 -0
  90. package/examples/multi_bars/data3.json +23 -0
  91. package/examples/multi_bars/easyrtc.js +11984 -0
  92. package/examples/multi_bars/index.html +97 -0
  93. package/examples/multi_bars/index1.html +111 -0
  94. package/examples/multi_bars/index2.html +102 -0
  95. package/examples/multi_bars/index3.html +104 -0
  96. package/examples/multi_boats/data3.json +174 -0
  97. package/examples/multi_boats/data4.json +192 -0
  98. package/examples/multi_boats/easyrtc.js +11984 -0
  99. package/examples/multi_boats/index_multi_boats.html +223 -0
  100. package/examples/multi_boats/jetuml.html +256 -0
  101. package/examples/multi_boats/jetuml_code_data.json +1 -0
  102. package/examples/multi_boats/jetuml_evolution_experiment.html +419 -0
  103. package/examples/multi_boats/only_queryjson.html +132 -0
  104. package/examples/multi_boats/only_queryjson2.html +167 -0
  105. package/examples/multi_boats/only_queryjson3.html +165 -0
  106. package/examples/multi_boats/queryjson_treebuilder.html +132 -0
  107. package/examples/multi_boats/with_selector.html +255 -0
  108. package/examples/multiuser/choose_avatar/index.html +18 -8
  109. package/examples/selector_boats/jetuml.html +74 -0
  110. package/examples/selector_boats/jetuml_evol_data.json +1 -0
  111. package/examples/selector_boats/jetuml_from_3_2_to_1_0.json +62382 -0
  112. package/examples/selector_boats/jetumltest.html +80 -0
  113. package/examples/ui/link/index.html +12 -11
  114. package/examples/ui/network/data.json +123 -0
  115. package/examples/ui/network/links.json +13 -0
  116. package/examples/ui/network/network.html +75 -0
  117. package/examples/ui/network/network_nodes_links.html +82 -0
  118. package/examples/ui/network/nodes.json +12 -0
  119. package/index.html +73 -2
  120. package/index.js +12 -1
  121. package/package.json +6 -3
  122. package/tests/screenshots/other_snapshots.js/chaoss-issues.png +0 -0
  123. package/tests/screenshots/other_snapshots.js/chaoss-pr.png +0 -0
  124. package/tests/screenshots/other_snapshots.js/template.png +0 -0
  125. package/tests/ui.js +7 -0
  126. package/webpack.common.js +10 -1
  127. package/webpack.devnossl.js +16 -0
@@ -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
 
@@ -46,36 +45,20 @@ AFRAME.registerComponent('babia-bubbles', {
46
45
  */
47
46
  multiple: false,
48
47
 
48
+ /**
49
+ * Called once when component is attached. Generally for initial setup.
50
+ */
51
+ init: function () {
52
+ this.notiBuffer = new NotiBuffer();
53
+ },
54
+
49
55
  /**
50
56
  * Called when component is attached and when component data changes.
51
57
  * Generally modifies the entity based on the data.
52
58
  */
53
59
 
54
60
  update: function (oldData) {
55
- let data = this.data;
56
- let el = this.el;
57
-
58
- /**
59
- * Update or create chart component
60
- */
61
- if (data.data && oldData.data !== data.data) {
62
- let _data = parseJson(data.data);
63
- this.processData(_data);
64
- } else if (data.from !== oldData.from) {
65
- // Unregister from old producer
66
- if (this.prodComponent) {
67
- this.prodComponent.notiBuffer.unregister(this.notiBufferId)
68
- };
69
- this.prodComponent = findProdComponent (data, el)
70
- if (this.prodComponent.notiBuffer) {
71
- this.notiBufferId = this.prodComponent.notiBuffer
72
- .register(this.processData.bind(this))
73
- }
74
- }
75
- // If changed whatever, re-print with the current data
76
- else if (data !== oldData && this.newData) {
77
- this.processData(this.newData)
78
- }
61
+ updateFunction(this, oldData)
79
62
  },
80
63
 
81
64
  /**
@@ -1,5 +1,7 @@
1
1
  let findProdComponent = require('../others/common').findProdComponent;
2
2
 
3
+ const NotiBuffer = require("../../common/noti-buffer").NotiBuffer;
4
+
3
5
  /* global AFRAME */
4
6
  if (typeof AFRAME === 'undefined') {
5
7
  throw new Error('Component attempted to register before AFRAME was available.');
@@ -143,7 +145,12 @@ AFRAME.registerComponent('babia-city', {
143
145
  * Set if component needs multiple instancing.
144
146
  */
145
147
  multiple: false,
146
-
148
+ /**
149
+ * Called once when component is attached. Generally for initial setup.
150
+ */
151
+ init: function () {
152
+ this.notiBuffer = new NotiBuffer();
153
+ },
147
154
  /**
148
155
  * Called when component is attached and when component data changes.
149
156
  * Generally modifies the entity based on the data.
@@ -169,14 +176,14 @@ AFRAME.registerComponent('babia-city', {
169
176
  this.notiBufferId = this.prodComponent.notiBuffer
170
177
  .register(this.processData.bind(this))
171
178
  }
172
-
173
- // If changed whatever, re-print with the current data
174
- if (data !== oldData && this.newData) {
175
- console.log("Generating city...")
176
- this.processData(this.newData)
177
- }
178
179
  }
179
- return
180
+ // If changed whatever, re-print with the current data
181
+ else if (data !== oldData && this.newData) {
182
+ console.log("Generating city...")
183
+ while (this.el.firstChild)
184
+ this.el.firstChild.remove();
185
+ this.processData(this.newData)
186
+ }
180
187
  },
181
188
 
182
189
  /**
@@ -216,7 +223,7 @@ AFRAME.registerComponent('babia-city', {
216
223
  * Process data obtained from producer
217
224
  */
218
225
  processData: function (_data) {
219
- console.log("processData", this);
226
+ console.log("processData", _data);
220
227
  this.newData = _data;
221
228
  this.babiaMetadata = { id: this.babiaMetadata.id++ };
222
229
 
@@ -231,8 +238,11 @@ AFRAME.registerComponent('babia-city', {
231
238
  } else {
232
239
  toSave = this.newData
233
240
  }
241
+ console.log("toSave", toSave);
242
+ this.notiBuffer.set(toSave)
234
243
  // Create city
235
244
  generateCity(this, toSave)
245
+
236
246
  },
237
247
 
238
248
  });
@@ -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;