d3-book
d3-book copied to clipboard
Chapter 14 - Dragging event
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 map
instead or it shouldn't matter here?
Thanks a lot!
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