Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

d3.mouse is not a function

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.

like image 641
Stan Sokolov Avatar asked Dec 03 '20 22:12

Stan Sokolov


People also ask

What does d3 mouse return?

mouse() function in D3. js is used to return the x-coordinate and y-coordinate of the current event. If the event is clicked then it returns the x and y position of the click.

Is d3 deprecated?

d3-collection is deprecated, and its methods are replaced: d3. nest ⇨ d3. group and d3.

What is d3 bisector?

The bisector() Function in D3. js is used to returns a new bisector using the specified accessor or comparator function. This method can be used to bisect arrays of objects instead of being limited to simple arrays of primitives.


1 Answers

d3.mouse was removed in d3v6, you should use d3.pointer(event)

like image 196
Achraf Farouky Avatar answered Nov 16 '22 02:11

Achraf Farouky