Browse Source

Added dynamic update of profile view when you click on the graph.

pull/11/head
Jeffery Russell 5 years ago
parent
commit
7dc429a74e
2 changed files with 21 additions and 0 deletions
  1. +1
    -0
      public/FriendsGraph.html
  2. +20
    -0
      public/js/friendsGraph.js

+ 1
- 0
public/FriendsGraph.html View File

@ -77,6 +77,7 @@
<div class="col-md-10 col-12">
<h2 id="graphLabel"></h2>
<div id="myGraph" class="w-100"></div>
<pre id="eventSpan"></pre>
</div>
<div class="col-md-2 col-12 w-100">
<div id="profileGen"></div>

+ 20
- 0
public/js/friendsGraph.js View File

@ -223,6 +223,17 @@ function addSelfToGraph(username)
}
function bringUpProfileView(id)
{
for(var i = 0; i < nodes.length; i++)
{
if(nodes[i].id === id)
{
profileGen(nodes[i].name, "profileGen");
}
}
}
/**
* Creates a graph
* @param username
@ -248,6 +259,15 @@ function createFriendsGraph(username, containerName, graphsTitle)
edges: edges
};
var network = new vis.Network(container, data, options);
network.on("click", function (params) {
params.event = "[original event]";
document.getElementById('eventSpan').innerHTML = '<h2>Click event:</h2>' + JSON.stringify(params, null, 4);
if(Number(this.getNodeAt(params.pointer.DOM)) !== NaN)
{
bringUpProfileView(Number(this.getNodeAt(params.pointer.DOM)));
}
});
});
});
})

Loading…
Cancel
Save