JSFiddle - React, Tailwind, and code Playground
by miska knapek
JavaScript
var mouseCoords = [0, 0];
var svgArea = d3.select("body")
.append("svg")
.attr("width", 500)
.attr("height", 500 );
var text2 = svgArea.append("text")
.attr("x", 100 )
.attr("y", 100 )
.style("fill", "red")
.text( mouseCoords[0]+","+mouseCoords[1] );
svgArea.on( "mousemove", function(){
var coords = d3.mouse( this ) ;
text2.text( coords[0]+","+coords[1] );
});