我正在使用 Christophe Viau 的 d3.js 工具提示助手:
https://gist.github.com/milroc/2975255
但也想在鼠标悬停时触发其他事件,而不仅仅是工具提示,具体来说我想修改圆圈本身,所以我尝试了:
var circle = svg.append("svg:g").selectAll("circle")
.data(force.nodes())
.enter().append("svg:circle")
.call(d3.helper.tooltip(function(d,i){return d.name;}))
.attr("r", 12)
.call(force.drag)
.on("mouseover", function(){d3.select(this).style("fill", "blue");});
任何一个都可以单独工作,但不能一起工作。我尝试编辑工具提示帮助程序,但出现错误。我在工具提示助手中添加了这些变体:
var newvar = function(d,i) {d3.select(this).style("fill", "blue");}
var newvar = function(selection) {d3.select(this).style("fill", "blue");}
有谁知道正确的表达方式是什么?