🏠 back to Observable

d3.event is undefined?

I am trying to implement zoom .

I have added the most basic implementation as below

var zoom = d3.zoom().on(‘zoom’, zoomed);

svg.call(zoom);

function zoomed() {
var transform = d3.event.transform;
leaf.attr(‘transform’, transform.toString());
}

When zoomed() is called by clicking on the graph I get en error that d3.event is undefined?

Not sure what I am doing wrong?

thanks,

Scott

d3.event was removed in d3 v7. Here’s a migration guide (and here’s the section on events)

Yurivish,

I just checked the version of d3 and it says 5.16???

Scott