Possibility to hide/display avatars from Cesium+

parent f8b1349d
This diff is collapsed.
Dossier de stockage des photos des membres, rappatriées à l'aide du script PHP
\ No newline at end of file
......@@ -37,7 +37,9 @@
<label for="levels">niveaux</label>
<select id="levels"></select><br /><br />
<input id="displayEdges" type="checkbox">
<label for="displayEdges">Afficher les liens</label>
<label for="displayEdges">Afficher les liens</label><br />
<input id="displayAvatars" type="checkbox">
<label for="displayAvatars">Afficher les avatars Cesium+</label>
</div>
<span class="line"></span>
<div>
......
......@@ -87,4 +87,28 @@ sigma.canvas.nodes.image = (function() {
};
return renderer;
})();
\ No newline at end of file
})();
// We gave our own name 'border' to the custom renderer
sigma.canvas.nodes.border = function(node, context, settings) {
var prefix = settings('prefix') || '';
context.fillStyle = node.color || settings('defaultNodeColor');
context.beginPath();
context.arc(
node[prefix + 'x'],
node[prefix + 'y'],
node[prefix + 'size'],
0,
Math.PI * 2,
true
);
context.closePath();
context.fill();
// Adding a border
context.lineWidth = node.borderWidth || 1;
context.strokeStyle = node.borderColor || '#fff';
context.stroke();
};
\ No newline at end of file
......@@ -11,6 +11,7 @@ function displayGraph(s){
// We place the nodes around a circle in order to make the force atlas efficient
s.graph.nodes().forEach(function(node, i, a) {
node.type = 'border';
node.x = Math.cos(Math.PI * 2 * i / a.length);
node.y = Math.sin(Math.PI * 2 * i / a.length);
......@@ -48,6 +49,16 @@ function displayGraph(s){
}
});
// Function to display/hide avatars
function displayAvatars(bool){
var type;
bool ? type='image' : type='border';
s.graph.nodes().forEach(function(n) {
n.type = type;
});
_.$('displayAvatars').checked = bool;
}
// Function to display the edges or not
function displayEdges(bool){
s.settings('drawEdges',bool);
......@@ -110,6 +121,7 @@ function displayGraph(s){
// Initialize the controls
_.$('displayEdges').checked = false; // When the user has refreshed the page
_.$('displayAvatars').checked = false; // When the user has refreshed the page
_.$('min-degree').max = maxDegree;
_.$('max-degree-value').textContent = maxDegree;
tabIdentities.sort(tri); // Sort identities in alphabetical order and fill in the combo list
......@@ -228,7 +240,12 @@ function displayGraph(s){
// Checkbox to display the edges
_.$('displayEdges').onclick = function() {
displayEdges(_.$('displayEdges').checked);
displayEdges(this.checked);
};
// Checkbox to display the avatars
_.$('displayAvatars').onclick = function() {
displayAvatars(this.checked);
};
// Button to close the minimap
......@@ -240,7 +257,7 @@ function displayGraph(s){
// Detect button for communities
_.$('run-btn').addEventListener("click", function(e) {
s.settings('edgeColor','target');
s.settings('edgeColor','source');
// Detect communities using the Louvain algorithm:
louvainInstance = sigma.plugins.louvain(s.graph, {
setter: function(communityId) { this.my_community = communityId; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment