scotthmurray / d3-book

Code examples for “Interactive Data Visualization for the Web”
http://d3book.com
Other
2.41k stars 1.79k forks source link

Chapter 14 - Dragging event #50

Open dung-phan opened 2 years ago

dung-phan commented 2 years ago

Original code: var dragging = function(d) { //Log out d3.event, so you can see all the goodies inside //console.log(d3.event);

It should be function(e,d) and console.log(e) and using e (event) to get access to dx and dy.

Also I have a question: svg.selectAll("path") .attr("d", path); Paths and circles in this example (p.301) are updated on svg instead of map which contains the group. Should it be map instead or it shouldn't matter here? Thanks a lot!

scotthmurray commented 2 years ago

Thanks @dung-phan! I suspect that you're using a newer version of D3. The book and examples are written to work with v4.5.0 — if you use a newer version (like the current version), you'll have to make some changes.

I've flagged this to update in some future version of the book.

As for your second question, if you point me to which example this is referencing, I can take a look: https://github.com/scotthmurray/d3-book