How does one go about displaying the 1st degree neighbors of a selected (and by that i mean hovering over the node) via d3,tip?
Here's my d3.tip portion
var tip = d3.tip()
.attr('class', 'd3-tip')
.html(function(d) {return [name of neighbors];});
How would I change the follow to help me return text via my tip rather than changing the opacity?
var linkedByIndex = {};
var toggle = 0;
for (i = 0; i < nodes.length; i++) {
linkedByIndex[i + "," + i] = 1;
};
links.forEach(function (d) {
linkedByIndex[d.source.index + "," + d.target.index] = 1;
});
//This function looks up whether a pair are neighbours
function neighboring(a, b) {
return linkedByIndex[a.index + "," + b.index];
}
function connectedNodes() {
if (toggle == 0) {
//Reduce the opacity of all but the neighbouring nodes
d = d3.select(this).node().__data__;
circle.style("opacity", function (o) {
return neighboring(d, o) | neighboring(o, d) ? 1 : 0.1;
});
path.style("opacity", function (o) {
return d.index==o.source.index | d.index==o.target.index ? 1 : 0.1;
});
//Reduce the op
toggle = 1;
} else {
//Put them back to opacity=1
circle.style("opacity", 1);
path.style("opacity", 1);
toggle = 0;
}}