Created
November 18, 2013 09:54
-
-
Save yongchun/7525394 to your computer and use it in GitHub Desktop.
d3的mouseover鼠标事件
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var node = svg.selectAll(".node") | |
.data(graph.nodes) | |
.enter().append("g") | |
.attr("class", "node") | |
.on("click",function(d){Ext.Msg.alert("businessID",d.nodes[0].businessId);}) | |
.on("mouseover", function(d) { | |
var g = d3.select(this); // The node | |
var info = g.append('text') | |
.classed('info', true) | |
.attr('x', d.x+6) | |
.attr("dy", function(d) { return d.y-3;}) | |
.text(function(d){ | |
return d.nodes[0].businessId; | |
}); | |
}) | |
.on("mouseout", function() { | |
// Remove the info text on mouse out. | |
d3.select(this).select('text.info').remove(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment