I am developing a resettable tree graph. I am trying to create a mouse event over an event on a node. When I click on node, at this time it should display the name of the node. I tried, but I donβt know how to calculate the value of the transform attribute to show the name above or below the node.
var nodeEnter = node.enter().append("g") .attr("class", "node") .attr("transform", function(d) { return "translate(" + source.y0 + "," + source.x0 + ")"; }) .on("click", click) .on("mouseover", function(d){ alert("over"); d3.select(this).attr('transform', function(d){ return 'translate(?,?)'}) .text(d.name + ": " + d.id) .style('display', null); }) .on("mouseout", function(d){ alert("out"); d3.select(this).style('display', 'none'); });
translation (?,?)
resettable tree graph: http://bl.ocks.org/mbostock/4339083
Please try to help me. Thanks.
source share