Accepted answer

When you set up your click handler like this:

.on("click", (d) => click(d))

The fat-arrow notation preserves the context of this, so it's referring to the instance of your class.

Your handler, though:

function click(d) {"circle").transition()
        .attr("r", 16);

Is expecting this to be the g that was clicked.

So, set up your handler like:

.on("click", click)

Related Query