Reputation: 2270
Upgraded d3 library and now getting an error for executing the following code
console.log(`\n${JSON.stringify(d3.mouse)}\n`);
const mouse = d3.mouse(this);
Getting
undefined
d3.mouse is not a function
And it is not defined anywhere. I went trough d3 exports and this function is not really exported from anywhere.
Upvotes: 20
Views: 16004
Reputation: 1280
d3.mouse
was removed in d3v6, you should use d3.pointer(event)
.
Upvotes: 38
Reputation: 87
An example of using event is represented below:
let mousemove = function (event, d) {
tooltip
.html("Year: " + d.Year + " Sales: " + d.value + " M$")
.style("left", (event.pageX + 30) + "px")
.style("top", (event.pageY) + "px")
}
If each data point has the values of year and value, you can demonstrate them using the code above. Event has two attributes: event.pageX and evev.pageY. Try to sum the returned values, for example event.pageX +30 , so they are not going to be in the exact position that the mouse is on.
Upvotes: 1