block by curran 88d03aa54097367eaae1

href on d3 objects

Full Screen

This example shows how to make an SVG element link to an external page.

This has the expected behavior of normal links when you open it in a new window. When clicked, the link will open in the current tab. When clicked while holding the meta key (“Command” on Macs and “Control” on Windows), the link will open in a new tab.

Clicking the rectangle doesn’t work correctly in the bl.ocks viewer, because it is in an iFrame (open the debugging console to see the iFrame-related error), but this technique of adding links to visual marks should work fine in your own D3 projects.

This is addressing the thread href on d3 objects in the D3 Google Group.