javascript - Proper way to select child nodes in D3 -
i have created svg element nodes:
gnodes = svg.selectall("g.node") .data(_nodes); var newnodes = gnodes.enter().append("g") .attr("class", "node") .attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; }) .call(drag) .on('mouseover', onmouseover) .on('mouseout', onmouseout); newnodes.append("circle") .attr("cx", 0) .attr("cy", 0) .attr("r", radius); newnodes.append("image") .attr("xlink:href", getimage) .attr("x", -radius/2) .attr("y", -radius/2) .attr("width", radius + "px") .attr("height", radius + "px");
in onmouseover want change colour of highlighted circle, can not item data receive:
function onmouseover(d, i) { var c1 = d.select("circle"); // error var c2 = i.select("circle"); // error var c3 = d.selectall("circle"); // error var c4 = i.selectall("circle"); // error }
what way child node d3?
d
data object , i
index. both not d3 instances provide access of d3 select
functions.
try this:
myelement.on('mouseenter', function(d,i) { d3.select(this).select('circle'); });
Comments
Post a Comment