summaryrefslogtreecommitdiff
path: root/bubble.js
diff options
context:
space:
mode:
Diffstat (limited to 'bubble.js')
-rw-r--r--bubble.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/bubble.js b/bubble.js
index 7c10f83..8d957b6 100644
--- a/bubble.js
+++ b/bubble.js
@@ -178,6 +178,8 @@ function processData(data) {
});
var infoBox = d3.select('#infobox');
+
+ // double-click locks selection of a user on hover
var selectedNode = null;
node.on('dblclick', function (d) {
if (selectedNode === d) {
@@ -192,14 +194,31 @@ function processData(data) {
infoBox.classed('user-locked', selectedNode === d);
})
.on('mouseover', function (d) {
+ console.log('Hovering over', d);
// only update on hover if no node is selected
if (selectedNode === null) {
updateInfobox(d, this);
}
+ // always update neighboring edges
+ contents.selectAll('.link')
+ .classed('neighbor', function (edge) {
+ return edge.source === d || edge.target === d;
+ });
+ // ... and also update neighboring nodes
+ contents.selectAll('.node')
+ .classed('neighbor', function (node) {
+ return node.related.indexOf(d.index) >= 0;
+ });
+ })
+ .on('mouseout', function (d) {
+ contents.selectAll('.neighbor')
+ .classed('neighbor', false);
});
+
// info panel for each user node
var userInfo = infoPane.select('.user-info');
+ // highlight selected node and update the user info in infobox
function updateInfobox(d, nodeElm) {
// unselect other nodes, mark self as selected.
contents.select('.node.selected').classed('selected', false);