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
@@ -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
 
@@ -22,6 +22,8 @@ AFRAME.registerComponent('babia-cylsmap', {
22
22
  z_axis: { type: 'string', default: 'z_axis' },
23
23
  from: { type: 'string' },
24
24
  legend: { type: 'boolean' },
25
+ legend_lookat: { type: 'string', default: "[camera]" },
26
+ legend_scale: { type: 'number', default: 1 },
25
27
  axis: { type: 'boolean', default: true },
26
28
  // Name for axis
27
29
  axis_name: {type: 'boolean', default: false},
@@ -33,7 +35,11 @@ AFRAME.registerComponent('babia-cylsmap', {
33
35
  titlePosition: { type: 'string', default: "0 0 0" },
34
36
  scale: { type: 'number' },
35
37
  heightMax: { type: 'number' },
36
- radiusMax: { type: 'number' },
38
+ radiusMax: { type: 'number', default: 2 },
39
+ // Height of the chart
40
+ chartHeight: { type: 'number', default: 10 },
41
+ // Keep height when updating data
42
+ keepHeight: { type: 'boolean', default: true},
37
43
  },
38
44
 
39
45
  /**
@@ -50,36 +56,22 @@ AFRAME.registerComponent('babia-cylsmap', {
50
56
  */
51
57
  init: function () {
52
58
  this.notiBuffer = new NotiBuffer();
59
+
60
+ // Build chartEl
61
+ this.chartEl = document.createElement('a-entity');
62
+ this.chartEl.classList.add('babiaxrChart')
63
+ this.el.appendChild(this.chartEl);
64
+
65
+ // Build titleEl
66
+ this.updateTitle()
67
+ this.el.appendChild(this.titleEl);
53
68
  },
54
69
  /**
55
70
  * Called when component is attached and when component data changes.
56
71
  * Generally modifies the entity based on the data.
57
72
  */
58
73
  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
- }
74
+ updateFunction(this, oldData)
83
75
  },
84
76
 
85
77
  /**
@@ -109,8 +101,7 @@ AFRAME.registerComponent('babia-cylsmap', {
109
101
  */
110
102
  updateTitle: function(){
111
103
  const titleRotation = { x: 0, y: 0, z: 0 }
112
- const titleEl = updateTitle(this.data, titleRotation);
113
- this.el.appendChild(titleEl);
104
+ this.titleEl = updateTitle(this.data, titleRotation);
114
105
  },
115
106
 
116
107
  /*
@@ -119,127 +110,123 @@ AFRAME.registerComponent('babia-cylsmap', {
119
110
 
120
111
  updateChart: function () {
121
112
  const dataToPrint = this.newData;
122
- console.log("Data babia-cylsmap:", dataToPrint)
123
-
124
113
  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
-
114
+
134
115
  let xLabels = [];
135
- let xTicks = [];
136
116
  let zLabels = [];
117
+ let map = new Array();
118
+ let colorId = 0
119
+ let xTicks = [];
137
120
  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
121
+
122
+ // Generate map, xLabels and zLabels
123
+ for (i= 0; i < dataToPrint.length; i++) {
124
+ let xLabel = dataToPrint[i][data.x_axis];
125
+ let zLabel = dataToPrint[i][data.z_axis];
126
+ if (!xLabels.includes(xLabel)){
127
+ xLabels.push(xLabel);
128
+ }
129
+ if (!zLabels.includes(zLabel)){
130
+ zLabels.push(zLabel);
131
+ }
132
+ let stepX = xLabels.indexOf(xLabel);
133
+ let stepZ = zLabels.indexOf(zLabel);
134
+ if (map[stepX]){
135
+ map[stepX][stepZ] = dataToPrint[i][data.radius];
136
+ } else {
137
+ let innermap = new Array();
138
+ innermap[stepZ] = dataToPrint[i][data.radius];
139
+ map[stepX] = innermap;
140
+ }
161
141
  }
162
- radius_scale = radiusMax / maxRadius
163
-
164
- this.chartEl = document.createElement('a-entity');
165
- this.chartEl.classList.add('babiaxrChart')
166
- el.appendChild(this.chartEl)
142
+ //console.log('MAP =>', map)
167
143
 
168
- if (scale) {
169
- maxX = maxRadius / scale
170
- maxZ = maxRadius / scale
171
- } else {
172
- maxX = maxRadius * radius_scale
173
- maxZ = maxRadius * radius_scale;
174
- }
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 * this.maxValue / this.maxValue;
150
+ };
151
+ this.maxValue = valueMax;
152
+
175
153
 
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]
154
+ // Proportion of the radius
155
+ let maxRadius = Math.max.apply(Math, dataToPrint.map(function (o) { return o[data.radius]; }))
156
+ this.radius_scale = data.radiusMax / maxRadius;
181
157
 
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
158
+ // Generate xticks and zticks (to assign cyls positions later)
159
+ for (i= 0; i < xLabels.length; i++) {
160
+ let rad_0 = Math.max.apply(Math, map[i].filter(function (o) { if( o != '' ) { return o ; }}));
161
+ if (i == 0){
162
+ xTicks.push(rad_0 * this.radius_scale);
186
163
  } 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++
164
+ let rad_1 = Math.max.apply(Math, map[i-1].filter(function (o) { if( o != '' ) { return o ; }}));
165
+ xTicks.push(xTicks[i-1] + rad_0 * this.radius_scale + 0.5 + rad_1 * this.radius_scale);
202
166
  }
167
+ };
168
+ //console.log('xticks: ', xTicks)
203
169
 
204
- if (z_axis[zLabel]) {
205
- stepZ = z_axis[zLabel].posZ
170
+ for (j= 0; j < zLabels.length; j++) {
171
+ rad_0 = maxRadiusZ(map, xLabels.length, j);
172
+ if (j == 0){
173
+ zTicks.push(rad_0 * this.radius_scale);
206
174
  } 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)
175
+ rad_1 = maxRadiusZ(map, xLabels.length, j-1);
176
+ zTicks.push(zTicks[j-1] + rad_1 * this.radius_scale + 0.5 + rad_0 * this.radius_scale);
177
+ }
178
+ };
179
+ //console.log('zticks: ', zTicks)
180
+
181
+ // List current cylinders
182
+ let chartEl = this.chartEl;
183
+ let cyls = chartEl.querySelectorAll('a-entity[babia-cyl]');
184
+ let currentCyls = {};
185
+ for (let cyl of cyls) {
186
+ let cylName = cyl.getAttribute('babia-name');
187
+ currentCyls[cylName] = {'el': cyl, 'found': false};
188
+ };
189
+
190
+ // Add or modify cyls for new data
191
+ for (let i = 0; i < dataToPrint.length; i++) {
192
+ let item = dataToPrint[i]
193
+
194
+ let xLabel = item[data.x_axis];
195
+ let zLabel = item[data.z_axis];
196
+ let cylEl;
197
+ let id = xLabel + '-' + zLabel;
198
+ let posX = xTicks[xLabels.indexOf(xLabel)];
199
+ let posZ = zTicks[zLabels.indexOf(zLabel)];
200
+ if ( currentCyls[id] && !item['_not'] ) {
201
+ cylEl = currentCyls[id].el;
202
+ currentCyls[id].found = true;
203
+ } else {
204
+ cylEl = document.createElement('a-entity');
205
+ cylEl.setAttribute('babia-name', id);
206
+ cylEl.id = id;
207
+ cylEl.object3D.position.x = posX;
208
+ cylEl.object3D.position.z = posZ;
209
+ this.chartEl.appendChild(cylEl);
234
210
  }
211
+ colorId = xLabels.indexOf(xLabel);
212
+ createCylinder(this, cylEl, data, item, colorId, xLabel, posX, posZ, zLabel);
235
213
  }
236
214
 
215
+ // Remove old cyls (not in new data)
216
+ for (let name in currentCyls) {
217
+ if ( !currentCyls[name].found ) {
218
+ currentCyls[name].el.remove();
219
+ };
220
+ };
221
+
237
222
  //Print axis
238
223
  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);
224
+ let lastRadX = Math.max.apply(Math, map[xLabels.length-1].filter(function (o) { if( o != '' ) { return o ; }}));
225
+ const lengthX = xTicks[xTicks.length-1] + lastRadX * this.radius_scale + 0.5;
226
+ const lengthZ = zTicks[zTicks.length-1] + maxRadiusZ(map, xLabels.length, zLabels.length-1) * this.radius_scale + 0.5;
227
+ xTicks = xTicks + 0.25;
228
+ zTicks = zTicks + 0.25;
229
+ this.updateAxis(xLabels, xTicks, lengthX, valueMax, zLabels, zTicks, lengthZ);
243
230
  }
244
231
 
245
232
  //Print Title
@@ -248,25 +235,49 @@ AFRAME.registerComponent('babia-cylsmap', {
248
235
  /*
249
236
  * Update axis
250
237
  */
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);
238
+ updateAxis: function(xLabels, xTicks, lengthX, maxValue, zLabels, zTicks, lengthZ) {
239
+ const data = this.data;
240
+ if (data.axis) {
241
+ if (!this.xAxisEl) {
242
+ this.xAxisEl = document.createElement('a-entity');
243
+ this.chartEl.appendChild(this.xAxisEl);
244
+ };
245
+ this.xAxisEl.setAttribute('babia-axis-x',
246
+ {'labels': xLabels, 'ticks': xTicks, 'length': lengthX,
247
+ 'palette': data.palette, 'align': 'behind'});
248
+ this.xAxisEl.setAttribute('position', {
249
+ x: -0.25, y: 0, z: -0.25
250
+ });
251
+
252
+ if (!this.zAxisEl) {
253
+ this.zAxisEl = document.createElement('a-entity');
254
+ this.chartEl.appendChild(this.zAxisEl);
255
+ };
256
+ this.zAxisEl.setAttribute('babia-axis-z',
257
+ {'labels': zLabels, 'ticks': zTicks, 'length': lengthZ,
258
+ 'palette': data.palette, 'align': 'left'});
259
+ this.zAxisEl.setAttribute('position', {
260
+ x: -0.25, y: 0, z: -0.25
261
+ });
262
+
263
+ if (!this.yAxisEl) {
264
+ this.yAxisEl = document.createElement('a-entity');
265
+ this.chartEl.appendChild(this.yAxisEl);
266
+ };
267
+ this.yAxisEl.setAttribute('babia-axis-y',
268
+ {'maxValue': maxValue, 'length': this.lengthY});
269
+ this.yAxisEl.setAttribute('position', {
270
+ x: -0.25, y: 0, z: -0.25
271
+ });
272
+ if (data.axis_name){
273
+ if (data.index =! "x_axis") {
274
+ this.xAxisEl.setAttribute('babia-axis-x', 'name', data.index);
275
+ } else {
276
+ this.xAxisEl.setAttribute('babia-axis-x', 'name', data.x_axis);
277
+ }
278
+ this.yAxisEl.setAttribute('babia-axis-y', 'name', data.height);
279
+ this.zAxisEl.setAttribute('babia-axis-z', 'name', data.z_axis);
280
+ }
270
281
  }
271
282
  },
272
283
 
@@ -277,99 +288,20 @@ AFRAME.registerComponent('babia-cylsmap', {
277
288
  console.log("processData", this);
278
289
  this.newData = data;
279
290
  this.babiaMetadata = { id: this.babiaMetadata.id++ };
280
- while (this.el.firstChild)
281
- this.el.firstChild.remove();
291
+ /*while (this.el.firstChild)
292
+ this.el.firstChild.remove();*/
282
293
  console.log("Generating cylsmap...")
283
294
  this.updateChart()
284
295
  this.notiBuffer.set(this.newData)
285
296
  }
286
297
  })
287
298
 
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
299
+ let maxRadiusZ = (map, length, j) => {
300
+ let rad = 0
301
+ for (i= 0; i < length; i++) {
302
+ if (map[i][j] && rad < map[i][j]){
303
+ rad = map[i][j];
300
304
  }
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
-
305
+ };
306
+ return rad;
307
+ }
@@ -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-doughnut', {
20
19
  key: { type: 'string', default: 'key' },
21
20
  from: { type: 'string' },
22
21
  legend: { type: 'boolean' },
22
+ legend_lookat: { type: 'string', default: "[camera]" },
23
+ legend_scale: { type: 'number', default: 1 },
23
24
  palette: { type: 'string', default: 'ubuntu' },
24
25
  title: { type: 'string' },
25
26
  titleFont: { type: 'string' },
@@ -49,32 +50,7 @@ AFRAME.registerComponent('babia-doughnut', {
49
50
  */
50
51
 
51
52
  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
- }
53
+ updateFunction(this, oldData)
78
54
  },
79
55
 
80
56
  /**
@@ -255,6 +231,8 @@ function generateLegend(data, slice) {
255
231
  'color': 'black'
256
232
  });
257
233
  entity.classList.add("babiaxrLegend")
234
+ entity.setAttribute('babia-lookat', data.legend_lookat);
235
+ entity.setAttribute('scale',{x: data.legend_scale, y: data.legend_scale, z: data.legend_scale});
258
236
  return entity;
259
237
  }
260
238