Tooltip Anchored to an HTML Element

The .position( ) method in the Tooltip class accepts an array of two numbers representing x and y values (in [x, y] format), an accessor function that returns an array of two numbers, or an HTML element used as an anchor point.

<div id="square"></div>
#square {
  background-color: red;
  height: 25px;
  width: 25px;
  position: absolute;
  left: 50%;
  top: 50%;
}
var square = document.getElementById("square");

var tip = new d3plus.Tooltip()
  .data([{title: "Test Tooltip"}])
  .position(square)
  .render();