You can go into the super-guide by receiving a mouse event and passing arguments to it that otherwise would have provided d3. This gives you a pretty clean way to do this while continuing to use the d3 constructs. For one item, use the following:
var path = g.select('path'); path.on('click').call(path.node(), path.datum());
For several elements, you can run each of them in turn:
g.selectAll('path').each(function(d, i) { d3.select(this).on('click').apply(this, arguments); });
The latter can also be used for a single element if your selector is specific enough, or if you use .select() instead of .selectAll() to return only the first element.
Yony Sep 10 '14 at 20:31 on 2014-09-10 20:31
source share