I\'m trying to use the angularjs tooltip directive on my d3 visualisation, so I have something like
var node = svg.selectAll(\".node\")
.data(nodes)
I like this method much better since you don't have to call removeAttr (seems like a hack)
myApp.directive('myNodes', ['$compile', function ($compile) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var nodes = [{"name": "foo"}, {"name": "bar"}]
var mySvg = d3.select(element[0])
.append("svg")
.attr("width", 100)
.attr("height", 100);
var node = mySvg.selectAll(".node")
.data(nodes)
.enter()
.append("circle")
.attr("cx", function(d,i){
return 20+i*50;
})
.attr("cy", 50)
.attr("r", 10)
.attr("tooltip-append-to-body", true)
.attr("tooltip", function(d){
return d.name;
});
$compile(svg[0])(scope);
}
};
}]);