aframe-babia-components 1.2.5 → 1.2.6
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.
- package/components/filters/babia-treebuilder.js +17 -12
- package/components/others/babia-camera.js +52 -40
- package/components/others/babia-experiment.js +457 -0
- package/components/others/babia-poster.js +383 -0
- package/components/others/babia-task.js +247 -0
- package/components/others/babia-ui.js +312 -147
- package/components/others/common.js +36 -5
- package/components/visualizers/babia-boats.js +708 -87
- package/components/visualizers/babia-network.js +268 -212
- package/dist/aframe-babia-components.js +20590 -18317
- package/dist/aframe-babia-components.min.js +3 -3
- package/dist/aframe-babia-components.min.js.map +1 -1
- package/docs/APIs/CHARTS.md +233 -207
- package/docs/APIs/OTHERS.md +143 -56
- package/docs/RELEASE_NOTES.md +5 -0
- package/docs/Tutorials/how_to_prepare_an_experiment.md +148 -0
- package/examples/assets/palettes/bluetored.jpg +0 -0
- package/examples/assets/textures/360-panorama.jpg +0 -0
- package/examples/assets/textures/floor-texture.jpg +0 -0
- package/examples/assets/textures/metalic-texture.jpg +0 -0
- package/examples/boats/boats_dependency/dependencieslist_cloudinary.json +1 -0
- package/examples/boats/boats_dependency/dependencieslist_express.json +4376 -0
- package/examples/boats/boats_dependency/dependencieslist_filestash.json +39533 -0
- package/examples/boats/boats_dependency/dependencieslist_ghdesktop.json +127660 -0
- package/examples/boats/boats_dependency/dependencieslist_karma.json +1 -0
- package/examples/boats/boats_dependency/dependencieslist_pm2.json +13726 -0
- package/examples/boats/boats_dependency/dependencieslist_portainer.json +41818 -0
- package/examples/boats/boats_dependency/dependencieslist_sh.json +5194 -0
- package/examples/boats/boats_dependency/experiment.html +277 -0
- package/examples/boats/boats_dependency/index.html +300 -0
- package/examples/boats/boats_dependency/index_gradient.html +209 -0
- package/examples/boats/boats_dependency/index_normalcity.html +207 -0
- package/examples/boats/boats_dependency/index_quarter_levels_01.html +213 -0
- package/examples/boats/boats_dependency/index_quarter_levels_02.html +213 -0
- package/examples/boats/boats_dependency/index_quarter_levels_03.html +213 -0
- package/examples/boats/boats_dependency/index_quarter_levels_querystring.html +243 -0
- package/examples/boats/boats_dependency/index_tree.html +211 -0
- package/examples/boats/boats_dependency/index_tree_gradient.html +212 -0
- package/examples/boats/boats_dependency/index_tree_wireframe.html +243 -0
- package/examples/charts/network_chart/network_chart.html +10 -2
- package/examples/charts/pie/index.html +3 -4
- package/examples/codecityjs/perceval2021/index.html +1 -1
- package/examples/codecityjs/projects_analysis/argouml_landscape.html +1 -1
- package/examples/codecityjs/projects_analysis/argouml_numfuns.html +3 -3
- package/examples/codecityjs/projects_analysis/argouml_table.html +1 -1
- package/examples/codecityjs/projects_analysis/argouml_tokens.html +1 -1
- package/examples/codecityjs/projects_analysis/experiment_interface.html +1 -1
- package/examples/codecityjs/projects_analysis/experiment_interface_task5.html +1 -1
- package/examples/codecityjs/projects_analysis/experiment_interface_vr_2021.html +1 -1
- package/examples/codecityjs/projects_analysis/experiment_interface_vr_task5.html +1 -1
- package/examples/codecityjs/projects_analysis/perceval_landscape.html +1 -1
- package/examples/codecityjs/projects_analysis/perceval_table.html +1 -1
- package/examples/dashboard/chaoss-dashboards.html +1 -1
- package/examples/dashboard/chaoss-issues.html +1 -1
- package/examples/dashboard/chaoss-pr.html +1 -1
- package/examples/dashboard/range.html +1 -1
- package/examples/dashboard/template.html +1 -1
- package/examples/experiment/city.html +352 -0
- package/examples/experiment/index.html +527 -0
- package/examples/experiment/pie.html +90 -0
- package/examples/experiment/sample-3s.mp3 +0 -0
- package/examples/experiment/sample.mp4 +0 -0
- package/examples/experiment/staticdata/80-percent-open-time-issues2.json +1 -0
- package/examples/experiment/staticdata/80-percent-open-time-pr.json +1 -0
- package/examples/experiment/staticdata/issues-by-organization.json +1 -0
- package/examples/experiment/staticdata/issues.json +1 -0
- package/examples/experiment/staticdata/jetuml_code_data.json +1 -0
- package/examples/experiment/staticdata/median-open-time-issues.json +1 -0
- package/examples/experiment/staticdata/median-open-time-pr.json +1 -0
- package/examples/experiment/staticdata/organizations-issues.json +1 -0
- package/examples/experiment/staticdata/organizations-pr.json +1 -0
- package/examples/experiment/staticdata/projects-issues.json +1 -0
- package/examples/experiment/staticdata/projects-pr.json +1 -0
- package/examples/experiment/staticdata/pull-requests-by-organization.json +1 -0
- package/examples/experiment/staticdata/pull-requests.json +1 -0
- package/examples/experiment/staticdata/repositories-issues-asignees.json +1 -0
- package/examples/experiment/staticdata/repositories-issues-avgdays.json +1 -0
- package/examples/experiment/staticdata/repositories-issues-count.json +1 -0
- package/examples/experiment/staticdata/repositories-issues-submitters.json +1 -0
- package/examples/experiment/staticdata/repositories-pr-asignees.json +1 -0
- package/examples/experiment/staticdata/repositories-pr-avgdays.json +1 -0
- package/examples/experiment/staticdata/repositories-pr-count.json +1 -0
- package/examples/experiment/staticdata/repositories-pr-submitters.json +1 -0
- package/examples/experiment/staticdata/status-issues.json +1 -0
- package/examples/experiment/staticdata/status-pr.json +1 -0
- package/examples/experiment/staticdata/submitter-issues-avgdays.json +1 -0
- package/examples/experiment/staticdata/submitter-issues-count.json +1 -0
- package/examples/experiment/staticdata/submitter-issues-repo.json +1 -0
- package/examples/experiment/staticdata/submitter-pr-avgdays.json +1 -0
- package/examples/experiment/staticdata/submitter-pr-count.json +1 -0
- package/examples/experiment/staticdata/submitter-pr-repo.json +1 -0
- package/examples/experiment/staticdata/submitters-issues.json +1 -0
- package/examples/experiment/staticdata/submitters-pr.json +1 -0
- package/examples/multi_boats/jetuml_evolution_experiment.html +1 -1
- package/index.js +23 -9
- package/package.json +1 -1
- package/examples/charts_querier/network_chart_querier/data.json +0 -123
- package/examples/charts_querier/network_chart_querier/links.json +0 -13
- package/examples/charts_querier/network_chart_querier/network_chart_querier.html +0 -68
- package/examples/charts_querier/network_chart_querier/network_chart_querier_nodes_links.html +0 -74
- package/examples/charts_querier/network_chart_querier/nodes.json +0 -12
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
let findProdComponent = require('../others/common').findProdComponent;
|
|
2
2
|
let updateFunction = require('../others/common').updateFunction;
|
|
3
|
+
const colorsArray = require('../others/common').colors.palettes['categoric'];
|
|
3
4
|
|
|
4
5
|
const NotiBuffer = require("../../common/noti-buffer").NotiBuffer;
|
|
5
6
|
|
|
@@ -21,20 +22,50 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
21
22
|
area: { type: 'string' },
|
|
22
23
|
color: { type: 'string' },
|
|
23
24
|
height: { type: 'string', default: 'height' },
|
|
24
|
-
|
|
25
|
+
maxBuildingHeight: { type: 'number', default: 2 },
|
|
26
|
+
minBuildingHeight: { type: 'number', default: 0.03 },
|
|
27
|
+
zone_elevation: { type: 'number', default: 0.01 },
|
|
25
28
|
building_separation: { type: 'number', default: 0.25 },
|
|
26
29
|
extra: { type: 'number', default: 1.0 },
|
|
27
30
|
levels: { type: 'number' },
|
|
28
31
|
building_color: { type: 'string', default: "#E6B9A1" },
|
|
32
|
+
buildingAlpha: { type: 'number', default: 1 },
|
|
33
|
+
gradientBaseColor: { type: 'boolean', default: false },
|
|
29
34
|
base_color: { type: 'color', default: '#98e690' },
|
|
35
|
+
baseAlpha: { type: 'number', default: 1 },
|
|
30
36
|
// To add into the doc
|
|
31
|
-
min_building_height: { type: 'number', default: 1 },
|
|
32
37
|
height_quarter_legend_box: { type: 'number', default: 11 },
|
|
33
38
|
height_quarter_legend_title: { type: 'number', default: 12 },
|
|
34
39
|
height_building_legend: { type: 'number', default: 0 },
|
|
35
40
|
legend_scale: { type: 'number', default: 1 },
|
|
36
41
|
legend_lookat: { type: 'string', default: "[camera]" },
|
|
42
|
+
metricsInfoId: { type: 'string', default: "" },
|
|
43
|
+
highlightQuarter: { type: 'boolean', default: false },
|
|
37
44
|
field: { type: 'string', default: 'uid' },
|
|
45
|
+
|
|
46
|
+
// Numeric color legend entity to hide/show
|
|
47
|
+
numericColorLegendId: { type: 'string' },
|
|
48
|
+
|
|
49
|
+
// Highlight building by field
|
|
50
|
+
highlightBuildingByField: { type: 'string' },
|
|
51
|
+
highlightBuildingByFieldColor: { type: 'string', default: 'white' },
|
|
52
|
+
|
|
53
|
+
// Wireframe & Transparency by repeated IDs
|
|
54
|
+
wireframeByRepeatedField: { type: 'string' },
|
|
55
|
+
transparent80ByRepeatedField: { type: 'string' },
|
|
56
|
+
transparent20ByRepeatedField: { type: 'string' },
|
|
57
|
+
|
|
58
|
+
// Autoscale when animating or starting
|
|
59
|
+
autoscale: { type: 'boolean', default: false },
|
|
60
|
+
autoscaleSizeX: { type: 'number', default: 3 },
|
|
61
|
+
autoscaleSizeZ: { type: 'number', default: 3 },
|
|
62
|
+
//autoscaleSizeY: { type: 'number', default: 2 }
|
|
63
|
+
|
|
64
|
+
// New layout
|
|
65
|
+
treeLayout: { type: 'boolean', default: false },
|
|
66
|
+
treeQuartersLevelHeight: { type: 'number', default: 0.2 },
|
|
67
|
+
treeFixQuarterHeight: { type: 'boolean', default: false },
|
|
68
|
+
treeHideOneSonQuarters: { type: 'boolean', default: false }
|
|
38
69
|
},
|
|
39
70
|
|
|
40
71
|
/**
|
|
@@ -63,7 +94,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
63
94
|
/**
|
|
64
95
|
* List of visualization properties
|
|
65
96
|
*/
|
|
66
|
-
visProperties: ['height', 'area', 'width', 'depth'],
|
|
97
|
+
visProperties: ['height', 'area', 'width', 'depth', 'color'],
|
|
67
98
|
|
|
68
99
|
/**
|
|
69
100
|
* Set if component needs multiple instancing.
|
|
@@ -92,17 +123,52 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
92
123
|
updateFunction(this, oldData)
|
|
93
124
|
},
|
|
94
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Already autoscaled
|
|
128
|
+
*/
|
|
129
|
+
alreadyAutoscaled: false,
|
|
130
|
+
autoscaleBoats: function () {
|
|
131
|
+
const self = this
|
|
132
|
+
// 2 for X and 2 for Y
|
|
133
|
+
let bbox = new THREE.Box3().setFromObject(this.el.object3D)
|
|
134
|
+
let finalSizeX = bbox.max.x - bbox.min.x
|
|
135
|
+
let finalSizeY = bbox.max.y - bbox.min.y
|
|
136
|
+
let finalSizeZ = bbox.max.z - bbox.min.z
|
|
137
|
+
|
|
138
|
+
let currentScale = this.el.getAttribute("scale")
|
|
139
|
+
if (!currentScale) {
|
|
140
|
+
currentScale = { x: 1, y: 1, z: 1 }
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
this.el.setAttribute("scale", { x: eval(this.data.autoscaleSizeX / finalSizeX) * currentScale.x, y: currentScale.y, z: eval(this.data.autoscaleSizeZ / finalSizeZ) * currentScale.z })
|
|
144
|
+
},
|
|
145
|
+
|
|
95
146
|
/**
|
|
96
147
|
* Called on each scene tick.
|
|
97
148
|
*/
|
|
98
149
|
tick: function (t, delta) {
|
|
99
150
|
let self = this;
|
|
151
|
+
|
|
152
|
+
// First time to autoscale
|
|
153
|
+
if (this.data.autoscale && !this.alreadyAutoscaled) {
|
|
154
|
+
let bbox = new THREE.Box3().setFromObject(this.el.object3D)
|
|
155
|
+
if (bbox.min.x !== Infinity) {
|
|
156
|
+
this.autoscaleBoats()
|
|
157
|
+
this.alreadyAutoscaled = true
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
100
161
|
if (this.animation) {
|
|
101
162
|
let t = { x: 0, y: 0, z: 0 };
|
|
102
163
|
if ((Date.now() - this.start_time) > this.duration) {
|
|
103
164
|
this.animation = false;
|
|
104
165
|
this.setFigures(this.figures, t);
|
|
105
166
|
|
|
167
|
+
// Animation finished, set autoscale if activated
|
|
168
|
+
if (this.data.autoscale) {
|
|
169
|
+
this.autoscaleBoats()
|
|
170
|
+
}
|
|
171
|
+
|
|
106
172
|
//Reactivate legends, check PERFORMANCE
|
|
107
173
|
self.entitiesWithLegend = self.entitiesWithLegend.filter(item => document.getElementById(item.entity.id))
|
|
108
174
|
self.entitiesWithLegend.forEach(item => {
|
|
@@ -121,7 +187,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
121
187
|
}
|
|
122
188
|
entity.legend.setAttribute('position', coordinatesFinal)
|
|
123
189
|
entity.legend.setAttribute('visible', true);
|
|
124
|
-
self.el.parentElement.appendChild(entity.legend)
|
|
190
|
+
self.el.parentElement.appendChild(entity.legend)
|
|
125
191
|
|
|
126
192
|
self.legendsActive.push(entity.legend)
|
|
127
193
|
entity.alreadyActive = true
|
|
@@ -153,6 +219,9 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
153
219
|
updateChart: function (items) {
|
|
154
220
|
console.log('Data Loaded.');
|
|
155
221
|
let t = { x: 0, y: 0, z: 0 };
|
|
222
|
+
this.idsToNotRepeatWireframe = []
|
|
223
|
+
this.idsToNotRepeat20Transparent = []
|
|
224
|
+
this.idsToNotRepeat80Transparent = []
|
|
156
225
|
|
|
157
226
|
// when animation not finished, delete figures and opa 1 to inserted
|
|
158
227
|
if (this.animation) {
|
|
@@ -210,7 +279,14 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
210
279
|
}
|
|
211
280
|
},
|
|
212
281
|
|
|
282
|
+
/**
|
|
283
|
+
* For the categoric colors
|
|
284
|
+
*/
|
|
285
|
+
categoricColorIndex: 0,
|
|
286
|
+
categoricColorMaps: {},
|
|
287
|
+
|
|
213
288
|
generateElements: function (elements, figures, translate, inc) {
|
|
289
|
+
const self = this;
|
|
214
290
|
var increment = inc;
|
|
215
291
|
|
|
216
292
|
// Vertical Limits
|
|
@@ -252,7 +328,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
252
328
|
element.width = elements[i][this.data.width] || 0.5
|
|
253
329
|
}
|
|
254
330
|
if (this.data.height) {
|
|
255
|
-
element.height = elements[i][this.data.height] || this.data.
|
|
331
|
+
element.height = self.normalizeValues(self.babiaMetadata['heightMin'], self.babiaMetadata['heightMax'], self.data.minBuildingHeight, self.data.maxBuildingHeight, elements[i][this.data.height]) || this.data.minBuildingHeight
|
|
256
332
|
}
|
|
257
333
|
if (this.data.depth) {
|
|
258
334
|
element.depth = elements[i][this.data.depth] || 0.5
|
|
@@ -266,8 +342,24 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
266
342
|
var children = [];
|
|
267
343
|
var translate_matrix;
|
|
268
344
|
// Save Zone's parameters
|
|
269
|
-
|
|
345
|
+
// Check scale because it should be abosulte, not relative
|
|
346
|
+
let scale = self.el.getAttribute("scale")
|
|
347
|
+
if (!scale) {
|
|
348
|
+
scale = { x: 1, y: 1, z: 1 }
|
|
349
|
+
}
|
|
350
|
+
element.height = this.data.zone_elevation / scale.y;
|
|
270
351
|
increment -= this.data.border * this.data.extra;
|
|
352
|
+
|
|
353
|
+
// TEST TREE
|
|
354
|
+
if (self.data.treeLayout) {
|
|
355
|
+
element.children.forEach(el => {
|
|
356
|
+
if (!el.children) {
|
|
357
|
+
element.treeMetaphorHeight = el[self.data.height]
|
|
358
|
+
return
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
|
|
271
363
|
[element.width, element.depth, translate_matrix, children] = this.generateElements(element.children, children, translate_matrix, increment);
|
|
272
364
|
translate_matrix.y = element.height;
|
|
273
365
|
increment = inc;
|
|
@@ -342,7 +434,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
342
434
|
let figure
|
|
343
435
|
if (elements[i].children) {
|
|
344
436
|
figure = {
|
|
345
|
-
id:
|
|
437
|
+
id: "boat-" + elements[i][this.data.field],
|
|
346
438
|
name: elements[i][this.data.field],
|
|
347
439
|
posX: posX,
|
|
348
440
|
posY: posY,
|
|
@@ -350,8 +442,25 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
350
442
|
height: element.height,
|
|
351
443
|
depth: element.depth,
|
|
352
444
|
children: children,
|
|
445
|
+
alpha: self.data.baseAlpha,
|
|
353
446
|
translate_matrix: translate_matrix
|
|
354
447
|
}
|
|
448
|
+
|
|
449
|
+
// TEST TREE
|
|
450
|
+
if (self.data.treeLayout) {
|
|
451
|
+
figure.treeMetaphorHeight = element.treeMetaphorHeight
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// Gradient color
|
|
455
|
+
let hierarchyLevel = figure.name.split("/").length - 1
|
|
456
|
+
figure.hierarchyLevel = hierarchyLevel
|
|
457
|
+
figure.renderOrder = hierarchyLevel
|
|
458
|
+
if (self.data.gradientBaseColor) {
|
|
459
|
+
figure.color = greenColorsurface(Math.round(self.normalizeValues(1, self.babiaMetadata['maxLevels'], 15, 100, hierarchyLevel)));
|
|
460
|
+
} else {
|
|
461
|
+
figure.color = self.data.base_color;
|
|
462
|
+
}
|
|
463
|
+
|
|
355
464
|
} else {
|
|
356
465
|
if (this.data.area) {
|
|
357
466
|
figure = {
|
|
@@ -361,6 +470,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
361
470
|
posY: posY,
|
|
362
471
|
width: Math.sqrt(element.area),
|
|
363
472
|
height: element.height,
|
|
473
|
+
alpha: self.data.buildingAlpha,
|
|
364
474
|
depth: Math.sqrt(element.area)
|
|
365
475
|
}
|
|
366
476
|
} else {
|
|
@@ -371,11 +481,59 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
371
481
|
posY: posY,
|
|
372
482
|
width: element.width,
|
|
373
483
|
height: element.height,
|
|
484
|
+
alpha: self.data.buildingAlpha,
|
|
374
485
|
depth: element.depth
|
|
375
486
|
}
|
|
376
487
|
}
|
|
488
|
+
if (typeof elements[i][self.data.color] === 'number') {
|
|
489
|
+
figure.color = heatMapColorforValue(elements[i][self.data.color], self.babiaMetadata['color_max'], self.babiaMetadata['color_min'])
|
|
490
|
+
} else if (typeof elements[i][self.data.color] === 'string') {
|
|
491
|
+
// Categoric color
|
|
492
|
+
if (elements[i][self.data.color] in self.categoricColorMaps) {
|
|
493
|
+
figure.color = self.categoricColorMaps[elements[i][self.data.color]]
|
|
494
|
+
} else {
|
|
495
|
+
self.categoricColorMaps[elements[i][self.data.color]] = colorsArray[self.categoricColorIndex]
|
|
496
|
+
figure.color = colorsArray[self.categoricColorIndex]
|
|
497
|
+
|
|
498
|
+
self.categoricColorIndex = self.categoricColorIndex + 1
|
|
499
|
+
if (self.categoricColorIndex >= colorsArray.length) {
|
|
500
|
+
self.categoricColorIndex = 0
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
|
|
377
507
|
}
|
|
378
508
|
figure.rawData = elements[i]
|
|
509
|
+
|
|
510
|
+
// If transparency by a field on buildings
|
|
511
|
+
// Put transparent 80% to those buildings that share same value for a field selected
|
|
512
|
+
if (self.data.transparent80ByRepeatedField && (!figure.children && self.idsToNotRepeat80Transparent.includes(figure.rawData[self.data.transparent80ByRepeatedField]))) {
|
|
513
|
+
figure.alpha = 0.8
|
|
514
|
+
figure.renderOrder = 2000
|
|
515
|
+
} else {
|
|
516
|
+
self.idsToNotRepeat80Transparent.push(figure.rawData[self.data.transparent80ByRepeatedField])
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// Put transparent 20% to those buildings that share same value for a field selected
|
|
520
|
+
if (self.data.transparent20ByRepeatedField && (!figure.children && self.idsToNotRepeat20Transparent.includes(figure.rawData[self.data.transparent20ByRepeatedField]))) {
|
|
521
|
+
figure.alpha = 0.45
|
|
522
|
+
figure.renderOrder = 2000
|
|
523
|
+
} else {
|
|
524
|
+
self.idsToNotRepeat20Transparent.push(figure.rawData[self.data.transparent20ByRepeatedField])
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// Put wireframe to those buildings that share same value for a field selected
|
|
528
|
+
if (self.data.wireframeByRepeatedField && (!figure.children && self.idsToNotRepeatWireframe.includes(figure.rawData[self.data.wireframeByRepeatedField]))) {
|
|
529
|
+
figure.wireframe = true
|
|
530
|
+
} else {
|
|
531
|
+
figure.wireframe = false
|
|
532
|
+
self.idsToNotRepeatWireframe.push(figure.rawData[self.data.wireframeByRepeatedField])
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
|
|
379
537
|
figures.push(figure);
|
|
380
538
|
}
|
|
381
539
|
|
|
@@ -424,7 +582,13 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
424
582
|
return [width, depth, translate, figures];
|
|
425
583
|
},
|
|
426
584
|
|
|
585
|
+
// If wireframerepeated activated
|
|
586
|
+
idsToNotRepeatWireframe: [],
|
|
587
|
+
idsToNotRepeat80Transparent: [],
|
|
588
|
+
idsToNotRepeat20Transparent: [],
|
|
589
|
+
|
|
427
590
|
drawElements: function (element, figures, translate) {
|
|
591
|
+
const self = this
|
|
428
592
|
|
|
429
593
|
for (let i in figures) {
|
|
430
594
|
|
|
@@ -437,9 +601,60 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
437
601
|
z: -y + translate.z
|
|
438
602
|
}
|
|
439
603
|
|
|
604
|
+
// TEST TREE
|
|
605
|
+
if (self.data.treeLayout) {
|
|
606
|
+
// // Hide quarters that has not children
|
|
607
|
+
if (self.data.treeHideOneSonQuarters && (figures[i].children && figures[i].children.length === 1)) {
|
|
608
|
+
figures[i].alphaTest = 1
|
|
609
|
+
figures[i].dontAddEvents = true
|
|
610
|
+
figures[i].children[0].dontAddLine = true
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
if (self.data.treeFixQuarterHeight) {
|
|
614
|
+
// Fix position y for quarters
|
|
615
|
+
// Check if not undefined because if it is 0, it returns false (thx JS)
|
|
616
|
+
if (figures[i].treeMetaphorHeight !== undefined) {
|
|
617
|
+
position.y = (height / 2 + translate.y / 2) + self.data.treeQuartersLevelHeight
|
|
618
|
+
} else {
|
|
619
|
+
position.y = ((height / 2 + translate.y / 2)) - self.data.treeQuartersLevelHeight - self.data.zone_elevation
|
|
620
|
+
|
|
621
|
+
if (figures[i].height < self.data.treeQuartersLevelHeight) {
|
|
622
|
+
// If flag to hide activated and the parent has only one son, not needed to draw the line
|
|
623
|
+
if (!(self.data.treeHideOneSonQuarters && figures[i].dontAddLine)) {
|
|
624
|
+
// First get top
|
|
625
|
+
let topBuildingY = position.y
|
|
626
|
+
// Get where the quarter is
|
|
627
|
+
let quarterPosY = position.y + (self.data.treeQuartersLevelHeight - (height / 2))
|
|
628
|
+
// Draw the line in the space
|
|
629
|
+
let line = document.createElement('a-entity')
|
|
630
|
+
line.setAttribute('class', 'babiaboatstreelines')
|
|
631
|
+
line.setAttribute('line', {
|
|
632
|
+
start: { x: position.x, y: topBuildingY, z: position.z },
|
|
633
|
+
end: { x: position.x, y: quarterPosY, z: position.z },
|
|
634
|
+
color: 'yellow'
|
|
635
|
+
})
|
|
636
|
+
element.appendChild(line)
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
} else {
|
|
642
|
+
// Quarters on top of the buildings
|
|
643
|
+
if (figures[i].treeMetaphorHeight !== undefined) {
|
|
644
|
+
position.y = ((self.normalizeValues(self.babiaMetadata['heightMin'], self.babiaMetadata['heightMax'], self.data.minBuildingHeight, self.data.maxBuildingHeight, figures[i].treeMetaphorHeight)))
|
|
645
|
+
} else {
|
|
646
|
+
position.y = ((height / 2 + translate.y / 2)) - height - 0.001
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
}
|
|
651
|
+
|
|
440
652
|
let entity = this.createElement(figures[i], position);
|
|
441
653
|
this.addEvents(entity, figures[i]);
|
|
442
654
|
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
|
|
443
658
|
element.appendChild(entity);
|
|
444
659
|
}
|
|
445
660
|
|
|
@@ -594,19 +809,57 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
594
809
|
if (entity.getAttribute('depth') != figures[i].depth) {
|
|
595
810
|
entity.setAttribute('depth', figures[i].depth);
|
|
596
811
|
}
|
|
812
|
+
if (entity.getAttribute('color') != figures[i].color) {
|
|
813
|
+
entity.setAttribute('color', figures[i].color);
|
|
814
|
+
}
|
|
815
|
+
if (entity.getAttribute('material').wireframe != figures[i].wireframe) {
|
|
816
|
+
entity.setAttribute('material', 'wireframe', figures[i].wireframe);
|
|
817
|
+
entity.setAttribute('material', 'wireframeLinewidth', 0.1);
|
|
818
|
+
}
|
|
597
819
|
|
|
598
820
|
} else {
|
|
599
821
|
// RESIZE
|
|
600
822
|
this.resize(entity, new_time, delta, figures[i], figures_old[index]);
|
|
601
823
|
// TRASLATE
|
|
602
824
|
this.traslate(entity, new_time, delta, figures[i], figures_old[index], translate, translate_old);
|
|
825
|
+
// COLOR
|
|
826
|
+
if (entity.getAttribute('color') != figures[i].color && !self.inEntitiesWithLegend(entity)) {
|
|
827
|
+
entity.setAttribute('color', figures[i].color);
|
|
828
|
+
}
|
|
829
|
+
if (entity.getAttribute('material').wireframe != figures[i].wireframe) {
|
|
830
|
+
entity.setAttribute('material', 'wireframe', figures[i].wireframe);
|
|
831
|
+
entity.setAttribute('material', 'wireframeLinewidth', 0.1);
|
|
832
|
+
}
|
|
833
|
+
if (entity.getAttribute('material').opacity != figures[i].alpha) {
|
|
834
|
+
entity.setAttribute('material', 'opacity', figures[i].alpha);
|
|
835
|
+
entity.object3D.renderOrder = figures[i].renderOrder
|
|
836
|
+
}
|
|
603
837
|
|
|
604
838
|
if (figures[i].children) {
|
|
605
839
|
this.Animation(entity, figures[i].children, figures_old[index].children, delta, figures[i].translate_matrix, figures_old[index].translate_matrix);
|
|
606
840
|
} else {
|
|
607
841
|
// Building color if changed, force to the new one
|
|
608
|
-
if(figures[i].rawData[self.data.color] !== figures_old[index].rawData[self.data.color]) {
|
|
609
|
-
|
|
842
|
+
if (figures[i].rawData[self.data.color] !== figures_old[index].rawData[self.data.color]) {
|
|
843
|
+
// Color numeric or categoric
|
|
844
|
+
let color
|
|
845
|
+
if (typeof figures[i].rawData[self.data.color] === 'number') {
|
|
846
|
+
color = heatMapColorforValue(figures[i].rawData[self.data.color], self.babiaMetadata['color_max'], self.babiaMetadata['color_min'])
|
|
847
|
+
} else if (typeof figures[i].rawData[self.data.color] === 'string') {
|
|
848
|
+
// Categoric color
|
|
849
|
+
if (figures[i].rawData[self.data.color] in self.categoricColorMaps) {
|
|
850
|
+
color = self.categoricColorMaps[figures[i].rawData[self.data.color]]
|
|
851
|
+
} else {
|
|
852
|
+
self.categoricColorMaps[figures[i].rawData[self.data.color]] = colorsArray[self.categoricColorIndex]
|
|
853
|
+
color = colorsArray[self.categoricColorIndex]
|
|
854
|
+
|
|
855
|
+
self.categoricColorIndex = self.categoricColorIndex + 1
|
|
856
|
+
if (self.categoricColorIndex >= colorsArray.length) {
|
|
857
|
+
self.categoricColorIndex = 0
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
|
|
610
863
|
let oldColor = entity.getAttribute('color')
|
|
611
864
|
if (color !== oldColor) {
|
|
612
865
|
entity.setAttribute('color', color)
|
|
@@ -672,7 +925,19 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
672
925
|
}
|
|
673
926
|
},
|
|
674
927
|
|
|
928
|
+
inEntitiesWithLegend(obj) {
|
|
929
|
+
let i;
|
|
930
|
+
for (i = 0; i < this.entitiesWithLegend.length; i++) {
|
|
931
|
+
if (this.entitiesWithLegend[i].entity === obj) {
|
|
932
|
+
return true;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
return false;
|
|
937
|
+
},
|
|
938
|
+
|
|
675
939
|
setFigures: function (figures, translate) {
|
|
940
|
+
const self = this
|
|
676
941
|
figures.forEach(figure => {
|
|
677
942
|
let entity = document.getElementById(figure.id);
|
|
678
943
|
if (entity) {
|
|
@@ -685,17 +950,95 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
685
950
|
if (entity.getAttribute('depth') != figure.depth) {
|
|
686
951
|
entity.setAttribute('depth', figure.depth);
|
|
687
952
|
}
|
|
953
|
+
// If legend active, don't force change color, put it as the color before
|
|
954
|
+
if (self.inEntitiesWithLegend(entity)) {
|
|
955
|
+
entity.setAttribute('babiaxrFirstColor', figure.color)
|
|
956
|
+
} else {
|
|
957
|
+
if (entity.getAttribute('color') != figure.color) {
|
|
958
|
+
entity.setAttribute('color', figure.color);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
688
961
|
|
|
689
962
|
//TODO: Full opacity because it was in 0.5 if new building/quarter
|
|
690
963
|
if (entity.components.material.data.opacity < 1) {
|
|
691
964
|
setOpacity(entity, 1)
|
|
692
965
|
}
|
|
693
966
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
(
|
|
697
|
-
|
|
698
|
-
|
|
967
|
+
// Quarters to alpha if tree fix position
|
|
968
|
+
if (entity.getAttribute('material').opacity != figure.alpha) {
|
|
969
|
+
entity.setAttribute('material', 'opacity', figure.alpha);
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
// TEST TREE
|
|
973
|
+
if (self.data.treeLayout) {
|
|
974
|
+
// Hide quarters that has not children
|
|
975
|
+
if (self.data.treeHideOneSonQuarters && (figure.children && figure.children.length === 1)) {
|
|
976
|
+
figure.alphaTest = 1
|
|
977
|
+
figure.dontAddEvents = true
|
|
978
|
+
figure.children[0].dontAddLine = true
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
if (self.data.treeFixQuarterHeight) {
|
|
982
|
+
// Fix position y for quarters
|
|
983
|
+
if (figure.treeMetaphorHeight !== undefined) {
|
|
984
|
+
entity.object3D.position.set(
|
|
985
|
+
figure.posX - translate.x,
|
|
986
|
+
(figure.height / 2 + translate.y / 2) + self.data.treeQuartersLevelHeight,
|
|
987
|
+
(- figure.posY + translate.z),
|
|
988
|
+
)
|
|
989
|
+
} else {
|
|
990
|
+
let positionYFixed = ((figure.height / 2 + translate.y / 2)) - self.data.treeQuartersLevelHeight - self.data.zone_elevation
|
|
991
|
+
let positionX = figure.posX - translate.x
|
|
992
|
+
let positionZ = (- figure.posY + translate.z)
|
|
993
|
+
entity.object3D.position.set(
|
|
994
|
+
positionX,
|
|
995
|
+
positionYFixed,
|
|
996
|
+
positionZ,
|
|
997
|
+
)
|
|
998
|
+
// DRAW LINE WHEN DOES NOT ACHIEVE THE QUARTER (TOO LOW)
|
|
999
|
+
if (figure.height < self.data.treeQuartersLevelHeight) {
|
|
1000
|
+
// If flag to hide activated and the parent has only one son, not needed to draw the line
|
|
1001
|
+
if (!(self.data.treeHideOneSonQuarters && figure.dontAddLine)) {
|
|
1002
|
+
// First get top
|
|
1003
|
+
let topBuildingY = positionYFixed
|
|
1004
|
+
// Get where the quarter is
|
|
1005
|
+
let quarterPosY = positionYFixed + (self.treeQuartersLevelHeight - figure.height / 2)
|
|
1006
|
+
// Draw the line in the space
|
|
1007
|
+
let line = document.createElement('a-entity')
|
|
1008
|
+
line.setAttribute('class', 'babiaboatstreelines')
|
|
1009
|
+
line.setAttribute('line', {
|
|
1010
|
+
start: { x: positionX, y: topBuildingY, z: positionZ },
|
|
1011
|
+
end: { x: positionX, y: quarterPosY, z: positionZ },
|
|
1012
|
+
color: 'yellow'
|
|
1013
|
+
})
|
|
1014
|
+
entity.parentElement.appendChild(line)
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
} else {
|
|
1019
|
+
if (figure.treeMetaphorHeight !== undefined) {
|
|
1020
|
+
entity.object3D.position.set(
|
|
1021
|
+
figure.posX - translate.x,
|
|
1022
|
+
((self.normalizeValues(self.babiaMetadata['heightMin'], self.babiaMetadata['heightMax'], self.data.minBuildingHeight, self.data.maxBuildingHeight, figure.treeMetaphorHeight))),
|
|
1023
|
+
(- figure.posY + translate.z),
|
|
1024
|
+
)
|
|
1025
|
+
} else {
|
|
1026
|
+
entity.object3D.position.set(
|
|
1027
|
+
figure.posX - translate.x,
|
|
1028
|
+
((figure.height / 2 + translate.y / 2)) - figure.height - 0.001,
|
|
1029
|
+
(- figure.posY + translate.z),
|
|
1030
|
+
)
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
} else {
|
|
1034
|
+
// Lo de no tree, lo que estaba antes
|
|
1035
|
+
entity.object3D.position.set(
|
|
1036
|
+
figure.posX - translate.x,
|
|
1037
|
+
((parseFloat(figure.height) + translate.y) / 2),
|
|
1038
|
+
(- figure.posY + translate.z),
|
|
1039
|
+
)
|
|
1040
|
+
}
|
|
1041
|
+
|
|
699
1042
|
if (figure.children) {
|
|
700
1043
|
this.setFigures(figure.children, figure.translate_matrix);
|
|
701
1044
|
}
|
|
@@ -704,6 +1047,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
704
1047
|
},
|
|
705
1048
|
|
|
706
1049
|
resize: function (entity, new_time, delta, figure, figure_old) {
|
|
1050
|
+
const self = this
|
|
707
1051
|
if (((new_time - this.start_time) < this.duration) &&
|
|
708
1052
|
((figure.width != figure_old.width) ||
|
|
709
1053
|
(figure.height != figure_old.height) ||
|
|
@@ -752,7 +1096,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
752
1096
|
//Check if has transparent box as a quarter
|
|
753
1097
|
if (entity.classList.contains('babiaquarterboxactivated')) {
|
|
754
1098
|
entity.childNodes.forEach(child => {
|
|
755
|
-
if (child.classList.contains('babiaquarterlegendbox')){
|
|
1099
|
+
if (child.classList.contains('babiaquarterlegendbox')) {
|
|
756
1100
|
child.setAttribute('geometry', 'width', new_width);
|
|
757
1101
|
child.setAttribute('geometry', 'depth', new_depth);
|
|
758
1102
|
child.setAttribute('material', 'opacity', 0.4);
|
|
@@ -774,7 +1118,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
774
1118
|
//Check if has transparent box as a quarter
|
|
775
1119
|
if (entity.classList.contains('babiaquarterboxactivated')) {
|
|
776
1120
|
entity.childNodes.forEach(child => {
|
|
777
|
-
if (child.classList.contains('babiaquarterlegendbox')){
|
|
1121
|
+
if (child.classList.contains('babiaquarterlegendbox')) {
|
|
778
1122
|
child.setAttribute('geometry', 'width', new_width);
|
|
779
1123
|
child.setAttribute('geometry', 'depth', new_depth);
|
|
780
1124
|
child.setAttribute('material', 'opacity', 0.4);
|
|
@@ -837,10 +1181,35 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
837
1181
|
|
|
838
1182
|
// set color
|
|
839
1183
|
if (figure.children) {
|
|
840
|
-
color
|
|
1184
|
+
// Gradient color depending on the level for the base
|
|
1185
|
+
let hierarchyLevel = figure.name.split("/").length - 1
|
|
1186
|
+
figure.hierarchyLevel = hierarchyLevel
|
|
1187
|
+
entity.object3D.renderOrder = hierarchyLevel
|
|
1188
|
+
if (self.data.gradientBaseColor) {
|
|
1189
|
+
color = greenColorsurface(Math.round(self.normalizeValues(1, self.babiaMetadata['maxLevels'], 15, 100, hierarchyLevel)));
|
|
1190
|
+
} else {
|
|
1191
|
+
color = self.data.base_color;
|
|
1192
|
+
}
|
|
841
1193
|
} else {
|
|
842
1194
|
if (self.data.color) {
|
|
843
|
-
|
|
1195
|
+
if (typeof figure.rawData[self.data.color] === 'number') {
|
|
1196
|
+
color = heatMapColorforValue(figure.rawData[self.data.color], self.babiaMetadata['color_max'], self.babiaMetadata['color_min'])
|
|
1197
|
+
} else if (typeof figure.rawData[self.data.color] === 'string') {
|
|
1198
|
+
// Categoric color
|
|
1199
|
+
if (figure.rawData[self.data.color] in self.categoricColorMaps) {
|
|
1200
|
+
color = self.categoricColorMaps[figure.rawData[self.data.color]]
|
|
1201
|
+
} else {
|
|
1202
|
+
self.categoricColorMaps[figure.rawData[self.data.color]] = colorsArray[self.categoricColorIndex]
|
|
1203
|
+
color = colorsArray[self.categoricColorIndex]
|
|
1204
|
+
|
|
1205
|
+
self.categoricColorIndex = self.categoricColorIndex + 1
|
|
1206
|
+
if (self.categoricColorIndex >= colorsArray.length) {
|
|
1207
|
+
self.categoricColorIndex = 0
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
} else {
|
|
1211
|
+
color = self.data.building_color;
|
|
1212
|
+
}
|
|
844
1213
|
} else {
|
|
845
1214
|
color = self.data.building_color;
|
|
846
1215
|
}
|
|
@@ -851,11 +1220,17 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
851
1220
|
entity.setAttribute('width', width);
|
|
852
1221
|
entity.setAttribute('height', height);
|
|
853
1222
|
entity.setAttribute('depth', depth);
|
|
1223
|
+
entity.object3D.renderOrder = figure.renderOrder
|
|
854
1224
|
// rawData building
|
|
855
1225
|
if (figure.rawData) {
|
|
856
1226
|
entity.babiaRawData = figure.rawData
|
|
857
1227
|
}
|
|
858
1228
|
|
|
1229
|
+
// Higlight repeated
|
|
1230
|
+
if (self.data.highlightBuildingByField && figure.rawData) {
|
|
1231
|
+
entity.setAttribute("babia-highlightbuildingbyfield", String(figure.rawData[self.data.highlightBuildingByField]).replace("/", "").replace("@", ""))
|
|
1232
|
+
}
|
|
1233
|
+
|
|
859
1234
|
// add into scene
|
|
860
1235
|
entity.setAttribute('position', {
|
|
861
1236
|
x: position.x,
|
|
@@ -863,6 +1238,19 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
863
1238
|
z: position.z
|
|
864
1239
|
});
|
|
865
1240
|
|
|
1241
|
+
// add opacity
|
|
1242
|
+
entity.setAttribute('material', 'opacity', figure.alpha);
|
|
1243
|
+
|
|
1244
|
+
// add opacity
|
|
1245
|
+
entity.setAttribute('material', 'wireframe', figure.wireframe);
|
|
1246
|
+
entity.setAttribute('material', 'wireframeLinewidth', 0.1);
|
|
1247
|
+
|
|
1248
|
+
// transparent if alphaTest
|
|
1249
|
+
if (figure.alphaTest) {
|
|
1250
|
+
entity.setAttribute('material', 'alphaTest', figure.alphaTest);
|
|
1251
|
+
entity.removeAttribute('class');
|
|
1252
|
+
}
|
|
1253
|
+
|
|
866
1254
|
return entity;
|
|
867
1255
|
},
|
|
868
1256
|
|
|
@@ -870,88 +1258,217 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
870
1258
|
* Process data obtained from producer
|
|
871
1259
|
*/
|
|
872
1260
|
processData: function (_data) {
|
|
1261
|
+
const self = this
|
|
873
1262
|
console.log("processData", _data);
|
|
874
1263
|
let data = this.data;
|
|
875
1264
|
this.newData = _data;
|
|
876
1265
|
this.babiaMetadata = { id: this.babiaMetadata.id++ };
|
|
1266
|
+
this.categoricColorMaps = {}
|
|
1267
|
+
this.categoricColorIndex = 0
|
|
877
1268
|
|
|
878
1269
|
// If color metric activated, save in the metadata the max and min value for mapping
|
|
879
1270
|
if (data.color) {
|
|
880
|
-
let [color_max, color_min] =
|
|
1271
|
+
let [color_max, color_min, color_values] = getMaxMinValues(this.newData, data.color, [])
|
|
881
1272
|
this.babiaMetadata['color_max'] = color_max
|
|
882
1273
|
this.babiaMetadata['color_min'] = color_min
|
|
1274
|
+
let colorAvg = Math.round(color_values.reduce((a, b) => a + b, 0) / color_values.length)
|
|
1275
|
+
this.babiaMetadata['colorAvg'] = colorAvg
|
|
1276
|
+
}
|
|
1277
|
+
// Get important data for normalize metrics
|
|
1278
|
+
let [heightMax, heightMin, height_values] = getMaxMinValues(this.newData, data.height, [])
|
|
1279
|
+
this.babiaMetadata['heightMax'] = heightMax
|
|
1280
|
+
this.babiaMetadata['heightMin'] = heightMin
|
|
1281
|
+
let heightAvg = Math.round(height_values.reduce((a, b) => a + b, 0) / height_values.length)
|
|
1282
|
+
this.babiaMetadata['heightAvg'] = heightAvg
|
|
1283
|
+
this.babiaMetadata['maxLevels'] = getLevels(this.newData, 0)
|
|
1284
|
+
|
|
1285
|
+
if (data.area) {
|
|
1286
|
+
let [areaMax, areaMin, area_values] = getMaxMinValues(this.newData, data.area, [])
|
|
1287
|
+
this.babiaMetadata['areaMax'] = areaMax
|
|
1288
|
+
this.babiaMetadata['areaMin'] = areaMin
|
|
1289
|
+
this.babiaMetadata['areaAvg'] = Math.round(area_values.reduce((a, b) => a + b, 0) / area_values.length)
|
|
1290
|
+
} else {
|
|
1291
|
+
let [widthMax, widthMin, width_values] = getMaxMinValues(this.newData, data.width, [])
|
|
1292
|
+
this.babiaMetadata['widthMax'] = widthMax
|
|
1293
|
+
this.babiaMetadata['widthMin'] = widthMin
|
|
1294
|
+
this.babiaMetadata['widthAvg'] = Math.round(width_values.reduce((a, b) => a + b, 0) / width_values.length)
|
|
1295
|
+
|
|
1296
|
+
let [depthMax, depthMin, depth_values] = getMaxMinValues(this.newData, data.depth, [])
|
|
1297
|
+
this.babiaMetadata['depthMax'] = depthMax
|
|
1298
|
+
this.babiaMetadata['depthMin'] = depthMin
|
|
1299
|
+
this.babiaMetadata['depthAvg'] = Math.round(depth_values.reduce((a, b) => a + b, 0) / depth_values.length)
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
// Update place where metric info if activated
|
|
1303
|
+
if (this.data.metricsInfoId) {
|
|
1304
|
+
let text = `Metrics information\nMETRIC (FIELD): MIN - MAX - AVG\n\nHeight (${data.height}) - ${heightMin} - ${heightMax} - ${heightAvg}`
|
|
1305
|
+
if (this.data.area) {
|
|
1306
|
+
text += `\nArea (${data.area}) - ${this.babiaMetadata['areaMin']} - ${this.babiaMetadata['areaMax']} - ${this.babiaMetadata['areaAvg']}`
|
|
1307
|
+
} else {
|
|
1308
|
+
text += `\nWidth (${data.width}) - ${this.babiaMetadata['widthMin']} - ${this.babiaMetadata['widthMax']} - ${this.babiaMetadata['widthAvg']}`
|
|
1309
|
+
text += `\nDepth (${data.depth}) - ${this.babiaMetadata['depthMin']} - ${this.babiaMetadata['depthMax']} - ${this.babiaMetadata['depthAvg']}`
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
if (this.data.color && typeof this.babiaMetadata['color_max'] !== 'string') {
|
|
1313
|
+
document.getElementById(this.data.numericColorLegendId).setAttribute("visible", true)
|
|
1314
|
+
text += `\nColor (${data.color}) - ${this.babiaMetadata['color_min']} - ${this.babiaMetadata['color_max']} - ${this.babiaMetadata['colorAvg']}`
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
|
|
1318
|
+
let placeToInsertInfo = document.getElementById(this.data.metricsInfoId)
|
|
1319
|
+
placeToInsertInfo.setAttribute('text', {
|
|
1320
|
+
'value': text,
|
|
1321
|
+
'align': 'center',
|
|
1322
|
+
'width': 3,
|
|
1323
|
+
'color': 'black',
|
|
1324
|
+
'alphaTest': 6,
|
|
1325
|
+
'opacity': 6,
|
|
1326
|
+
'transparent': false
|
|
1327
|
+
})
|
|
883
1328
|
}
|
|
1329
|
+
|
|
884
1330
|
this.notiBuffer.set(this.newData)
|
|
1331
|
+
|
|
1332
|
+
// Remove lines if activated the fixed position
|
|
1333
|
+
if (this.data.treeLayout && this.data.treeFixQuarterHeight) {
|
|
1334
|
+
this.removeTreeLines()
|
|
1335
|
+
}
|
|
1336
|
+
|
|
885
1337
|
// Create city
|
|
886
1338
|
this.updateChart(this.newData)
|
|
1339
|
+
|
|
1340
|
+
// Categoric color legend
|
|
1341
|
+
if (this.data.metricsInfoId && typeof (this.babiaMetadata['color_max']) !== "number") {
|
|
1342
|
+
// Hide numericlegend
|
|
1343
|
+
document.getElementById(self.data.numericColorLegendId).setAttribute("visible", false)
|
|
1344
|
+
|
|
1345
|
+
// If already exists, just show
|
|
1346
|
+
if (self.entityCatColorLegend) {
|
|
1347
|
+
self.entityCatColorLegend.remove()
|
|
1348
|
+
self.entityCatColorLegend = undefined
|
|
1349
|
+
}
|
|
1350
|
+
let placeToInsertInfo = document.getElementById(this.data.metricsInfoId)
|
|
1351
|
+
self.entityCatColorLegend = document.createElement("a-plane")
|
|
1352
|
+
self.entityCatColorLegend.setAttribute("position", '-3 0 0')
|
|
1353
|
+
self.entityCatColorLegend.setAttribute("width", 2.8)
|
|
1354
|
+
self.entityCatColorLegend.setAttribute("height", 5)
|
|
1355
|
+
self.entityCatColorLegend.setAttribute("position", '-3 0 0')
|
|
1356
|
+
self.entityCatColorLegend.setAttribute("material", 'color', "#B7B7B7")
|
|
1357
|
+
let posY = 2.2
|
|
1358
|
+
let text = `COLOR LEGEND (${this.data.color})`
|
|
1359
|
+
let entity = document.createElement("a-entity")
|
|
1360
|
+
entity.setAttribute('text', {
|
|
1361
|
+
'value': text,
|
|
1362
|
+
'align': 'center',
|
|
1363
|
+
'width': 3,
|
|
1364
|
+
'color': 'black',
|
|
1365
|
+
})
|
|
1366
|
+
entity.setAttribute("position", { x: 0, y: posY, z: 0 })
|
|
1367
|
+
posY = posY - 0.2
|
|
1368
|
+
self.entityCatColorLegend.appendChild(entity)
|
|
1369
|
+
for (const [key, value] of Object.entries(this.categoricColorMaps)) {
|
|
1370
|
+
let text = `${key}: ${value}`;
|
|
1371
|
+
let entity = document.createElement("a-entity")
|
|
1372
|
+
entity.setAttribute('text', {
|
|
1373
|
+
'value': text,
|
|
1374
|
+
'align': 'center',
|
|
1375
|
+
'width': 3,
|
|
1376
|
+
'color': value,
|
|
1377
|
+
})
|
|
1378
|
+
entity.setAttribute("position", { x: 0, y: posY, z: 0 })
|
|
1379
|
+
posY = posY - 0.15
|
|
1380
|
+
self.entityCatColorLegend.appendChild(entity)
|
|
1381
|
+
|
|
1382
|
+
}
|
|
1383
|
+
placeToInsertInfo.appendChild(self.entityCatColorLegend)
|
|
1384
|
+
} else if (this.data.metricsInfoId && typeof (this.babiaMetadata['color_max']) === "number") {
|
|
1385
|
+
if (self.entityCatColorLegend) {
|
|
1386
|
+
self.entityCatColorLegend.remove()
|
|
1387
|
+
self.entityCatColorLegend = undefined
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
},
|
|
1391
|
+
|
|
1392
|
+
removeTreeLines: function () {
|
|
1393
|
+
let currentLines = this.el.querySelectorAll(".babiaboatstreelines");
|
|
1394
|
+
for (line of currentLines) {
|
|
1395
|
+
line.remove()
|
|
1396
|
+
}
|
|
1397
|
+
},
|
|
1398
|
+
|
|
1399
|
+
normalizeValues: function (valmin, valmax, newmin, newmax, val) {
|
|
1400
|
+
return (((val - valmin) / (valmax - valmin)) * (newmax - newmin)) + newmin;
|
|
887
1401
|
},
|
|
888
1402
|
|
|
889
1403
|
addEvents: function (entity, figure) {
|
|
890
1404
|
let self = this;
|
|
891
1405
|
if (figure.children) {
|
|
892
1406
|
// Quarter
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
entity.
|
|
902
|
-
|
|
1407
|
+
// dont add events flag (if transparent)
|
|
1408
|
+
if (!figure.dontAddEvents) {
|
|
1409
|
+
let transparentBox;
|
|
1410
|
+
entity.addEventListener('click', function (e) {
|
|
1411
|
+
// Just launch the event on the child
|
|
1412
|
+
if (e.target !== this)
|
|
1413
|
+
return;
|
|
1414
|
+
|
|
1415
|
+
if (entity.legend) {
|
|
1416
|
+
self.el.parentElement.removeChild(transparentBox)
|
|
1417
|
+
entity.classList.remove("babiaquarterboxactivated");
|
|
1418
|
+
self.el.parentElement.removeChild(entity.legend)
|
|
1419
|
+
|
|
1420
|
+
// Remove from the array that has the entity activated and the legend
|
|
1421
|
+
const index = self.entitiesWithLegend.findIndex(item => item.entity === entity);
|
|
1422
|
+
if (index > -1) {
|
|
1423
|
+
self.entitiesWithLegend.splice(index, 1);
|
|
1424
|
+
}
|
|
1425
|
+
const indexLegend = self.legendsActive.indexOf(entity.legend);
|
|
1426
|
+
if (index > -1) {
|
|
1427
|
+
self.legendsActive.splice(indexLegend, 1);
|
|
1428
|
+
}
|
|
903
1429
|
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
if (index > -1) {
|
|
907
|
-
self.entitiesWithLegend.splice(index, 1);
|
|
908
|
-
}
|
|
909
|
-
const indexLegend = self.legendsActive.indexOf(entity.legend);
|
|
910
|
-
if (index > -1) {
|
|
911
|
-
self.legendsActive.splice(indexLegend, 1);
|
|
912
|
-
}
|
|
1430
|
+
entity.legend = undefined
|
|
1431
|
+
transparentBox = undefined
|
|
913
1432
|
|
|
914
|
-
|
|
915
|
-
|
|
1433
|
+
} else {
|
|
1434
|
+
transparentBox = document.createElement('a-entity');
|
|
1435
|
+
transparentBox.setAttribute('class', 'babiaquarterlegendbox')
|
|
1436
|
+
entity.classList.add("babiaquarterboxactivated");
|
|
1437
|
+
let oldGeometry = entity.getAttribute('geometry')
|
|
1438
|
+
let scale = self.el.getAttribute("scale") || { x: 1, y: 1, z: 1 }
|
|
1439
|
+
let tsBoxHeight = (oldGeometry.height * scale.y) + self.data.height_quarter_legend_box
|
|
1440
|
+
transparentBox.setAttribute('geometry', {
|
|
1441
|
+
height: tsBoxHeight,
|
|
1442
|
+
depth: oldGeometry.depth * scale.z,
|
|
1443
|
+
width: oldGeometry.width * scale.x
|
|
1444
|
+
});
|
|
1445
|
+
transparentBox.setAttribute('material', {
|
|
1446
|
+
'visible': true,
|
|
1447
|
+
'opacity': 0.4
|
|
1448
|
+
});
|
|
1449
|
+
// This is because the webGL render order does not work well with the transparencies
|
|
1450
|
+
transparentBox.object3D.renderOrder = 1000000000
|
|
1451
|
+
let worldPos = new THREE.Vector3();
|
|
1452
|
+
let coordinates = worldPos.setFromMatrixPosition(entity.object3D.matrixWorld);
|
|
1453
|
+
transparentBox.setAttribute('position', coordinates)
|
|
1454
|
+
self.el.parentElement.appendChild(transparentBox)
|
|
916
1455
|
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
}
|
|
927
|
-
transparentBox.setAttribute('geometry', {
|
|
928
|
-
height: tsBoxHeight,
|
|
929
|
-
depth: oldGeometry.depth,
|
|
930
|
-
width: oldGeometry.width
|
|
931
|
-
});
|
|
932
|
-
transparentBox.setAttribute('material', {
|
|
933
|
-
'visible': true,
|
|
934
|
-
'opacity': 0.4
|
|
935
|
-
});
|
|
936
|
-
entity.appendChild(transparentBox)
|
|
1456
|
+
let coordinatesFinal = {
|
|
1457
|
+
x: coordinates.x,
|
|
1458
|
+
y: self.data.height_quarter_legend_title,
|
|
1459
|
+
z: coordinates.z
|
|
1460
|
+
}
|
|
1461
|
+
entity.legend = generateLegend(figure.name, self.data.legend_scale, self.data.legend_lookat, 'black', 'white');
|
|
1462
|
+
entity.legend.setAttribute('position', coordinatesFinal)
|
|
1463
|
+
entity.legend.setAttribute('visible', true);
|
|
1464
|
+
self.el.parentElement.appendChild(entity.legend)
|
|
937
1465
|
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
let coordinatesFinal = {
|
|
942
|
-
x: coordinates.x,
|
|
943
|
-
y: self.data.height_quarter_legend_title,
|
|
944
|
-
z: coordinates.z
|
|
1466
|
+
// Add to the elements that has the legend activated
|
|
1467
|
+
self.entitiesWithLegend.push({ 'figure': figure, 'entity': entity })
|
|
1468
|
+
self.legendsActive.push(entity.legend)
|
|
945
1469
|
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
self.el.parentElement.appendChild(entity.legend)
|
|
949
|
-
|
|
950
|
-
// Add to the elements that has the legend activated
|
|
951
|
-
self.entitiesWithLegend.push({'figure': figure, 'entity': entity})
|
|
952
|
-
self.legendsActive.push(entity.legend)
|
|
953
|
-
}
|
|
954
|
-
})
|
|
1470
|
+
})
|
|
1471
|
+
}
|
|
955
1472
|
|
|
956
1473
|
this.drawElements(entity, figure.children, figure.translate_matrix);
|
|
957
1474
|
} else {
|
|
@@ -964,6 +1481,22 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
964
1481
|
return;
|
|
965
1482
|
|
|
966
1483
|
if (entity.alreadyActive) {
|
|
1484
|
+
// Remove Higlight quarter
|
|
1485
|
+
if (self.data.highlightQuarter) {
|
|
1486
|
+
if (parseInt(entity.parentElement.getAttribute('babiaxrHightlighted')) == 1) {
|
|
1487
|
+
let oldPosition = entity.parentElement.getAttribute('position')
|
|
1488
|
+
entity.parentElement.setAttribute("position", { x: oldPosition.x, y: entity.parentElement.getAttribute('babiaxrFirstYPosition'), z: oldPosition.z })
|
|
1489
|
+
entity.parentElement.setAttribute('material', {
|
|
1490
|
+
'color': entity.parentElement.getAttribute('babiaxrFirstColor')
|
|
1491
|
+
});
|
|
1492
|
+
entity.parentElement.setAttribute('babiaxrHightlighted', 0)
|
|
1493
|
+
} else {
|
|
1494
|
+
let currentActives = parseInt(entity.parentElement.getAttribute('babiaxrHightlighted'))
|
|
1495
|
+
entity.parentElement.setAttribute('babiaxrHightlighted', currentActives - 1)
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
|
|
967
1500
|
entity.legend.setAttribute('visible', false);
|
|
968
1501
|
entity.setAttribute('geometry', {
|
|
969
1502
|
height: entityGeometry.height - 0.1,
|
|
@@ -985,16 +1518,36 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
985
1518
|
self.legendsActive.splice(indexLegend, 1);
|
|
986
1519
|
}
|
|
987
1520
|
|
|
1521
|
+
// Remove Hihglight by field
|
|
1522
|
+
if (self.data.highlightBuildingByField) {
|
|
1523
|
+
let fieldValue = entity.getAttribute("babia-highlightbuildingbyfield")
|
|
1524
|
+
let toRemoveHighlight = document.querySelectorAll(`[babia-highlightbuildingbyfield=${fieldValue}]`)
|
|
1525
|
+
toRemoveHighlight.forEach(element => {
|
|
1526
|
+
if (entity !== element) {
|
|
1527
|
+
if (element.highlightbuildingbyfieldactive && !element.alreadyActive) {
|
|
1528
|
+
let oldColor = element.getAttribute('babiaxrBeforeBuildingHighlight')
|
|
1529
|
+
element.setAttribute("material", "color", oldColor)
|
|
1530
|
+
element.highlightbuildingbyfieldactive = false
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
|
|
988
1536
|
entity.legend = undefined
|
|
989
1537
|
entity.alreadyActive = false
|
|
990
1538
|
} else {
|
|
1539
|
+
// Avoid to click if higlighted by building field
|
|
1540
|
+
if (entity.highlightbuildingbyfieldactive) {
|
|
1541
|
+
return
|
|
1542
|
+
}
|
|
1543
|
+
|
|
991
1544
|
entity.alreadyActive = true
|
|
992
1545
|
|
|
993
1546
|
// If clicked again but not mouseover
|
|
994
1547
|
if (!entity.legend) {
|
|
995
1548
|
// COPY FROM 626
|
|
996
1549
|
entityGeometry = entity.getAttribute('geometry')
|
|
997
|
-
let boxPosition = entity.getAttribute(
|
|
1550
|
+
let boxPosition = entity.getAttribute('position')
|
|
998
1551
|
entity.setAttribute('position', boxPosition)
|
|
999
1552
|
entity.setAttribute('babiaxrFirstColor', entity.getAttribute("material")["color"])
|
|
1000
1553
|
entity.setAttribute('material', {
|
|
@@ -1019,8 +1572,36 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
1019
1572
|
self.el.parentElement.appendChild(entity.legend);
|
|
1020
1573
|
}
|
|
1021
1574
|
|
|
1575
|
+
// Higlight quarter
|
|
1576
|
+
if (self.data.highlightQuarter) {
|
|
1577
|
+
if (!entity.parentElement.getAttribute('babiaxrHightlighted') || parseInt(entity.parentElement.getAttribute('babiaxrHightlighted')) == 0) {
|
|
1578
|
+
let oldPosition = entity.parentElement.getAttribute("position")
|
|
1579
|
+
entity.parentElement.setAttribute('babiaxrFirstYPosition', oldPosition.y)
|
|
1580
|
+
entity.parentElement.setAttribute("position", { x: oldPosition.x, y: oldPosition.y + 0.2, z: oldPosition.z })
|
|
1581
|
+
entity.parentElement.setAttribute('babiaxrFirstColor', entity.parentElement.getAttribute("material")["color"])
|
|
1582
|
+
entity.parentElement.setAttribute('material', 'color', '#bfbfbf')
|
|
1583
|
+
entity.parentElement.setAttribute('babiaxrHightlighted', 1)
|
|
1584
|
+
} else {
|
|
1585
|
+
let currentActives = parseInt(entity.parentElement.getAttribute('babiaxrHightlighted'))
|
|
1586
|
+
entity.parentElement.setAttribute('babiaxrHightlighted', currentActives + 1)
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
// Hihglight by field
|
|
1591
|
+
if (self.data.highlightBuildingByField) {
|
|
1592
|
+
let fieldValue = entity.getAttribute("babia-highlightbuildingbyfield")
|
|
1593
|
+
let toHighlight = document.querySelectorAll(`[babia-highlightbuildingbyfield=${fieldValue}]`)
|
|
1594
|
+
toHighlight.forEach(element => {
|
|
1595
|
+
if (entity !== element && !element.highlightbuildingbyfieldactive && !element.alreadyActive) {
|
|
1596
|
+
element.highlightbuildingbyfieldactive = true
|
|
1597
|
+
element.setAttribute('babiaxrBeforeBuildingHighlight', element.getAttribute("material")["color"])
|
|
1598
|
+
element.setAttribute("material", "color", self.data.highlightBuildingByFieldColor)
|
|
1599
|
+
}
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1022
1603
|
// Add to the elements that has the legend activated
|
|
1023
|
-
self.entitiesWithLegend.push({'figure': figure, 'entity': entity})
|
|
1604
|
+
self.entitiesWithLegend.push({ 'figure': figure, 'entity': entity })
|
|
1024
1605
|
self.legendsActive.push(entity.legend)
|
|
1025
1606
|
}
|
|
1026
1607
|
|
|
@@ -1029,7 +1610,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
1029
1610
|
entity.addEventListener('mouseenter', function () {
|
|
1030
1611
|
if (!entity.alreadyActive) {
|
|
1031
1612
|
entityGeometry = entity.getAttribute('geometry')
|
|
1032
|
-
let boxPosition = entity.getAttribute(
|
|
1613
|
+
let boxPosition = entity.getAttribute('position')
|
|
1033
1614
|
entity.setAttribute('position', boxPosition)
|
|
1034
1615
|
entity.setAttribute('babiaxrFirstColor', entity.getAttribute("material")["color"])
|
|
1035
1616
|
entity.setAttribute('material', {
|
|
@@ -1052,6 +1633,19 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
1052
1633
|
entity.legend.setAttribute('position', coordinatesFinal)
|
|
1053
1634
|
entity.legend.setAttribute('visible', true);
|
|
1054
1635
|
self.el.parentElement.appendChild(entity.legend);
|
|
1636
|
+
|
|
1637
|
+
// Hihglight by field
|
|
1638
|
+
if (self.data.highlightBuildingByField) {
|
|
1639
|
+
let fieldValue = entity.getAttribute("babia-highlightbuildingbyfield")
|
|
1640
|
+
let toHighlight = document.querySelectorAll(`[babia-highlightbuildingbyfield=${fieldValue}]`)
|
|
1641
|
+
toHighlight.forEach(element => {
|
|
1642
|
+
if (entity !== element && !element.highlightbuildingbyfieldactive && !element.alreadyActive) {
|
|
1643
|
+
element.highlightbuildingbyfieldactive = true
|
|
1644
|
+
element.setAttribute('babiaxrBeforeBuildingHighlight', element.getAttribute("material")["color"])
|
|
1645
|
+
element.setAttribute("material", "color", self.data.highlightBuildingByFieldColor)
|
|
1646
|
+
}
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1055
1649
|
}
|
|
1056
1650
|
|
|
1057
1651
|
});
|
|
@@ -1069,6 +1663,23 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
1069
1663
|
self.el.parentElement.removeChild(entity.legend)
|
|
1070
1664
|
entity.legend = undefined
|
|
1071
1665
|
}
|
|
1666
|
+
|
|
1667
|
+
// Remove Hihglight by field
|
|
1668
|
+
if (self.data.highlightBuildingByField) {
|
|
1669
|
+
if (!entity.alreadyActive && !entity.highlightbuildingbyfieldactive) {
|
|
1670
|
+
let fieldValue = entity.getAttribute("babia-highlightbuildingbyfield")
|
|
1671
|
+
let toRemoveHighlight = document.querySelectorAll(`[babia-highlightbuildingbyfield=${fieldValue}]`)
|
|
1672
|
+
toRemoveHighlight.forEach(element => {
|
|
1673
|
+
if (entity !== element) {
|
|
1674
|
+
if (element.highlightbuildingbyfieldactive && !element.alreadyActive) {
|
|
1675
|
+
let oldColor = element.getAttribute('babiaxrBeforeBuildingHighlight')
|
|
1676
|
+
element.setAttribute("material", "color", oldColor)
|
|
1677
|
+
element.highlightbuildingbyfieldactive = false
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1072
1683
|
});
|
|
1073
1684
|
}
|
|
1074
1685
|
},
|
|
@@ -1109,7 +1720,12 @@ let generateLegend = (name, legend_scale, lookat, colorPlane, colorText, data, f
|
|
|
1109
1720
|
}
|
|
1110
1721
|
|
|
1111
1722
|
if (fcolor) {
|
|
1112
|
-
let colorText = "\n " + fcolor
|
|
1723
|
+
let colorText = "\n " + fcolor
|
|
1724
|
+
if (typeof data[fcolor] === 'string') {
|
|
1725
|
+
colorText += " (color): " + data[fcolor]
|
|
1726
|
+
} else {
|
|
1727
|
+
colorText += " (color): " + Math.round(data[fcolor] * 100) / 100
|
|
1728
|
+
}
|
|
1113
1729
|
if (colorText.length > 16 && colorText > heightText)
|
|
1114
1730
|
width = colorText.length / 5;
|
|
1115
1731
|
name += colorText
|
|
@@ -1166,20 +1782,21 @@ let getLevels = (elements, levels) => {
|
|
|
1166
1782
|
return max_level;
|
|
1167
1783
|
}
|
|
1168
1784
|
|
|
1169
|
-
let
|
|
1785
|
+
let getMaxMinValues = (data, field, valuesToAvg, max, min) => {
|
|
1170
1786
|
for (let i = 0; i < data.length; i++) {
|
|
1171
1787
|
if (data[i].children) {
|
|
1172
|
-
[max, min] =
|
|
1788
|
+
[max, min] = getMaxMinValues(data[i].children, field, valuesToAvg, max, min)
|
|
1173
1789
|
} else {
|
|
1174
|
-
if (data[i][
|
|
1175
|
-
max = data[i][
|
|
1790
|
+
if (data[i][field] !== "null" && !max || data[i][field] > max) {
|
|
1791
|
+
max = data[i][field]
|
|
1176
1792
|
}
|
|
1177
|
-
if (data[i][
|
|
1178
|
-
min = data[i][
|
|
1793
|
+
if (data[i][field] !== "null" && !(min !== undefined) || data[i][field] < min) {
|
|
1794
|
+
min = data[i][field]
|
|
1179
1795
|
}
|
|
1796
|
+
valuesToAvg.push(data[i][field])
|
|
1180
1797
|
}
|
|
1181
1798
|
}
|
|
1182
|
-
return [max, min]
|
|
1799
|
+
return [max, min, valuesToAvg]
|
|
1183
1800
|
}
|
|
1184
1801
|
|
|
1185
1802
|
function heatMapColorforValue(val, max, min) {
|
|
@@ -1210,4 +1827,8 @@ let findIndex = (list, condicion) => {
|
|
|
1210
1827
|
}
|
|
1211
1828
|
}
|
|
1212
1829
|
return -1
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
let greenColorsurface = (perc) => {
|
|
1833
|
+
return "hsl(140, 100%," + perc + "%)"
|
|
1213
1834
|
}
|