Skip to content

Instantly share code, notes, and snippets.

@yongchun
Created November 18, 2013 09:54
Show Gist options
  • Save yongchun/7525394 to your computer and use it in GitHub Desktop.
Save yongchun/7525394 to your computer and use it in GitHub Desktop.
d3的mouseover鼠标事件
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