I am struggling to find a notebook that get coordinates when the user clicks with mouse in rectangular area. Any hints? Thanks.
1 Like
d3.pointer(evt) returns the pointer location of evt
relative to the HTML element that the event is attached to. So you might have something like:
div.on("click", function (evt) {
let [x,y] = d3.pointer(evt);
// Do something with x and y
});
Here’s an example where the click coordinates are reported:
3 Likes
Thanks a lot, that solves my problem!