Skip to main content
100%

d3.js tool tip with HTML link

✓ Published0🌍 Public
Dd3noob
Last edited Apr 30, 2014
Created on Apr 30, 2014

This example shows a line graph of date-stock price pairs from a CSV file, where each data point is marked by a circle. Hovering over a circle triggers an HTML tooltip containing a hyperlink to Google, a formatted date, and the closing price. It uses d3.v3 APIs like `d3.time.scale`, `d3.svg.line`, and `d3.select` to build the SVG chart and manage the tooltip’s position and opacity transitions. The tooltip remains active because the `pointer-events` CSS property is not disabled.

AI-generated description

This is designed to demonstrate generating tool tips with an HTML link in them. The graph is based on a simple line graph per the book D3 Tips and Tricks and was generated in response to a question on the d3noob.org blog.

The main differences with this example are the addition of the <a> tags in the appropriate places as commented, the removal of the pointer-events: none attribute in the `style section and the slight amending of the transitions of the html divs so that the tool tips stay in place while the mouse moves off the dot.

Similar vizzes