D3-graph-gallery
D3-graph-gallery copied to clipboard
tooltip d3.v6 example mouse position
https://www.d3-graph-gallery.com/graph/connectedscatter_tooltip.html
in the d3.v6 example.
const mousemove = function(event,d) { Tooltip .html("Exact value: " + d.value) .style("left", (event.x)/2 + "px") .style("top", (event.y)/2 + "px") }
(event.x)/2 and (event.y)/2 is not mouse mouse position. x position is d3.pointer(event)[0] + 70 y position is d3.pointer(event)[1]