d3-book icon indicating copy to clipboard operation
d3-book copied to clipboard

Chapter 14 - Dragging event

Open dung-phan opened this issue 3 years ago • 1 comments

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!

dung-phan avatar Feb 02 '22 15:02 dung-phan

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

scotthmurray avatar Mar 15 '22 05:03 scotthmurray