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.
- package/components/filters/babia-selector.js +256 -79
- package/components/filters/babia-treebuilder.js +1 -2
- package/components/geometries/babia-bar.js +13 -1
- package/components/geometries/babia-cyl.js +189 -0
- package/components/others/assets/tooltip.png +0 -0
- package/components/others/babia-camera.js +195 -0
- package/components/others/babia-controls.js +56 -31
- package/components/others/babia-navigator.js +55 -49
- package/components/others/babia-range-selector.js +218 -0
- package/components/others/babia-slider.js +36 -8
- package/components/others/babia-ui.js +246 -73
- package/components/others/common.js +91 -83
- package/components/queriers/babia-querycsv.js +96 -0
- package/components/queriers/babia-queryes.js +209 -131
- package/components/visualizers/babia-bars.js +15 -38
- package/components/visualizers/babia-barsmap.js +19 -34
- package/components/visualizers/babia-boats.js +221 -134
- package/components/visualizers/babia-bubbles.js +13 -26
- package/components/visualizers/babia-cyls.js +203 -201
- package/components/visualizers/babia-cylsmap.js +173 -241
- package/components/visualizers/babia-doughnut.js +6 -28
- package/components/visualizers/babia-network.js +191 -124
- package/components/visualizers/babia-pie.js +6 -30
- package/dist/aframe-babia-components.js +21913 -19571
- package/dist/aframe-babia-components.min.js +7 -1
- package/dist/aframe-babia-components.min.js.map +1 -1
- package/docs/APIs/CHARTS.md +33 -14
- package/docs/APIs/DATAMANAGEMENT.md +7 -0
- package/docs/APIs/OTHERS.md +42 -0
- package/docs/APIs/QUERIERS.md +18 -0
- package/docs/RELEASE_NOTES.md +58 -21
- package/docs/Tutorials/multiuser.md +47 -2
- package/examples/assets/door/New Bitmap Image.jpg +0 -0
- package/examples/assets/door/door.mtl +26 -0
- package/examples/assets/door/door.obj +6927 -0
- package/examples/assets/popups/0.png +0 -0
- package/examples/assets/popups/1.png +0 -0
- package/examples/assets/popups/10.png +0 -0
- package/examples/assets/popups/2.png +0 -0
- package/examples/assets/popups/3.png +0 -0
- package/examples/assets/popups/4.png +0 -0
- package/examples/assets/popups/5.png +0 -0
- package/examples/assets/popups/6.png +0 -0
- package/examples/assets/popups/7.png +0 -0
- package/examples/assets/popups/8.png +0 -0
- package/examples/assets/popups/9.png +0 -0
- package/examples/assets/popups/close.jpg +0 -0
- package/examples/assets/popups/info.jpg +0 -0
- package/examples/assets/textures/brownwall.png +0 -0
- package/examples/assets/textures/concrete.png +0 -0
- package/examples/assets/textures/white-wall-texture.jpg +0 -0
- package/examples/charts/cyls/index.html +13 -4
- package/examples/charts/cyls/primitive.html +76 -0
- package/examples/charts/cylsmap/index.html +14 -5
- package/examples/charts_querier/bars_querier/data.csv +10 -0
- package/examples/charts_querier/bars_querier/index_csv.html +80 -0
- package/examples/charts_querier/multichart_querier/manual_colors.html +81 -0
- package/examples/dashboard/chaoss-dashboards.html +259 -0
- package/examples/dashboard/chaoss-issues.html +248 -0
- package/examples/dashboard/chaoss-pr.html +248 -0
- package/examples/dashboard/index.html +247 -0
- package/examples/dashboard/issues_queries/80-percent-open-time.json +123 -0
- package/examples/dashboard/issues_queries/issues-by-organization.json +107 -0
- package/examples/dashboard/issues_queries/issues.json +117 -0
- package/examples/dashboard/issues_queries/median-open-time.json +123 -0
- package/examples/dashboard/issues_queries/organizations.json +130 -0
- package/examples/dashboard/issues_queries/projects.json +130 -0
- package/examples/dashboard/issues_queries/repositories.json +130 -0
- package/examples/dashboard/issues_queries/status.json +107 -0
- package/examples/dashboard/issues_queries/submitter.json +125 -0
- package/examples/dashboard/issues_queries/submitters.json +113 -0
- package/examples/dashboard/pullrequests_queries/80-percent-open-time.json +123 -0
- package/examples/dashboard/pullrequests_queries/median-open-time.json +123 -0
- package/examples/dashboard/pullrequests_queries/organizations.json +130 -0
- package/examples/dashboard/pullrequests_queries/projects.json +130 -0
- package/examples/dashboard/pullrequests_queries/pull-requests-by-organization.json +107 -0
- package/examples/dashboard/pullrequests_queries/pull-requests.json +117 -0
- package/examples/dashboard/pullrequests_queries/repositories.json +130 -0
- package/examples/dashboard/pullrequests_queries/status.json +107 -0
- package/examples/dashboard/pullrequests_queries/submitter.json +125 -0
- package/examples/dashboard/pullrequests_queries/submitters.json +113 -0
- package/examples/dashboard/range.html +88 -0
- package/examples/dashboard/template.html +136 -0
- package/examples/demos/1.0.11/index_multiuser_ui.html +1 -1
- package/examples/multi_bars/data.json +14 -0
- package/examples/multi_bars/data2.json +15 -0
- package/examples/multi_bars/data3.json +23 -0
- package/examples/multi_bars/easyrtc.js +11984 -0
- package/examples/multi_bars/index.html +97 -0
- package/examples/multi_bars/index1.html +111 -0
- package/examples/multi_bars/index2.html +102 -0
- package/examples/multi_bars/index3.html +104 -0
- package/examples/multi_boats/data3.json +174 -0
- package/examples/multi_boats/data4.json +192 -0
- package/examples/multi_boats/{index.html → index_multi_boats.html} +50 -55
- package/examples/multi_boats/jetuml.html +124 -115
- package/examples/multi_boats/jetuml_evolution_experiment.html +419 -0
- package/examples/multi_boats/only_queryjson.html +132 -0
- package/examples/multi_boats/only_queryjson2.html +167 -0
- package/examples/multi_boats/only_queryjson3.html +165 -0
- package/examples/multi_boats/queryjson_treebuilder.html +132 -0
- package/examples/multi_boats/with_selector.html +121 -111
- package/examples/multiuser/choose_avatar/index.html +18 -8
- package/examples/selector_boats/jetuml_from_3_2_to_1_0.json +62382 -0
- package/examples/ui/network/data.json +123 -0
- package/examples/ui/network/links.json +13 -0
- package/examples/ui/network/network.html +75 -0
- package/examples/ui/network/network_nodes_links.html +82 -0
- package/examples/ui/network/nodes.json +12 -0
- package/index.html +69 -3
- package/index.js +6 -1
- package/package.json +4 -3
- package/tests/screenshots/other_snapshots.js/chaoss-issues.png +0 -0
- package/tests/screenshots/other_snapshots.js/chaoss-pr.png +0 -0
- package/tests/screenshots/other_snapshots.js/template.png +0 -0
- package/tests/ui.js +7 -0
- package/webpack.common.js +1 -1
- package/webpack.devnossl.js +16 -0
- package/.idea/vcs.xml +0 -6
- package/.idea/workspace.xml +0 -79
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
let findProdComponent = require('../others/common').findProdComponent;
|
|
2
1
|
let updateTitle = require('../others/common').updateTitle;
|
|
3
|
-
let parseJson = require('../others/common').parseJson;
|
|
4
2
|
const colors = require('../others/common').colors;
|
|
3
|
+
let updateFunction = require('../others/common').updateFunction;
|
|
5
4
|
|
|
6
5
|
const NotiBuffer = require("../../common/noti-buffer").NotiBuffer;
|
|
7
6
|
|
|
@@ -22,6 +21,8 @@ AFRAME.registerComponent('babia-bubbles', {
|
|
|
22
21
|
z_axis: { type: 'string', default: 'z_axis' },
|
|
23
22
|
from: { type: 'string' },
|
|
24
23
|
legend: { type: 'boolean' },
|
|
24
|
+
legend_lookat: { type: 'string', default: "[camera]" },
|
|
25
|
+
legend_scale: { type: 'number', default: 1 },
|
|
25
26
|
axis: { type: 'boolean', default: true },
|
|
26
27
|
// Name for axis
|
|
27
28
|
axis_name: {type: 'boolean', default: false},
|
|
@@ -46,36 +47,20 @@ AFRAME.registerComponent('babia-bubbles', {
|
|
|
46
47
|
*/
|
|
47
48
|
multiple: false,
|
|
48
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Called once when component is attached. Generally for initial setup.
|
|
52
|
+
*/
|
|
53
|
+
init: function () {
|
|
54
|
+
this.notiBuffer = new NotiBuffer();
|
|
55
|
+
},
|
|
56
|
+
|
|
49
57
|
/**
|
|
50
58
|
* Called when component is attached and when component data changes.
|
|
51
59
|
* Generally modifies the entity based on the data.
|
|
52
60
|
*/
|
|
53
61
|
|
|
54
62
|
update: function (oldData) {
|
|
55
|
-
|
|
56
|
-
let el = this.el;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Update or create chart component
|
|
60
|
-
*/
|
|
61
|
-
if (data.data && oldData.data !== data.data) {
|
|
62
|
-
let _data = parseJson(data.data);
|
|
63
|
-
this.processData(_data);
|
|
64
|
-
} else if (data.from !== oldData.from) {
|
|
65
|
-
// Unregister from old producer
|
|
66
|
-
if (this.prodComponent) {
|
|
67
|
-
this.prodComponent.notiBuffer.unregister(this.notiBufferId)
|
|
68
|
-
};
|
|
69
|
-
this.prodComponent = findProdComponent (data, el)
|
|
70
|
-
if (this.prodComponent.notiBuffer) {
|
|
71
|
-
this.notiBufferId = this.prodComponent.notiBuffer
|
|
72
|
-
.register(this.processData.bind(this))
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
// If changed whatever, re-print with the current data
|
|
76
|
-
else if (data !== oldData && this.newData) {
|
|
77
|
-
this.processData(this.newData)
|
|
78
|
-
}
|
|
63
|
+
updateFunction(this, oldData)
|
|
79
64
|
},
|
|
80
65
|
|
|
81
66
|
/**
|
|
@@ -341,6 +326,8 @@ function generateLegend(data, bubble, bubbleEntity) {
|
|
|
341
326
|
'color': 'black'
|
|
342
327
|
});
|
|
343
328
|
entity.classList.add("babiaxrLegend")
|
|
329
|
+
entity.setAttribute('babia-lookat', data.legend_lookat);
|
|
330
|
+
entity.setAttribute('scale',{x: data.legend_scale, y: data.legend_scale, z: data.legend_scale});
|
|
344
331
|
return entity;
|
|
345
332
|
}
|
|
346
333
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
let findProdComponent = require('../others/common').findProdComponent;
|
|
2
1
|
let updateTitle = require('../others/common').updateTitle;
|
|
3
|
-
let parseJson = require('../others/common').parseJson;
|
|
4
2
|
const colors = require('../others/common').colors;
|
|
3
|
+
let updateFunction = require('../others/common').updateFunction;
|
|
5
4
|
|
|
6
5
|
const NotiBuffer = require("../../common/noti-buffer").NotiBuffer;
|
|
7
6
|
|
|
@@ -20,19 +19,31 @@ AFRAME.registerComponent('babia-cyls', {
|
|
|
20
19
|
radius: { type: 'string', default: 'radius' },
|
|
21
20
|
x_axis: { type: 'string', default: 'x_axis' },
|
|
22
21
|
from: { type: 'string' },
|
|
23
|
-
legend: { type: 'boolean' },
|
|
22
|
+
legend: { type: 'boolean', default: false },
|
|
23
|
+
legend_lookat: { type: 'string', default: "[camera]" },
|
|
24
|
+
legend_scale: { type: 'number', default: 1 },
|
|
24
25
|
axis: { type: 'boolean', default: true },
|
|
25
26
|
// Name for axis
|
|
26
27
|
axis_name: {type: 'boolean', default: false},
|
|
27
|
-
animation: { type: 'boolean', default: false },
|
|
28
28
|
palette: { type: 'string', default: 'ubuntu' },
|
|
29
29
|
title: { type: 'string' },
|
|
30
30
|
titleFont: { type: 'string' },
|
|
31
31
|
titleColor: { type: 'string' },
|
|
32
|
-
titlePosition: { type: '
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
titlePosition: { type: 'vec3', default: {x: 0, y: 0, z: 0} },
|
|
33
|
+
// Height of the chart
|
|
34
|
+
chartHeight: { type: 'number', default: 10 },
|
|
35
|
+
// Maximun of the radius
|
|
36
|
+
radiusMax: { type: 'number', default: 2 },
|
|
37
|
+
// Keep height when updating data
|
|
38
|
+
keepHeight: { type: 'boolean', default: true},
|
|
39
|
+
incremental: { type: 'boolean', default: false},
|
|
40
|
+
index: { type: 'string' },
|
|
41
|
+
// Should this be animated
|
|
42
|
+
animation: { type: 'boolean', default: true},
|
|
43
|
+
// Duration of animations
|
|
44
|
+
dur: { type: 'number', default: 2000},
|
|
45
|
+
uiLink: {type: 'boolean', default: false},
|
|
46
|
+
uiLinkPosition: { type: 'vec3', default: {x: -4.5, y: 2, z: 2.5} },
|
|
36
47
|
},
|
|
37
48
|
|
|
38
49
|
/**
|
|
@@ -49,36 +60,25 @@ AFRAME.registerComponent('babia-cyls', {
|
|
|
49
60
|
*/
|
|
50
61
|
init: function () {
|
|
51
62
|
this.notiBuffer = new NotiBuffer();
|
|
63
|
+
|
|
64
|
+
// Build chartEl
|
|
65
|
+
this.chartEl = document.createElement('a-entity');
|
|
66
|
+
this.chartEl.classList.add('babiaxrChart')
|
|
67
|
+
this.el.appendChild(this.chartEl);
|
|
68
|
+
|
|
69
|
+
// Build titleEl
|
|
70
|
+
this.updateTitle()
|
|
71
|
+
this.el.appendChild(this.titleEl);
|
|
52
72
|
},
|
|
53
73
|
/**
|
|
54
74
|
* Called when component is attached and when component data changes.
|
|
55
75
|
* Generally modifies the entity based on the data.
|
|
56
76
|
*/
|
|
57
77
|
update: function (oldData) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
* Update or create chart component
|
|
63
|
-
*/
|
|
64
|
-
if (data.data && oldData.data !== data.data) {
|
|
65
|
-
let _data = parseJson(data.data);
|
|
66
|
-
this.processData(_data);
|
|
67
|
-
} else if (data.from !== oldData.from) {
|
|
68
|
-
// Unregister from old producer
|
|
69
|
-
if (this.prodComponent) {
|
|
70
|
-
this.prodComponent.notiBuffer.unregister(this.notiBufferId)
|
|
71
|
-
};
|
|
72
|
-
this.prodComponent = findProdComponent (data, el)
|
|
73
|
-
if (this.prodComponent.notiBuffer) {
|
|
74
|
-
this.notiBufferId = this.prodComponent.notiBuffer
|
|
75
|
-
.register(this.processData.bind(this))
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
// If changed whatever, re-print with the current data
|
|
79
|
-
else if (data !== oldData && this.newData) {
|
|
80
|
-
this.processData(this.newData)
|
|
81
|
-
}
|
|
78
|
+
updateFunction(this, oldData)
|
|
79
|
+
if (this.data.uiLink){
|
|
80
|
+
createUiLink(el, this.data.uiLinkPosition)
|
|
81
|
+
}
|
|
82
82
|
},
|
|
83
83
|
|
|
84
84
|
/**
|
|
@@ -96,6 +96,11 @@ AFRAME.registerComponent('babia-cyls', {
|
|
|
96
96
|
*/
|
|
97
97
|
newData: undefined,
|
|
98
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Where the previous state data is gonna be stored
|
|
101
|
+
*/
|
|
102
|
+
currentData: undefined,
|
|
103
|
+
|
|
99
104
|
/**
|
|
100
105
|
* Where the metadata is gonna be stored
|
|
101
106
|
*/
|
|
@@ -103,136 +108,150 @@ AFRAME.registerComponent('babia-cyls', {
|
|
|
103
108
|
id: 0
|
|
104
109
|
},
|
|
105
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Value max
|
|
113
|
+
*/
|
|
114
|
+
valueMax: undefined,
|
|
115
|
+
|
|
116
|
+
xLabels: [],
|
|
117
|
+
xTicks: [],
|
|
118
|
+
|
|
106
119
|
/*
|
|
107
120
|
* Update title
|
|
108
121
|
*/
|
|
109
122
|
updateTitle: function(){
|
|
110
123
|
const titleRotation = { x: 0, y: 0, z: 0 }
|
|
111
|
-
|
|
112
|
-
this.el.appendChild(titleEl);
|
|
124
|
+
this.titleEl = updateTitle(this.data, titleRotation);
|
|
113
125
|
},
|
|
114
126
|
|
|
115
127
|
/*
|
|
116
128
|
* Update chart
|
|
117
129
|
*/
|
|
118
130
|
updateChart: function () {
|
|
119
|
-
|
|
131
|
+
let dataToPrint = this.newData;
|
|
132
|
+
|
|
133
|
+
if (this.currentData) {
|
|
134
|
+
dataToPrint = this.currentData;
|
|
135
|
+
} else {
|
|
136
|
+
dataToPrint = this.newData;
|
|
137
|
+
}
|
|
120
138
|
console.log("Data babia-cyls:", dataToPrint)
|
|
121
139
|
|
|
122
140
|
const data = this.data;
|
|
123
|
-
const el = this.el;
|
|
141
|
+
const el = this.el;
|
|
124
142
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
143
|
+
//Print Title
|
|
144
|
+
this.updateTitle();
|
|
145
|
+
|
|
146
|
+
// Height Chart
|
|
147
|
+
let valueMax = Math.max.apply(Math, dataToPrint.map(function (o) { return o[data.height]; }))
|
|
148
|
+
if (!this.lengthY) {
|
|
149
|
+
this.lengthY = data.chartHeight;
|
|
150
|
+
} else if (!data.keepHeight) {
|
|
151
|
+
this.lengthY = this.lengthY * maxValue / this.maxValue;
|
|
152
|
+
};
|
|
153
|
+
this.maxValue = valueMax;
|
|
154
|
+
|
|
155
|
+
// Proportion of the radius
|
|
156
|
+
let maxRadius = Math.max.apply(Math, dataToPrint.map(function (o) { return o[data.radius]; }))
|
|
157
|
+
this.radius_scale = data.radiusMax / maxRadius;
|
|
158
|
+
|
|
159
|
+
// List current cylinders
|
|
160
|
+
let chartEl = this.chartEl;
|
|
161
|
+
let cyls = chartEl.querySelectorAll('a-entity[babia-cyl]');
|
|
162
|
+
let currentCyls = {};
|
|
163
|
+
for (let cyl of cyls) {
|
|
164
|
+
let cylName = cyl.getAttribute('babia-name');
|
|
165
|
+
currentCyls[cylName] = {'el': cyl, 'found': false};
|
|
166
|
+
};
|
|
128
167
|
|
|
129
|
-
let heightMax = data.heightMax
|
|
130
|
-
let radiusMax = data.radiusMax
|
|
131
|
-
|
|
132
168
|
let xLabels = [];
|
|
133
169
|
let xTicks = [];
|
|
134
170
|
let colorId = 0
|
|
135
|
-
|
|
136
|
-
let
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
if (!heightMax){
|
|
147
|
-
heightMax = valueMax
|
|
148
|
-
}
|
|
149
|
-
proportion = heightMax / valueMax
|
|
150
|
-
|
|
151
|
-
if (!radiusMax){
|
|
152
|
-
radiusMax = maxRadius
|
|
153
|
-
}
|
|
154
|
-
radius_scale = radiusMax / maxRadius
|
|
155
|
-
|
|
156
|
-
this.chartEl = document.createElement('a-entity');
|
|
157
|
-
this.chartEl.classList.add('babiaxrChart')
|
|
158
|
-
el.appendChild(this.chartEl)
|
|
159
|
-
|
|
160
|
-
for (let cylinder of dataToPrint) {
|
|
161
|
-
let xLabel = cylinder[data.x_axis]
|
|
162
|
-
let radius = cylinder[data.radius]
|
|
163
|
-
let height = cylinder[data.height]
|
|
164
|
-
|
|
165
|
-
if (cylinder !== dataToPrint[0]) {
|
|
166
|
-
//Calculate stepX
|
|
167
|
-
if (scale) {
|
|
168
|
-
stepX += lastradius + radius / scale + 0.5
|
|
169
|
-
} else{
|
|
170
|
-
stepX += lastradius + radius * radius_scale + 0.5
|
|
171
|
-
}
|
|
172
|
-
|
|
171
|
+
|
|
172
|
+
let last_radius; // Needed to calculate separation between cyls
|
|
173
|
+
// Add or modify cyls for new data
|
|
174
|
+
for (let i = 0; i < dataToPrint.length; i++) {
|
|
175
|
+
let item = dataToPrint[i]
|
|
176
|
+
|
|
177
|
+
let xLabel = item[data.x_axis];
|
|
178
|
+
let posX;
|
|
179
|
+
if (i == 0){
|
|
180
|
+
posX = 0.5 + item[data.radius] * this.radius_scale;
|
|
173
181
|
} else {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
let cylinderEntity = generateCylinder(height, radius, colorId, palette, stepX, animation, scale, proportion, radius_scale)
|
|
182
|
-
cylinderEntity.classList.add("babiaxraycasterclass")
|
|
183
|
-
this.chartEl.appendChild(cylinderEntity);
|
|
184
|
-
|
|
185
|
-
//Prepare legend
|
|
186
|
-
if (data.legend) {
|
|
187
|
-
showLegend(data, cylinderEntity, cylinder, el, maxRadius)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// update lastradius
|
|
191
|
-
if (!scale && !radius_scale) {
|
|
192
|
-
lastradius = radius
|
|
182
|
+
posX = xTicks[i-1] + last_radius + 0.5 + item[data.radius] * this.radius_scale;
|
|
183
|
+
}
|
|
184
|
+
let cylEl;
|
|
185
|
+
if ( currentCyls[xLabel] && !item['_not'] ) {
|
|
186
|
+
cylEl = currentCyls[xLabel].el;
|
|
187
|
+
currentCyls[xLabel].found = true;
|
|
193
188
|
} else {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
189
|
+
cylEl = document.createElement('a-entity');
|
|
190
|
+
cylEl.setAttribute('babia-name', xLabel);
|
|
191
|
+
cylEl.id = item[data.index];
|
|
192
|
+
cylEl.object3D.position.x = posX;
|
|
193
|
+
this.chartEl.appendChild(cylEl);
|
|
199
194
|
}
|
|
195
|
+
|
|
196
|
+
createCylinder(this, cylEl, data, item, colorId, xLabel, posX, 0);
|
|
200
197
|
|
|
201
|
-
xLabels.push(xLabel)
|
|
202
|
-
xTicks.push(
|
|
198
|
+
xLabels.push(xLabel);
|
|
199
|
+
xTicks.push(posX);
|
|
203
200
|
|
|
204
201
|
//Increase color id
|
|
205
202
|
colorId++
|
|
203
|
+
|
|
204
|
+
last_radius = item[data.radius] * this.radius_scale;
|
|
206
205
|
}
|
|
206
|
+
|
|
207
|
+
// Remove old cyls (not in new data)
|
|
208
|
+
for (let name in currentCyls) {
|
|
209
|
+
if ( !currentCyls[name].found ) {
|
|
210
|
+
currentCyls[name].el.remove();
|
|
211
|
+
};
|
|
212
|
+
};
|
|
207
213
|
|
|
208
214
|
//Print axis
|
|
209
215
|
if (data.axis) {
|
|
210
|
-
const lengthX =
|
|
211
|
-
|
|
212
|
-
this.updateAxis(xLabels, xTicks, lengthX, firstradius, maxRadius, valueMax, lengthY);
|
|
216
|
+
const lengthX = xTicks[xTicks.length-1] + (dataToPrint[0][data.radius]+ dataToPrint[dataToPrint.length-1][data.radius])* this.radius_scale / 2 ;
|
|
217
|
+
this.updateAxis(xLabels, xTicks, lengthX, this.maxValue);
|
|
213
218
|
}
|
|
214
|
-
|
|
215
|
-
//Print Title
|
|
216
|
-
this.updateTitle();
|
|
217
219
|
},
|
|
218
220
|
|
|
219
221
|
/*
|
|
220
222
|
* Update axis
|
|
221
223
|
*/
|
|
222
|
-
updateAxis: function
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
224
|
+
updateAxis: function(labels, ticks, lengthX, maxValue) {
|
|
225
|
+
const data = this.data;
|
|
226
|
+
if (data.axis) {
|
|
227
|
+
if (!this.xAxisEl) {
|
|
228
|
+
this.xAxisEl = document.createElement('a-entity');
|
|
229
|
+
this.chartEl.appendChild(this.xAxisEl);
|
|
230
|
+
};
|
|
231
|
+
this.xAxisEl.setAttribute('babia-axis-x',
|
|
232
|
+
{'labels': labels, 'ticks': ticks, 'length': lengthX,
|
|
233
|
+
'palette': data.palette});
|
|
234
|
+
this.xAxisEl.setAttribute('position', {
|
|
235
|
+
x: 0, y: 0, z: data.radiusMax + 0.25
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
if (!this.yAxisEl) {
|
|
239
|
+
this.yAxisEl = document.createElement('a-entity');
|
|
240
|
+
this.chartEl.appendChild(this.yAxisEl);
|
|
241
|
+
};
|
|
242
|
+
this.yAxisEl.setAttribute('babia-axis-y',
|
|
243
|
+
{'maxValue': maxValue, 'length': this.lengthY});
|
|
244
|
+
this.yAxisEl.setAttribute('position', {
|
|
245
|
+
x: 0, y: 0, z: data.radiusMax + 0.25
|
|
246
|
+
});
|
|
247
|
+
if (data.axis_name){
|
|
248
|
+
if (data.index) {
|
|
249
|
+
this.xAxisEl.setAttribute('babia-axis-x', 'name', data.index);
|
|
250
|
+
} else {
|
|
251
|
+
this.xAxisEl.setAttribute('babia-axis-x', 'name', data.x_axis);
|
|
252
|
+
}
|
|
253
|
+
this.yAxisEl.setAttribute('babia-axis-y', 'name', data.height);
|
|
254
|
+
}
|
|
236
255
|
}
|
|
237
256
|
},
|
|
238
257
|
|
|
@@ -243,92 +262,75 @@ AFRAME.registerComponent('babia-cyls', {
|
|
|
243
262
|
console.log("processData", this);
|
|
244
263
|
this.newData = data;
|
|
245
264
|
this.babiaMetadata = { id: this.babiaMetadata.id++ };
|
|
246
|
-
while (this.el.firstChild)
|
|
247
|
-
this.el.firstChild.remove()
|
|
265
|
+
/*while (this.el.firstChild)
|
|
266
|
+
this.el.firstChild.remove();*/
|
|
248
267
|
console.log("Generating cyls...")
|
|
249
268
|
this.updateChart()
|
|
250
269
|
this.notiBuffer.set(this.newData)
|
|
251
270
|
}
|
|
252
271
|
})
|
|
253
272
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
entity.setAttribute('height', 0);
|
|
270
|
-
entity.setAttribute('radius', radius);
|
|
271
|
-
// Add animation
|
|
272
|
-
if (animation) {
|
|
273
|
-
var duration = 4000
|
|
274
|
-
var increment = 20 * height / duration
|
|
275
|
-
var size = 0
|
|
276
|
-
var id = setInterval(animation, 1);
|
|
277
|
-
function animation() {
|
|
278
|
-
if (size >= height) {
|
|
279
|
-
clearInterval(id);
|
|
273
|
+
let createCylinder = (self, cylEl, data, item, colorId, xLabel, posX, posZ, zLabel) => {
|
|
274
|
+
cylEl.setAttribute('babia-cyl', {
|
|
275
|
+
'height': item[data.height] * self.lengthY / self.maxValue,
|
|
276
|
+
'radius': item[data.radius] * self.radius_scale,
|
|
277
|
+
'color': colors.get(colorId, data.palette),
|
|
278
|
+
'label': 'events',
|
|
279
|
+
'animation': data.animation
|
|
280
|
+
});
|
|
281
|
+
if (data.legend) {
|
|
282
|
+
if (!zLabel){
|
|
283
|
+
cylEl.setAttribute('babia-cyl', {
|
|
284
|
+
'labelText': xLabel + '\nHeight: ' + item[data.height] + '\nRadius: ' + item[data.radius],
|
|
285
|
+
'labelLookat': data.legend_lookat,
|
|
286
|
+
'labelScale': data.legend_scale
|
|
287
|
+
});
|
|
280
288
|
} else {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
289
|
+
cylEl.setAttribute('babia-cyl', {
|
|
290
|
+
'labelText': xLabel + ' | ' + zLabel + '\nHeight: ' + item[data.height] + '\nRadius: ' + item[data.radius],
|
|
291
|
+
'labelLookat': data.legend_lookat,
|
|
292
|
+
'labelScale': data.legend_scale
|
|
293
|
+
});
|
|
284
294
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
295
|
+
};
|
|
296
|
+
if (posX !== cylEl.object3D.position.x) {
|
|
297
|
+
if (data.animation) {
|
|
298
|
+
cylEl.setAttribute('animation', {
|
|
299
|
+
'property': 'object3D.position.x',
|
|
300
|
+
'to': posX,
|
|
301
|
+
'dur': data.dur
|
|
302
|
+
});
|
|
303
|
+
} else {
|
|
304
|
+
cylEl.object3D.position.x = posX;
|
|
305
|
+
};
|
|
289
306
|
}
|
|
290
|
-
|
|
307
|
+
if (posZ !== cylEl.object3D.position.z) {
|
|
308
|
+
if (data.animation) {
|
|
309
|
+
cylEl.setAttribute('animation', {
|
|
310
|
+
'property': 'object3D.position.z',
|
|
311
|
+
'to': posZ,
|
|
312
|
+
'dur': data.dur
|
|
313
|
+
});
|
|
314
|
+
} else {
|
|
315
|
+
cylEl.object3D.position.z = posZ;
|
|
316
|
+
};
|
|
291
317
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
function showLegend(data, cylinderEntity, cylinder, el, maxRadius) {
|
|
295
|
-
cylinderEntity.addEventListener('mouseenter', function () {
|
|
296
|
-
this.setAttribute('scale', { x: 1.1, y: 1.1, z: 1.1 });
|
|
297
|
-
legend = generateLegend(data, cylinder, cylinderEntity, maxRadius);
|
|
298
|
-
el.appendChild(legend);
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
cylinderEntity.addEventListener('mouseleave', function () {
|
|
302
|
-
this.setAttribute('scale', { x: 1, y: 1, z: 1 });
|
|
303
|
-
el.removeChild(legend);
|
|
304
|
-
});
|
|
318
|
+
|
|
305
319
|
}
|
|
306
320
|
|
|
307
|
-
|
|
308
|
-
let
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
entity.setAttribute('height', '1.5');
|
|
321
|
-
entity.setAttribute('width', width);
|
|
322
|
-
entity.setAttribute('color', 'white');
|
|
323
|
-
entity.setAttribute('text', {
|
|
324
|
-
'value': cylinder[data.x_axis] + ': ' + cylinder[data.height],
|
|
325
|
-
'align': 'center',
|
|
326
|
-
'width': 20,
|
|
327
|
-
'color': 'black'
|
|
328
|
-
});
|
|
329
|
-
entity.classList.add("babiaxrLegend")
|
|
330
|
-
return entity;
|
|
321
|
+
let createUiLink = (el, position) => {
|
|
322
|
+
let ui_link = document.createElement('a-entity');
|
|
323
|
+
if (!el.id){
|
|
324
|
+
// Generate id
|
|
325
|
+
let id = 'bars' + Math.floor(Math.random() * 1000);
|
|
326
|
+
el.id = id
|
|
327
|
+
}
|
|
328
|
+
console.log('id:', el.id)
|
|
329
|
+
ui_link.setAttribute('babia-ui-link', {viz: el.id})
|
|
330
|
+
ui_link.setAttribute('position', {x: position.x, y: position.y, z:position.z})
|
|
331
|
+
el.appendChild(ui_link)
|
|
332
|
+
console.log('Create Button', el)
|
|
333
|
+
return
|
|
331
334
|
}
|
|
332
335
|
|
|
333
|
-
|
|
334
|
-
|
|
336
|
+
module.exports.createCylinder = createCylinder;
|