Skip to main content
100%

Adding links to objects in v6

✓ Published0🌍 Public
Dd3noob
Last edited Sep 15, 2020
Created on Sep 15, 2020

This example demonstrates how to add a hyperlink to an SVG rectangle in D3 v6, with the text "gongoozler" placed on top of it. It shows that the text remains clickable through the rectangle’s link by setting its `pointer-events` style to `"none"`. The code appends an SVG `<a>` element with an `xlink:href` attribute to Wikipedia, then draws the rectangle inside it via `d3.select` and `.append`. The text is added separately using `holder.append("text")`. Rendering uses plain SVG elements created with D3’s selection API.

AI-generated description

The above example is intended to demonstrate adding a hyperlink to an object (the rectangle) and instructing the text object to be transparent to the pointer so that the link on the rectangle is recognised 'through' the text.

This is one of the code samples for the update to the book D3 Tips and Tricks to version 6 of d3.js.

mit Licensed

Similar vizzes