This is a quick test of a tooltip that is responsive to the curser and also avoids the edges so that it is always visible. A more practical example can be seen here: Election History w/ Avoidant Tooltip.
If you can manage to click on the tooltip, the screen flashes!
https://d3js.org/d3.v4.min.js