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,7 @@
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;
4
+ let createCylinder = require('./babia-cyls').createCylinder;
5
5
 
6
6
  const NotiBuffer = require("../../common/noti-buffer").NotiBuffer;
7
7
 
@@ -33,7 +33,11 @@ AFRAME.registerComponent('babia-cylsmap', {
33
33
  titlePosition: { type: 'string', default: "0 0 0" },
34
34
  scale: { type: 'number' },
35
35
  heightMax: { type: 'number' },
36
- radiusMax: { type: 'number' },
36
+ radiusMax: { type: 'number', default: 2 },
37
+ // Height of the chart
38
+ chartHeight: { type: 'number', default: 10 },
39
+ // Keep height when updating data
40
+ keepHeight: { type: 'boolean', default: true},
37
41
  },
38
42
 
39
43
  /**
@@ -50,36 +54,22 @@ AFRAME.registerComponent('babia-cylsmap', {
50
54
  */
51
55
  init: function () {
52
56
  this.notiBuffer = new NotiBuffer();
57
+
58
+ // Build chartEl
59
+ this.chartEl = document.createElement('a-entity');
60
+ this.chartEl.classList.add('babiaxrChart')
61
+ this.el.appendChild(this.chartEl);
62
+
63
+ // Build titleEl
64
+ this.updateTitle()
65
+ this.el.appendChild(this.titleEl);
53
66
  },
54
67
  /**
55
68
  * Called when component is attached and when component data changes.
56
69
  * Generally modifies the entity based on the data.
57
70
  */
58
71
  update: function (oldData) {
59
- let data = this.data;
60
- let el = this.el;
61
-
62
- /**
63
- * Update or create chart component
64
- */
65
- if (data.data && oldData.data !== data.data) {
66
- let _data = parseJson(data.data);
67
- this.processData(_data);
68
- } else if (data.from !== oldData.from) {
69
- // Unregister from old producer
70
- if (this.prodComponent) {
71
- this.prodComponent.notiBuffer.unregister(this.notiBufferId)
72
- };
73
- this.prodComponent = findProdComponent (data, el)
74
- if (this.prodComponent.notiBuffer) {
75
- this.notiBufferId = this.prodComponent.notiBuffer
76
- .register(this.processData.bind(this))
77
- }
78
- }
79
- // If changed whatever, re-print with the current data
80
- else if (data !== oldData && this.newData) {
81
- this.processData(this.newData)
82
- }
72
+ updateFunction(this, oldData)
83
73
  },
84
74
 
85
75
  /**
@@ -109,8 +99,7 @@ AFRAME.registerComponent('babia-cylsmap', {
109
99
  */
110
100
  updateTitle: function(){
111
101
  const titleRotation = { x: 0, y: 0, z: 0 }
112
- const titleEl = updateTitle(this.data, titleRotation);
113
- this.el.appendChild(titleEl);
102
+ this.titleEl = updateTitle(this.data, titleRotation);
114
103
  },
115
104
 
116
105
  /*
@@ -119,127 +108,123 @@ AFRAME.registerComponent('babia-cylsmap', {
119
108
 
120
109
  updateChart: function () {
121
110
  const dataToPrint = this.newData;
122
- console.log("Data babia-cylsmap:", dataToPrint)
123
-
124
111
  const data = this.data;
125
- const el = this.el;
126
-
127
- const animation = data.animation
128
- const palette = data.palette
129
- const scale = data.scale
130
-
131
- let heightMax = data.heightMax
132
- let radiusMax = data.radiusMax
133
-
112
+
134
113
  let xLabels = [];
135
- let xTicks = [];
136
114
  let zLabels = [];
115
+ let map = new Array();
116
+ let colorId = 0
117
+ let xTicks = [];
137
118
  let zTicks = [];
138
- let colorId = 0;
139
- let maxColorId = 0;
140
- let stepX = 0;
141
- let stepZ = 0;
142
- let maxX = 0;
143
- let maxZ = 0;
144
- let keys_used = {}
145
- let z_axis = {}
146
-
147
- let valueMax = Math.max.apply(Math, dataToPrint.map(function (o) { return o[data.height]; }))
148
- let maxRadius = Math.max.apply(Math, dataToPrint.map(function (o) { return o[data.radius]; }))
149
-
150
- if (scale) {
151
- valueMax = valueMax / scale
152
- maxRadius = maxRadius / scale
153
- }
154
- if (!heightMax) {
155
- heightMax = valueMax
156
- }
157
- proportion = heightMax / valueMax
158
-
159
- if (!radiusMax) {
160
- radiusMax = maxRadius
119
+
120
+ // Generate map, xLabels and zLabels
121
+ for (i= 0; i < dataToPrint.length; i++) {
122
+ let xLabel = dataToPrint[i][data.x_axis];
123
+ let zLabel = dataToPrint[i][data.z_axis];
124
+ if (!xLabels.includes(xLabel)){
125
+ xLabels.push(xLabel);
126
+ }
127
+ if (!zLabels.includes(zLabel)){
128
+ zLabels.push(zLabel);
129
+ }
130
+ let stepX = xLabels.indexOf(xLabel);
131
+ let stepZ = zLabels.indexOf(zLabel);
132
+ if (map[stepX]){
133
+ map[stepX][stepZ] = dataToPrint[i][data.radius];
134
+ } else {
135
+ let innermap = new Array();
136
+ innermap[stepZ] = dataToPrint[i][data.radius];
137
+ map[stepX] = innermap;
138
+ }
161
139
  }
162
- radius_scale = radiusMax / maxRadius
163
-
164
- this.chartEl = document.createElement('a-entity');
165
- this.chartEl.classList.add('babiaxrChart')
166
- el.appendChild(this.chartEl)
140
+ //console.log('MAP =>', map)
167
141
 
168
- if (scale) {
169
- maxX = maxRadius / scale
170
- maxZ = maxRadius / scale
171
- } else {
172
- maxX = maxRadius * radius_scale
173
- maxZ = maxRadius * radius_scale;
174
- }
142
+ // Height Chart
143
+ let valueMax = Math.max.apply(Math, dataToPrint.map(function (o) { return o[data.height]; }))
144
+ if (!this.lengthY) {
145
+ this.lengthY = data.chartHeight;
146
+ } else if (!data.keepHeight) {
147
+ this.lengthY = this.lengthY * this.maxValue / this.maxValue;
148
+ };
149
+ this.maxValue = valueMax;
150
+
175
151
 
176
- for (let cylinder of dataToPrint) {
177
- let xLabel = cylinder[data.x_axis]
178
- let zLabel = cylinder[data.z_axis]
179
- let height = cylinder[data.height]
180
- let radius = cylinder[data.radius]
152
+ // Proportion of the radius
153
+ let maxRadius = Math.max.apply(Math, dataToPrint.map(function (o) { return o[data.radius]; }))
154
+ this.radius_scale = data.radiusMax / maxRadius;
181
155
 
182
- // Check if used in order to put the cylinder in the parent row
183
- if (keys_used[xLabel]) {
184
- stepX = keys_used[xLabel].posX
185
- colorId = keys_used[xLabel].colorId
156
+ // Generate xticks and zticks (to assign cyls positions later)
157
+ for (i= 0; i < xLabels.length; i++) {
158
+ let rad_0 = Math.max.apply(Math, map[i].filter(function (o) { if( o != '' ) { return o ; }}));
159
+ if (i == 0){
160
+ xTicks.push(rad_0 * this.radius_scale);
186
161
  } else {
187
- if (scale) {
188
- stepX += 2 * maxRadius / scale + 0.5
189
- } else {
190
- stepX += 2 * maxRadius * radius_scale + 0.5
191
- }
192
- colorId = maxColorId
193
- //Save in used
194
- keys_used[xLabel] = {
195
- "posX": stepX,
196
- "colorId": colorId
197
- }
198
-
199
- xLabels.push(xLabel)
200
- xTicks.push(stepX)
201
- maxColorId++
162
+ let rad_1 = Math.max.apply(Math, map[i-1].filter(function (o) { if( o != '' ) { return o ; }}));
163
+ xTicks.push(xTicks[i-1] + rad_0 * this.radius_scale + 0.5 + rad_1 * this.radius_scale);
202
164
  }
165
+ };
166
+ //console.log('xticks: ', xTicks)
203
167
 
204
- if (z_axis[zLabel]) {
205
- stepZ = z_axis[zLabel].posZ
168
+ for (j= 0; j < zLabels.length; j++) {
169
+ rad_0 = maxRadiusZ(map, xLabels.length, j);
170
+ if (j == 0){
171
+ zTicks.push(rad_0 * this.radius_scale);
206
172
  } else {
207
- if (scale) {
208
- stepZ = maxZ + 2 * maxRadius / scale + 0.5
209
- } else {
210
- stepZ = maxZ + 2 * maxRadius * radius_scale + 0.5
211
- }
212
- //Save in used
213
- z_axis[zLabel] = {
214
- "posZ": stepZ
215
- }
216
- zLabels.push(zLabel)
217
- zTicks.push(stepZ)
218
- }
219
-
220
- if (stepX > maxX){
221
- maxX = stepX
222
- }
223
- if (stepZ > maxZ){
224
- maxZ = stepZ
225
- }
226
-
227
- let cylinderEntity = generateCylinder(height, radius, colorId, palette, stepX, stepZ, animation, scale, proportion, radius_scale);
228
- cylinderEntity.classList.add("babiaxraycasterclass")
229
- this.chartEl.appendChild(cylinderEntity, el)
230
-
231
- //Prepare legend
232
- if (data.legend) {
233
- showLegend(data, cylinderEntity, cylinder, el)
173
+ rad_1 = maxRadiusZ(map, xLabels.length, j-1);
174
+ zTicks.push(zTicks[j-1] + rad_1 * this.radius_scale + 0.5 + rad_0 * this.radius_scale);
175
+ }
176
+ };
177
+ //console.log('zticks: ', zTicks)
178
+
179
+ // List current cylinders
180
+ let chartEl = this.chartEl;
181
+ let cyls = chartEl.querySelectorAll('a-entity[babia-cyl]');
182
+ let currentCyls = {};
183
+ for (let cyl of cyls) {
184
+ let cylName = cyl.getAttribute('babia-name');
185
+ currentCyls[cylName] = {'el': cyl, 'found': false};
186
+ };
187
+
188
+ // Add or modify cyls for new data
189
+ for (let i = 0; i < dataToPrint.length; i++) {
190
+ let item = dataToPrint[i]
191
+
192
+ let xLabel = item[data.x_axis];
193
+ let zLabel = item[data.z_axis];
194
+ let cylEl;
195
+ let id = xLabel + '-' + zLabel;
196
+ let posX = xTicks[xLabels.indexOf(xLabel)];
197
+ let posZ = zTicks[zLabels.indexOf(zLabel)];
198
+ if ( currentCyls[id] && !item['_not'] ) {
199
+ cylEl = currentCyls[id].el;
200
+ currentCyls[id].found = true;
201
+ } else {
202
+ cylEl = document.createElement('a-entity');
203
+ cylEl.setAttribute('babia-name', id);
204
+ cylEl.id = id;
205
+ cylEl.object3D.position.x = posX;
206
+ cylEl.object3D.position.z = posZ;
207
+ this.chartEl.appendChild(cylEl);
234
208
  }
209
+ colorId = xLabels.indexOf(xLabel);
210
+ createCylinder(this, cylEl, data, item, colorId, xLabel, posX, posZ, zLabel);
235
211
  }
236
212
 
213
+ // Remove old cyls (not in new data)
214
+ for (let name in currentCyls) {
215
+ if ( !currentCyls[name].found ) {
216
+ currentCyls[name].el.remove();
217
+ };
218
+ };
219
+
237
220
  //Print axis
238
221
  if (data.axis) {
239
- const lengthX = maxX
240
- const lengthZ = maxZ
241
- const lengthY = heightMax
242
- this.updateAxis(xLabels, xTicks, lengthX, zLabels, zTicks, lengthZ, valueMax, lengthY);
222
+ let lastRadX = Math.max.apply(Math, map[xLabels.length-1].filter(function (o) { if( o != '' ) { return o ; }}));
223
+ const lengthX = xTicks[xTicks.length-1] + lastRadX * this.radius_scale + 0.5;
224
+ const lengthZ = zTicks[zTicks.length-1] + maxRadiusZ(map, xLabels.length, zLabels.length-1) * this.radius_scale + 0.5;
225
+ xTicks = xTicks + 0.25;
226
+ zTicks = zTicks + 0.25;
227
+ this.updateAxis(xLabels, xTicks, lengthX, valueMax, zLabels, zTicks, lengthZ);
243
228
  }
244
229
 
245
230
  //Print Title
@@ -248,25 +233,49 @@ AFRAME.registerComponent('babia-cylsmap', {
248
233
  /*
249
234
  * Update axis
250
235
  */
251
- updateAxis: function(xLabels, xTicks, lengthX, zLabels, zTicks, lengthZ, valueMax, lengthY) {
252
- let xAxisEl = document.createElement('a-entity');
253
- this.chartEl.appendChild(xAxisEl);
254
- xAxisEl.setAttribute('babia-axis-x',{'labels': xLabels, 'ticks': xTicks, 'length': lengthX,'palette': this.data.palette});
255
- xAxisEl.setAttribute('position', {x: 0, y: 0, z: 0});
256
-
257
- let yAxisEl = document.createElement('a-entity');
258
- this.chartEl.appendChild(yAxisEl);
259
- yAxisEl.setAttribute('babia-axis-y',{'maxValue': valueMax, 'length': lengthY});
260
- yAxisEl.setAttribute('position', {x: 0, y: 0, z: 0});
261
-
262
- let zAxisEl = document.createElement('a-entity');
263
- this.chartEl.appendChild(zAxisEl);
264
- zAxisEl.setAttribute('babia-axis-z',{'labels': zLabels, 'ticks': zTicks, 'length': lengthZ});
265
- zAxisEl.setAttribute('position', {x: 0, y: 0, z: 0});
266
- if (this.data.axis_name){
267
- xAxisEl.setAttribute('babia-axis-x', 'name', this.data.x_axis);
268
- yAxisEl.setAttribute('babia-axis-y', 'name', this.data.height);
269
- zAxisEl.setAttribute('babia-axis-z', 'name', this.data.z_axis);
236
+ updateAxis: function(xLabels, xTicks, lengthX, maxValue, zLabels, zTicks, lengthZ) {
237
+ const data = this.data;
238
+ if (data.axis) {
239
+ if (!this.xAxisEl) {
240
+ this.xAxisEl = document.createElement('a-entity');
241
+ this.chartEl.appendChild(this.xAxisEl);
242
+ };
243
+ this.xAxisEl.setAttribute('babia-axis-x',
244
+ {'labels': xLabels, 'ticks': xTicks, 'length': lengthX,
245
+ 'palette': data.palette, 'align': 'behind'});
246
+ this.xAxisEl.setAttribute('position', {
247
+ x: -0.25, y: 0, z: -0.25
248
+ });
249
+
250
+ if (!this.zAxisEl) {
251
+ this.zAxisEl = document.createElement('a-entity');
252
+ this.chartEl.appendChild(this.zAxisEl);
253
+ };
254
+ this.zAxisEl.setAttribute('babia-axis-z',
255
+ {'labels': zLabels, 'ticks': zTicks, 'length': lengthZ,
256
+ 'palette': data.palette, 'align': 'left'});
257
+ this.zAxisEl.setAttribute('position', {
258
+ x: -0.25, y: 0, z: -0.25
259
+ });
260
+
261
+ if (!this.yAxisEl) {
262
+ this.yAxisEl = document.createElement('a-entity');
263
+ this.chartEl.appendChild(this.yAxisEl);
264
+ };
265
+ this.yAxisEl.setAttribute('babia-axis-y',
266
+ {'maxValue': maxValue, 'length': this.lengthY});
267
+ this.yAxisEl.setAttribute('position', {
268
+ x: -0.25, y: 0, z: -0.25
269
+ });
270
+ if (data.axis_name){
271
+ if (data.index =! "x_axis") {
272
+ this.xAxisEl.setAttribute('babia-axis-x', 'name', data.index);
273
+ } else {
274
+ this.xAxisEl.setAttribute('babia-axis-x', 'name', data.x_axis);
275
+ }
276
+ this.yAxisEl.setAttribute('babia-axis-y', 'name', data.height);
277
+ this.zAxisEl.setAttribute('babia-axis-z', 'name', data.z_axis);
278
+ }
270
279
  }
271
280
  },
272
281
 
@@ -277,99 +286,20 @@ AFRAME.registerComponent('babia-cylsmap', {
277
286
  console.log("processData", this);
278
287
  this.newData = data;
279
288
  this.babiaMetadata = { id: this.babiaMetadata.id++ };
280
- while (this.el.firstChild)
281
- this.el.firstChild.remove();
289
+ /*while (this.el.firstChild)
290
+ this.el.firstChild.remove();*/
282
291
  console.log("Generating cylsmap...")
283
292
  this.updateChart()
284
293
  this.notiBuffer.set(this.newData)
285
294
  }
286
295
  })
287
296
 
288
- function generateCylinder(height, radius, colorId, palette, positionX, positionZ, animation, scale, proportion, radius_scale) {
289
- let color = colors.get(colorId, palette)
290
- let entity = document.createElement('a-cylinder');
291
- if (scale) {
292
- height = height / scale
293
- radius = radius / scale
294
- } else if (proportion || radius_scale) {
295
- if (proportion) {
296
- height = proportion * height
297
- }
298
- if (radius_scale) {
299
- radius = radius_scale * radius
297
+ let maxRadiusZ = (map, length, j) => {
298
+ let rad = 0
299
+ for (i= 0; i < length; i++) {
300
+ if (map[i][j] && rad < map[i][j]){
301
+ rad = map[i][j];
300
302
  }
301
- }
302
- entity.setAttribute('color', color);
303
- entity.setAttribute('height', 0);
304
- entity.setAttribute('radius', radius);
305
- // Add animation
306
- if (animation) {
307
- var duration = 4000
308
- var increment = 20 * height / duration
309
- var size = 0
310
- var id = setInterval(animation, 1);
311
- function animation() {
312
- if (size >= height) {
313
- clearInterval(id);
314
- } else {
315
- size += increment;
316
- entity.setAttribute('height', size);
317
- entity.setAttribute('position', { x: positionX, y: size / 2, z: positionZ });
318
- }
319
- }
320
- } else {
321
- entity.setAttribute('height', height);
322
- entity.setAttribute('position', { x: positionX, y: height / 2, z: positionZ });
323
- }
324
- return entity;
325
- }
326
-
327
- function showLegend(data, cylinderEntity, cylinder, el) {
328
- cylinderEntity.addEventListener('mouseenter', function () {
329
- this.setAttribute('scale', { x: 1.1, y: 1.1, z: 1.1 });
330
- legend = generateLegend(data, cylinder, cylinderEntity, el.getAttribute("scale"));
331
- el.appendChild(legend);
332
- });
333
-
334
- cylinderEntity.addEventListener('mouseleave', function () {
335
- this.setAttribute('scale', { x: 1, y: 1, z: 1 });
336
- el.removeChild(legend);
337
- });
338
- }
339
-
340
- function generateLegend(data, cylinder, cylinderEntity, scale) {
341
- let text = ''
342
- let lines = []
343
- lines.push(cylinder[data.x_axis] + ' ' + cylinder[data.z_axis] + '\n');
344
- lines.push('Height: ' + cylinder[data.height] + '\n');
345
- lines.push('Radius: ' + cylinder[data.radius])
346
- let width = 5;
347
- for (let line of lines) {
348
- if ((line.length > 10) && (width < line.length / 2)) {
349
- width = line.length / 2;
350
- }
351
- text += line
352
- }
353
-
354
- let cylinderPosition = cylinderEntity.getAttribute('position')
355
- let entity = document.createElement('a-plane');
356
- let z = cylinderPosition.z;
357
- if (scale)
358
- z = z + (cylinder[data.radius] / 2) * scale.z;
359
- else
360
- z = z + (cylinder[data.radius] / 2);
361
- entity.setAttribute('position', {x: cylinderPosition.x, y: 2 * cylinderPosition.y + 3, z: z});
362
- entity.setAttribute('rotation', { x: 0, y: 0, z: 0 });
363
- entity.setAttribute('height', '4');
364
- entity.setAttribute('width', width);
365
- entity.setAttribute('color', 'white');
366
- entity.setAttribute('text', {
367
- 'value': text,
368
- 'align': 'center',
369
- 'width': 20,
370
- 'color': 'black'
371
- });
372
- entity.classList.add("babiaxrLegend")
373
- return entity;
374
- }
375
-
303
+ };
304
+ return rad;
305
+ }
@@ -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
 
@@ -49,32 +48,7 @@ AFRAME.registerComponent('babia-doughnut', {
49
48
  */
50
49
 
51
50
  update: function (oldData) {
52
- let data = this.data;
53
- let el = this.el;
54
-
55
- /**
56
- * Update or create chart component
57
- */
58
- if (data.data && oldData.data !== data.data) {
59
- let _data = parseJson(data.data)
60
- this.processData(_data)
61
- } else if (data.from !== oldData.from) {
62
- this.slice_array = []
63
- // Unregister from old producer
64
- if (this.prodComponent) {
65
- this.prodComponent.notiBuffer.unregister(this.notiBufferId)
66
- };
67
- this.prodComponent = findProdComponent (data, el)
68
- if (this.prodComponent.notiBuffer) {
69
- this.notiBufferId = this.prodComponent.notiBuffer
70
- .register(this.processData.bind(this))
71
- }
72
- }
73
- // If changed whatever, re-print with the current data
74
- else if (data !== oldData && this.newData) {
75
- this.slice_array = []
76
- this.processData(this.newData)
77
- }
51
+ updateFunction(this, oldData)
78
52
  },
79
53
 
80
54
  /**