javascript - Select node and highlight its connections by feature ID in D3.js -
i have create d3.js network graph. want select node id , highlight , neighbors. have following code
var linkedbyindex = {}; (i = 0; < graph.nodes.length; i++) { linkedbyindex[i + "," + i] = 1; }; graph.links.foreach(function (d) { linkedbyindex[d.source.index + "," + d.target.index] = 1; }); //this function looks whether pair neighbours function neighboring(a, b) { return linkedbyindex[a.index + "," + b.index]; }
but how use 1 selected node selected feature id?
i worked out answer:
d3.select("#nodeid") .transition().duration(500) .each(function(d){ //#nodeid selected node.style("stroke-opacity", function(o) { thisopacity = isconnected(d, o) ? 1 : opacity; this.setattribute('fill-opacity', thisopacity); return thisopacity; }); link.style("stroke-opacity", function(o) { return o.source === d || o.target === d ? 1 : opacity; }); });
i want display labels nodes display. suggestions?
Comments
Post a Comment