Two simple code, one fails, one runs ?

Continuing my journey through the d3’s docs, I tried executing this code snippet.
var matrix = [
[11975, 5871, 8916, 2868],
[ 1951, 10048, 2060, 6171],
[ 8010, 16145, 8090, 8045],
[ 1013, 990, 940, 6907]
var tr =“body”)
var td = tr.selectAll(“td”)
.data((d) => d)
.text((d) => d);

which I manage to have working in this notebook,
But then I copied the code to another notebook and it failed.
with a
TypeError: TypeError:…).append(…).selectAll(…).data(…).join is not a function
at eval (eval at Dt (, :17:6)

I was careful for hidden chars, checked both code with but cannot find the difference. Although I must be missing something obvious but I fail to see. Please help ?

Thank you

Can you share your most recent version? I don’t see any errors in the one that is currently public.

notebook with error updated.

I don’t see any error

It’s possible you had version mismatch somehow

here is the version, which is referenced in


Ok, I saw my error
d3 = require("d3@v5") should have been d3 = require("d3@5")

That last notation points by default to the last version in d3@5 version, while d3@v5 points to the first version of d3@5 right ?

As far as npm is concerned both “v5” and “5” point to the same version. The “v” prefix is ignored by npm’s semver library, but is commonly used in tags.

It’s probable that your browser was just using a cached older version of d3. That also happened to me after d3 5.8.0 was released. Hard refreshing some number of times and clearing caches eventually fixed it.


Ok… I still need to get those dev reflex but getting there thanks to you.