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");}
これを表現する適切な方法を知っている人はいますか?