One thing that has come up often is showing some sort of tooltip.
I want to be able to access the 'node' selection from within the callback to the mouse events so as to append the svg:text node to it with the translation applied.
It's documented, but I need to make the API reference more visible
from the website. So much to do!
https://github.com/mbostock/d3/wiki/Selections#insert
I had a fairly good experience using the Tipsy plugin with Protovis;
it'd be possible to do the same with D3, and a bit easier to determine
the correct positioning by inspecting the DOM elements. In particular,
the getBBox method is handy for determining the bounding box of an
arbitrary SVG elements:
http://www.w3.org/TR/SVG/types.html#__svg__SVGLocatable__getBBox
Mike
Something like:
vis.selectAll("circle.dot").transition()
… transition circle properties here …
.select("title")
.text(function(d) { … compute new title text here … });
The title text isn't interpolated, but simply set to the new value
when the transition starts.
Mike
Right. Use select if there's one child (per parent); this propagates
the parent data, and preserves the grouping:
https://github.com/mbostock/d3/wiki/Selections#select
As for the "svg:" bit, that's a bit of an inconsistency between
selecting and creating. When selecting, you don't need to specify the
namespace. (If you did, it would look like "svg|title", but browsers
don't currently support namespaced selectors.) However, you do need to
specify the namespace when creating new nodes, hence, "svg:title".
I could make it a little bit shorter by defaulting to the namespace of
the parent node, so that if you're in svg, you don't have to specify
"svg:" when appending. But I'm not sure that's a great idea, because
you'd still need to remember to say "svg:svg" when you create the
outer SVG container.
Mike