aframe-babia-components 1.2.0 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/filters/babia-selector.js +256 -79
- package/components/filters/babia-treebuilder.js +4 -5
- package/components/geometries/babia-cyl.js +180 -0
- package/components/others/assets/tooltip.png +0 -0
- package/components/others/babia-camera.js +195 -0
- package/components/others/babia-controls.js +62 -37
- package/components/others/babia-navigator.js +55 -49
- package/components/others/babia-range-selector.js +208 -0
- package/components/others/babia-slider.js +36 -8
- package/components/others/babia-ui.js +246 -73
- package/components/others/common.js +60 -73
- package/components/queriers/babia-querycsv.js +96 -0
- package/components/queriers/babia-queryes.js +203 -132
- package/components/visualizers/babia-bars.js +4 -35
- package/components/visualizers/babia-barsmap.js +2 -30
- package/components/visualizers/babia-boats.js +291 -279
- package/components/visualizers/babia-bubbles.js +9 -26
- package/components/visualizers/babia-city.js +19 -9
- package/components/visualizers/babia-cyls.js +197 -201
- package/components/visualizers/babia-cylsmap.js +171 -241
- package/components/visualizers/babia-doughnut.js +2 -28
- package/components/visualizers/babia-network.js +191 -124
- package/components/visualizers/babia-pie.js +2 -30
- package/dist/aframe-babia-components.js +6785 -5626
- package/dist/aframe-babia-components.min.js +7 -1
- package/dist/aframe-babia-components.min.js.map +1 -0
- package/docs/APIs/CHARTS.md +11 -4
- package/docs/APIs/DATAMANAGEMENT.md +7 -0
- package/docs/APIs/OTHERS.md +27 -0
- package/docs/APIs/QUERIERS.md +16 -0
- package/docs/RELEASE_NOTES.md +44 -23
- package/docs/Tutorials/multiuser.md +47 -2
- package/docs/Tutorials/temporal_evol_with_boats.md +4 -4
- 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/boats/boats_new_element/data1.json +18 -18
- package/examples/boats/boats_new_element/data2.json +19 -19
- package/examples/boats/boats_new_element/index.html +1 -1
- 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/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/easyrtc.js +11984 -0
- package/examples/multi_boats/index_multi_boats.html +223 -0
- package/examples/multi_boats/jetuml.html +256 -0
- package/examples/multi_boats/jetuml_code_data.json +1 -0
- 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 +255 -0
- package/examples/multiuser/choose_avatar/index.html +18 -8
- package/examples/selector_boats/jetuml.html +74 -0
- package/examples/selector_boats/jetuml_evol_data.json +1 -0
- package/examples/selector_boats/jetuml_from_3_2_to_1_0.json +62382 -0
- package/examples/selector_boats/jetumltest.html +80 -0
- package/examples/ui/link/index.html +12 -11
- 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 +73 -2
- package/index.js +12 -1
- package/package.json +6 -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 +10 -1
- package/webpack.devnossl.js +16 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
let findProdComponent = require('../others/common').findProdComponent;
|
|
2
1
|
let updateTitle = require('../others/common').updateTitle;
|
|
3
|
-
let parseJson = require('../others/common').parseJson;
|
|
4
2
|
const colors = require('../others/common').colors;
|
|
3
|
+
let updateFunction = require('../others/common').updateFunction;
|
|
5
4
|
|
|
6
5
|
const NotiBuffer = require("../../common/noti-buffer").NotiBuffer;
|
|
7
6
|
|
|
@@ -46,36 +45,20 @@ AFRAME.registerComponent('babia-bubbles', {
|
|
|
46
45
|
*/
|
|
47
46
|
multiple: false,
|
|
48
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Called once when component is attached. Generally for initial setup.
|
|
50
|
+
*/
|
|
51
|
+
init: function () {
|
|
52
|
+
this.notiBuffer = new NotiBuffer();
|
|
53
|
+
},
|
|
54
|
+
|
|
49
55
|
/**
|
|
50
56
|
* Called when component is attached and when component data changes.
|
|
51
57
|
* Generally modifies the entity based on the data.
|
|
52
58
|
*/
|
|
53
59
|
|
|
54
60
|
update: function (oldData) {
|
|
55
|
-
|
|
56
|
-
let el = this.el;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Update or create chart component
|
|
60
|
-
*/
|
|
61
|
-
if (data.data && oldData.data !== data.data) {
|
|
62
|
-
let _data = parseJson(data.data);
|
|
63
|
-
this.processData(_data);
|
|
64
|
-
} else if (data.from !== oldData.from) {
|
|
65
|
-
// Unregister from old producer
|
|
66
|
-
if (this.prodComponent) {
|
|
67
|
-
this.prodComponent.notiBuffer.unregister(this.notiBufferId)
|
|
68
|
-
};
|
|
69
|
-
this.prodComponent = findProdComponent (data, el)
|
|
70
|
-
if (this.prodComponent.notiBuffer) {
|
|
71
|
-
this.notiBufferId = this.prodComponent.notiBuffer
|
|
72
|
-
.register(this.processData.bind(this))
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
// If changed whatever, re-print with the current data
|
|
76
|
-
else if (data !== oldData && this.newData) {
|
|
77
|
-
this.processData(this.newData)
|
|
78
|
-
}
|
|
61
|
+
updateFunction(this, oldData)
|
|
79
62
|
},
|
|
80
63
|
|
|
81
64
|
/**
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
let findProdComponent = require('../others/common').findProdComponent;
|
|
2
2
|
|
|
3
|
+
const NotiBuffer = require("../../common/noti-buffer").NotiBuffer;
|
|
4
|
+
|
|
3
5
|
/* global AFRAME */
|
|
4
6
|
if (typeof AFRAME === 'undefined') {
|
|
5
7
|
throw new Error('Component attempted to register before AFRAME was available.');
|
|
@@ -143,7 +145,12 @@ AFRAME.registerComponent('babia-city', {
|
|
|
143
145
|
* Set if component needs multiple instancing.
|
|
144
146
|
*/
|
|
145
147
|
multiple: false,
|
|
146
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Called once when component is attached. Generally for initial setup.
|
|
150
|
+
*/
|
|
151
|
+
init: function () {
|
|
152
|
+
this.notiBuffer = new NotiBuffer();
|
|
153
|
+
},
|
|
147
154
|
/**
|
|
148
155
|
* Called when component is attached and when component data changes.
|
|
149
156
|
* Generally modifies the entity based on the data.
|
|
@@ -169,14 +176,14 @@ AFRAME.registerComponent('babia-city', {
|
|
|
169
176
|
this.notiBufferId = this.prodComponent.notiBuffer
|
|
170
177
|
.register(this.processData.bind(this))
|
|
171
178
|
}
|
|
172
|
-
|
|
173
|
-
// If changed whatever, re-print with the current data
|
|
174
|
-
if (data !== oldData && this.newData) {
|
|
175
|
-
console.log("Generating city...")
|
|
176
|
-
this.processData(this.newData)
|
|
177
|
-
}
|
|
178
179
|
}
|
|
179
|
-
|
|
180
|
+
// If changed whatever, re-print with the current data
|
|
181
|
+
else if (data !== oldData && this.newData) {
|
|
182
|
+
console.log("Generating city...")
|
|
183
|
+
while (this.el.firstChild)
|
|
184
|
+
this.el.firstChild.remove();
|
|
185
|
+
this.processData(this.newData)
|
|
186
|
+
}
|
|
180
187
|
},
|
|
181
188
|
|
|
182
189
|
/**
|
|
@@ -216,7 +223,7 @@ AFRAME.registerComponent('babia-city', {
|
|
|
216
223
|
* Process data obtained from producer
|
|
217
224
|
*/
|
|
218
225
|
processData: function (_data) {
|
|
219
|
-
console.log("processData",
|
|
226
|
+
console.log("processData", _data);
|
|
220
227
|
this.newData = _data;
|
|
221
228
|
this.babiaMetadata = { id: this.babiaMetadata.id++ };
|
|
222
229
|
|
|
@@ -231,8 +238,11 @@ AFRAME.registerComponent('babia-city', {
|
|
|
231
238
|
} else {
|
|
232
239
|
toSave = this.newData
|
|
233
240
|
}
|
|
241
|
+
console.log("toSave", toSave);
|
|
242
|
+
this.notiBuffer.set(toSave)
|
|
234
243
|
// Create city
|
|
235
244
|
generateCity(this, toSave)
|
|
245
|
+
|
|
236
246
|
},
|
|
237
247
|
|
|
238
248
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
let findProdComponent = require('../others/common').findProdComponent;
|
|
2
1
|
let updateTitle = require('../others/common').updateTitle;
|
|
3
|
-
let parseJson = require('../others/common').parseJson;
|
|
4
2
|
const colors = require('../others/common').colors;
|
|
3
|
+
let updateFunction = require('../others/common').updateFunction;
|
|
5
4
|
|
|
6
5
|
const NotiBuffer = require("../../common/noti-buffer").NotiBuffer;
|
|
7
6
|
|
|
@@ -20,19 +19,29 @@ AFRAME.registerComponent('babia-cyls', {
|
|
|
20
19
|
radius: { type: 'string', default: 'radius' },
|
|
21
20
|
x_axis: { type: 'string', default: 'x_axis' },
|
|
22
21
|
from: { type: 'string' },
|
|
23
|
-
legend: { type: 'boolean' },
|
|
22
|
+
legend: { type: 'boolean', default: false },
|
|
24
23
|
axis: { type: 'boolean', default: true },
|
|
25
24
|
// Name for axis
|
|
26
25
|
axis_name: {type: 'boolean', default: false},
|
|
27
|
-
animation: { type: 'boolean', default: false },
|
|
28
26
|
palette: { type: 'string', default: 'ubuntu' },
|
|
29
27
|
title: { type: 'string' },
|
|
30
28
|
titleFont: { type: 'string' },
|
|
31
29
|
titleColor: { type: 'string' },
|
|
32
|
-
titlePosition: { type: '
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
titlePosition: { type: 'vec3', default: {x: 0, y: 0, z: 0} },
|
|
31
|
+
// Height of the chart
|
|
32
|
+
chartHeight: { type: 'number', default: 10 },
|
|
33
|
+
// Maximun of the radius
|
|
34
|
+
radiusMax: { type: 'number', default: 2 },
|
|
35
|
+
// Keep height when updating data
|
|
36
|
+
keepHeight: { type: 'boolean', default: true},
|
|
37
|
+
incremental: { type: 'boolean', default: false},
|
|
38
|
+
index: { type: 'string' },
|
|
39
|
+
// Should this be animated
|
|
40
|
+
animation: { type: 'boolean', default: true},
|
|
41
|
+
// Duration of animations
|
|
42
|
+
dur: { type: 'number', default: 2000},
|
|
43
|
+
uiLink: {type: 'boolean', default: false},
|
|
44
|
+
uiLinkPosition: { type: 'vec3', default: {x: -4.5, y: 2, z: 2.5} },
|
|
36
45
|
},
|
|
37
46
|
|
|
38
47
|
/**
|
|
@@ -49,36 +58,25 @@ AFRAME.registerComponent('babia-cyls', {
|
|
|
49
58
|
*/
|
|
50
59
|
init: function () {
|
|
51
60
|
this.notiBuffer = new NotiBuffer();
|
|
61
|
+
|
|
62
|
+
// Build chartEl
|
|
63
|
+
this.chartEl = document.createElement('a-entity');
|
|
64
|
+
this.chartEl.classList.add('babiaxrChart')
|
|
65
|
+
this.el.appendChild(this.chartEl);
|
|
66
|
+
|
|
67
|
+
// Build titleEl
|
|
68
|
+
this.updateTitle()
|
|
69
|
+
this.el.appendChild(this.titleEl);
|
|
52
70
|
},
|
|
53
71
|
/**
|
|
54
72
|
* Called when component is attached and when component data changes.
|
|
55
73
|
* Generally modifies the entity based on the data.
|
|
56
74
|
*/
|
|
57
75
|
update: function (oldData) {
|
|
58
|
-
|
|
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
|
-
}
|
|
76
|
+
updateFunction(this, oldData)
|
|
77
|
+
if (this.data.uiLink){
|
|
78
|
+
createUiLink(el, this.data.uiLinkPosition)
|
|
79
|
+
}
|
|
82
80
|
},
|
|
83
81
|
|
|
84
82
|
/**
|
|
@@ -96,6 +94,11 @@ AFRAME.registerComponent('babia-cyls', {
|
|
|
96
94
|
*/
|
|
97
95
|
newData: undefined,
|
|
98
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Where the previous state data is gonna be stored
|
|
99
|
+
*/
|
|
100
|
+
currentData: undefined,
|
|
101
|
+
|
|
99
102
|
/**
|
|
100
103
|
* Where the metadata is gonna be stored
|
|
101
104
|
*/
|
|
@@ -103,136 +106,150 @@ AFRAME.registerComponent('babia-cyls', {
|
|
|
103
106
|
id: 0
|
|
104
107
|
},
|
|
105
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Value max
|
|
111
|
+
*/
|
|
112
|
+
valueMax: undefined,
|
|
113
|
+
|
|
114
|
+
xLabels: [],
|
|
115
|
+
xTicks: [],
|
|
116
|
+
|
|
106
117
|
/*
|
|
107
118
|
* Update title
|
|
108
119
|
*/
|
|
109
120
|
updateTitle: function(){
|
|
110
121
|
const titleRotation = { x: 0, y: 0, z: 0 }
|
|
111
|
-
|
|
112
|
-
this.el.appendChild(titleEl);
|
|
122
|
+
this.titleEl = updateTitle(this.data, titleRotation);
|
|
113
123
|
},
|
|
114
124
|
|
|
115
125
|
/*
|
|
116
126
|
* Update chart
|
|
117
127
|
*/
|
|
118
128
|
updateChart: function () {
|
|
119
|
-
|
|
129
|
+
let dataToPrint = this.newData;
|
|
130
|
+
|
|
131
|
+
if (this.currentData) {
|
|
132
|
+
dataToPrint = this.currentData;
|
|
133
|
+
} else {
|
|
134
|
+
dataToPrint = this.newData;
|
|
135
|
+
}
|
|
120
136
|
console.log("Data babia-cyls:", dataToPrint)
|
|
121
137
|
|
|
122
138
|
const data = this.data;
|
|
123
|
-
const el = this.el;
|
|
139
|
+
const el = this.el;
|
|
124
140
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
141
|
+
//Print Title
|
|
142
|
+
this.updateTitle();
|
|
143
|
+
|
|
144
|
+
// Height Chart
|
|
145
|
+
let valueMax = Math.max.apply(Math, dataToPrint.map(function (o) { return o[data.height]; }))
|
|
146
|
+
if (!this.lengthY) {
|
|
147
|
+
this.lengthY = data.chartHeight;
|
|
148
|
+
} else if (!data.keepHeight) {
|
|
149
|
+
this.lengthY = this.lengthY * maxValue / this.maxValue;
|
|
150
|
+
};
|
|
151
|
+
this.maxValue = valueMax;
|
|
152
|
+
|
|
153
|
+
// Proportion of the radius
|
|
154
|
+
let maxRadius = Math.max.apply(Math, dataToPrint.map(function (o) { return o[data.radius]; }))
|
|
155
|
+
this.radius_scale = data.radiusMax / maxRadius;
|
|
156
|
+
|
|
157
|
+
// List current cylinders
|
|
158
|
+
let chartEl = this.chartEl;
|
|
159
|
+
let cyls = chartEl.querySelectorAll('a-entity[babia-cyl]');
|
|
160
|
+
let currentCyls = {};
|
|
161
|
+
for (let cyl of cyls) {
|
|
162
|
+
let cylName = cyl.getAttribute('babia-name');
|
|
163
|
+
currentCyls[cylName] = {'el': cyl, 'found': false};
|
|
164
|
+
};
|
|
128
165
|
|
|
129
|
-
let heightMax = data.heightMax
|
|
130
|
-
let radiusMax = data.radiusMax
|
|
131
|
-
|
|
132
166
|
let xLabels = [];
|
|
133
167
|
let xTicks = [];
|
|
134
168
|
let colorId = 0
|
|
135
|
-
|
|
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
|
-
|
|
169
|
+
|
|
170
|
+
let last_radius; // Needed to calculate separation between cyls
|
|
171
|
+
// Add or modify cyls for new data
|
|
172
|
+
for (let i = 0; i < dataToPrint.length; i++) {
|
|
173
|
+
let item = dataToPrint[i]
|
|
174
|
+
|
|
175
|
+
let xLabel = item[data.x_axis];
|
|
176
|
+
let posX;
|
|
177
|
+
if (i == 0){
|
|
178
|
+
posX = 0.5 + item[data.radius] * this.radius_scale;
|
|
173
179
|
} else {
|
|
174
|
-
|
|
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
|
|
180
|
+
posX = xTicks[i-1] + last_radius + 0.5 + item[data.radius] * this.radius_scale;
|
|
181
|
+
}
|
|
182
|
+
let cylEl;
|
|
183
|
+
if ( currentCyls[xLabel] && !item['_not'] ) {
|
|
184
|
+
cylEl = currentCyls[xLabel].el;
|
|
185
|
+
currentCyls[xLabel].found = true;
|
|
193
186
|
} else {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
187
|
+
cylEl = document.createElement('a-entity');
|
|
188
|
+
cylEl.setAttribute('babia-name', xLabel);
|
|
189
|
+
cylEl.id = item[data.index];
|
|
190
|
+
cylEl.object3D.position.x = posX;
|
|
191
|
+
this.chartEl.appendChild(cylEl);
|
|
199
192
|
}
|
|
193
|
+
|
|
194
|
+
createCylinder(this, cylEl, data, item, colorId, xLabel, posX, 0);
|
|
200
195
|
|
|
201
|
-
xLabels.push(xLabel)
|
|
202
|
-
xTicks.push(
|
|
196
|
+
xLabels.push(xLabel);
|
|
197
|
+
xTicks.push(posX);
|
|
203
198
|
|
|
204
199
|
//Increase color id
|
|
205
200
|
colorId++
|
|
201
|
+
|
|
202
|
+
last_radius = item[data.radius] * this.radius_scale;
|
|
206
203
|
}
|
|
204
|
+
|
|
205
|
+
// Remove old cyls (not in new data)
|
|
206
|
+
for (let name in currentCyls) {
|
|
207
|
+
if ( !currentCyls[name].found ) {
|
|
208
|
+
currentCyls[name].el.remove();
|
|
209
|
+
};
|
|
210
|
+
};
|
|
207
211
|
|
|
208
212
|
//Print axis
|
|
209
213
|
if (data.axis) {
|
|
210
|
-
const lengthX =
|
|
211
|
-
|
|
212
|
-
this.updateAxis(xLabels, xTicks, lengthX, firstradius, maxRadius, valueMax, lengthY);
|
|
214
|
+
const lengthX = xTicks[xTicks.length-1] + (dataToPrint[0][data.radius]+ dataToPrint[dataToPrint.length-1][data.radius])* this.radius_scale / 2 ;
|
|
215
|
+
this.updateAxis(xLabels, xTicks, lengthX, this.maxValue);
|
|
213
216
|
}
|
|
214
|
-
|
|
215
|
-
//Print Title
|
|
216
|
-
this.updateTitle();
|
|
217
217
|
},
|
|
218
218
|
|
|
219
219
|
/*
|
|
220
220
|
* Update axis
|
|
221
221
|
*/
|
|
222
|
-
updateAxis: function
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
222
|
+
updateAxis: function(labels, ticks, lengthX, maxValue) {
|
|
223
|
+
const data = this.data;
|
|
224
|
+
if (data.axis) {
|
|
225
|
+
if (!this.xAxisEl) {
|
|
226
|
+
this.xAxisEl = document.createElement('a-entity');
|
|
227
|
+
this.chartEl.appendChild(this.xAxisEl);
|
|
228
|
+
};
|
|
229
|
+
this.xAxisEl.setAttribute('babia-axis-x',
|
|
230
|
+
{'labels': labels, 'ticks': ticks, 'length': lengthX,
|
|
231
|
+
'palette': data.palette});
|
|
232
|
+
this.xAxisEl.setAttribute('position', {
|
|
233
|
+
x: 0, y: 0, z: data.radiusMax + 0.25
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
if (!this.yAxisEl) {
|
|
237
|
+
this.yAxisEl = document.createElement('a-entity');
|
|
238
|
+
this.chartEl.appendChild(this.yAxisEl);
|
|
239
|
+
};
|
|
240
|
+
this.yAxisEl.setAttribute('babia-axis-y',
|
|
241
|
+
{'maxValue': maxValue, 'length': this.lengthY});
|
|
242
|
+
this.yAxisEl.setAttribute('position', {
|
|
243
|
+
x: 0, y: 0, z: data.radiusMax + 0.25
|
|
244
|
+
});
|
|
245
|
+
if (data.axis_name){
|
|
246
|
+
if (data.index) {
|
|
247
|
+
this.xAxisEl.setAttribute('babia-axis-x', 'name', data.index);
|
|
248
|
+
} else {
|
|
249
|
+
this.xAxisEl.setAttribute('babia-axis-x', 'name', data.x_axis);
|
|
250
|
+
}
|
|
251
|
+
this.yAxisEl.setAttribute('babia-axis-y', 'name', data.height);
|
|
252
|
+
}
|
|
236
253
|
}
|
|
237
254
|
},
|
|
238
255
|
|
|
@@ -243,92 +260,71 @@ AFRAME.registerComponent('babia-cyls', {
|
|
|
243
260
|
console.log("processData", this);
|
|
244
261
|
this.newData = data;
|
|
245
262
|
this.babiaMetadata = { id: this.babiaMetadata.id++ };
|
|
246
|
-
while (this.el.firstChild)
|
|
247
|
-
this.el.firstChild.remove()
|
|
263
|
+
/*while (this.el.firstChild)
|
|
264
|
+
this.el.firstChild.remove();*/
|
|
248
265
|
console.log("Generating cyls...")
|
|
249
266
|
this.updateChart()
|
|
250
267
|
this.notiBuffer.set(this.newData)
|
|
251
268
|
}
|
|
252
269
|
})
|
|
253
270
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
entity.setAttribute('color', color);
|
|
269
|
-
entity.setAttribute('height', 0);
|
|
270
|
-
entity.setAttribute('radius', radius);
|
|
271
|
-
// Add animation
|
|
272
|
-
if (animation) {
|
|
273
|
-
var duration = 4000
|
|
274
|
-
var increment = 20 * height / duration
|
|
275
|
-
var size = 0
|
|
276
|
-
var id = setInterval(animation, 1);
|
|
277
|
-
function animation() {
|
|
278
|
-
if (size >= height) {
|
|
279
|
-
clearInterval(id);
|
|
271
|
+
let createCylinder = (self, cylEl, data, item, colorId, xLabel, posX, posZ, zLabel) => {
|
|
272
|
+
cylEl.setAttribute('babia-cyl', {
|
|
273
|
+
'height': item[data.height] * self.lengthY / self.maxValue,
|
|
274
|
+
'radius': item[data.radius] * self.radius_scale,
|
|
275
|
+
'color': colors.get(colorId, data.palette),
|
|
276
|
+
'label': 'events',
|
|
277
|
+
'animation': data.animation
|
|
278
|
+
});
|
|
279
|
+
if (data.legend) {
|
|
280
|
+
if (!zLabel){
|
|
281
|
+
cylEl.setAttribute('babia-cyl', {
|
|
282
|
+
'labelText': xLabel + '\nHeight: ' + item[data.height] + '\nRadius: ' + item[data.radius]
|
|
283
|
+
});
|
|
280
284
|
} else {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
285
|
+
cylEl.setAttribute('babia-cyl', {
|
|
286
|
+
'labelText': xLabel + ' | ' + zLabel + '\nHeight: ' + item[data.height] + '\nRadius: ' + item[data.radius]
|
|
287
|
+
});
|
|
284
288
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
+
};
|
|
290
|
+
if (posX !== cylEl.object3D.position.x) {
|
|
291
|
+
if (data.animation) {
|
|
292
|
+
cylEl.setAttribute('animation', {
|
|
293
|
+
'property': 'object3D.position.x',
|
|
294
|
+
'to': posX,
|
|
295
|
+
'dur': data.dur
|
|
296
|
+
});
|
|
297
|
+
} else {
|
|
298
|
+
cylEl.object3D.position.x = posX;
|
|
299
|
+
};
|
|
289
300
|
}
|
|
290
|
-
|
|
301
|
+
if (posZ !== cylEl.object3D.position.z) {
|
|
302
|
+
if (data.animation) {
|
|
303
|
+
cylEl.setAttribute('animation', {
|
|
304
|
+
'property': 'object3D.position.z',
|
|
305
|
+
'to': posZ,
|
|
306
|
+
'dur': data.dur
|
|
307
|
+
});
|
|
308
|
+
} else {
|
|
309
|
+
cylEl.object3D.position.z = posZ;
|
|
310
|
+
};
|
|
291
311
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
function showLegend(data, cylinderEntity, cylinder, el, maxRadius) {
|
|
295
|
-
cylinderEntity.addEventListener('mouseenter', function () {
|
|
296
|
-
this.setAttribute('scale', { x: 1.1, y: 1.1, z: 1.1 });
|
|
297
|
-
legend = generateLegend(data, cylinder, cylinderEntity, maxRadius);
|
|
298
|
-
el.appendChild(legend);
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
cylinderEntity.addEventListener('mouseleave', function () {
|
|
302
|
-
this.setAttribute('scale', { x: 1, y: 1, z: 1 });
|
|
303
|
-
el.removeChild(legend);
|
|
304
|
-
});
|
|
312
|
+
|
|
305
313
|
}
|
|
306
314
|
|
|
307
|
-
|
|
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;
|
|
315
|
+
let createUiLink = (el, position) => {
|
|
316
|
+
let ui_link = document.createElement('a-entity');
|
|
317
|
+
if (!el.id){
|
|
318
|
+
// Generate id
|
|
319
|
+
let id = 'bars' + Math.floor(Math.random() * 1000);
|
|
320
|
+
el.id = id
|
|
321
|
+
}
|
|
322
|
+
console.log('id:', el.id)
|
|
323
|
+
ui_link.setAttribute('babia-ui-link', {viz: el.id})
|
|
324
|
+
ui_link.setAttribute('position', {x: position.x, y: position.y, z:position.z})
|
|
325
|
+
el.appendChild(ui_link)
|
|
326
|
+
console.log('Create Button', el)
|
|
327
|
+
return
|
|
331
328
|
}
|
|
332
329
|
|
|
333
|
-
|
|
334
|
-
|
|
330
|
+
module.exports.createCylinder = createCylinder;
|