javascript - d3 fade icons of non connected nodes -
I have created a guided graph of my twitter timerline, and on each node the user has a profile icon with the screen name, And when the mouse rotates on a node it fades non-connected nodes
But the image of the icon of non-connected nodes is not fading, I have received text and lines to fade, but The icons remain the same.
How can I also fade the image of the node?
Here is the graph
var nodes = {}; Links.forEach (work (link) {link.source = nodes [link.source] || (nodes [link.source] = {name: link.source}); link.target = nodes [link.target] || (Nodes [link.target] = {name: link.target}); link.source.icon = link.icon;}); Width = 1400, height = 1200; Fill = d3.scale.category20 (); Var strength = d3.layout.force (). Nodes (d3.values (nodes)). Link (link). Size ([width, height]) .Link resistance (120) Charge (-300) .on ("tick", tick). Start (); Var svg = d3.select ("# home-page"). Attached ("svg: svg") .attr ("width", width) .attr ("height", height) .attr ("pointer-events", "all") .append ('svg: g') .Col ("Zoom", redraw) at d3.behavior.zoom () .append ('svg: g'); // per-type markers, because they do not receive styles. ("Marker") .data (["suit", "licensing", "resolved"]) .endra () .andend ("marker") .attr ("id", " Id "(" refix ", 15) .attr (" refY ", -1.5) .attr (" markerwidth ", 6) .attr (" markerHeight ", 6) .attr (" orient "," auto "). Append ("Path") .attr ("d", "m0, -5L10,0L0,5"); path path = svg.append ("g"). All ("path") .data (force.links () ) .enter () .addend ("path") .attr ("class", function (d) {return "link" + d.type;}). Etr ("marker-end", function (d) {return "Url (#" + d.type + ");}); var image = svg.append (" g "). All (" image "). Data (force.nodes ()) .enter () .addend ("Image") .attr ("xlink: href", function (d) {return d.con;}) .rrt ("x", -8) .attr ("y", -8) .attr ("width", 20) .attr ("height", 20). Style ("stroke", function (D) {return D. 3. RGB (fill (DGP process) ("Mouseout", feed (1)); Var text = svg.append ("g"); ). ("Text") .attr ("x", 8) .attr ("Y", ".31em"). ("Text") .data (force.nodes ()) .enter (). Text (function (d) {return dna;}); Function radra () {console.log ("here", d3.event.translate, d3.event.scale); Svg.attr ("conversion", "translation (" + d3.event.translate + ")" + "scale (" + d3.event.scale + ")"); } Var linkedByIndex = {}; Links.forEach (function (d) {linked bindex [d.source.inx + "," + d.target.index] = 1;}); Function isConnected (a, b) {return linkIndex [a.index + "," + b.index] || || LinkedIn Index [b. Induct + "," + AEndex] || A.index == b.index; } Function feed (opacity) {return function (d) {image.style ("stroke-opacity", function (o) {thisOpacity = isconnected (d, o)? 1: opacity; this.setAttribute ('fill-opacity' , ThisOpacity;; back to this feature;}); Text.style ("stroke-opacity", function (o) {thisOpacity = isconnected (d, o)? 1: ambiguity; this.setAttribute ('fill-opacity', this opacity); Return this feature;}); Path.style ("stroke-opacity", function (o) {returns o.source === D || OABIJET === D? 1: ambiguity;}); }; } // Use the ambient arc path segment for double-encoding directionality function tick () {path.attr ("d", linkArc); Text.attr ("conversion", conversion); Image.attr ("result", resulting in); } Function link acre (d) {var dx = d.target.x - d.source.x, dy = d.target.y - d.source.y, dr = Math.sqrt (dx * dx + dy * dy) ; Return "M" + d.source.x + "," + d.source.y + "A" + + + "," + Dr. + "0 0,1" + d.target.x + "," + D.target.y; } Transform result (d) {return "translation (" + d.x + "," + d.y + ")"; } << Code>
instead of its fade
function
image.style ("stroke-opacity", function (o) {thisOpacity = isconnected (d, o) 1: opacity; this.setAttribute ('fill-opacity', thisOpacity); ;}); With
image.style ("opacity", function (o) {thisOpacity = isconnected (d, o)? 1: Opacity; SetAttribute ('Opacity', this opacity); back to this feature;});
for your image
refurbished