Hi,
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 = d3.select(“body”)
.append(“table”)
.selectAll(“tr”)
.data(matrix)
.enter().append(“tr”);
var td = tr.selectAll(“td”)
.data((d) => d)
.enter().append(“td”)
.text((d) => d);
which I manage to have working in this notebook https://beta.observablehq.com/@maliky/table-example-working,
But then I copied the code to another notebook and it failed.
https://beta.observablehq.com/@maliky/table-example-broken
with a
TypeError: TypeError: d3.select(…).append(…).selectAll(…).data(…).join is not a function
at eval (eval at Dt (https://static.observableusercontent.com/worker/worker.6257841301f9ded022c9b58fa57227d7a7b6c7aa9cd35a3b3f62100b54b51d6d.js:2:36229), :17:6)
at https://static.observableusercontent.com/worker/worker.6257841301f9ded022c9b58fa57227d7a7b6c7aa9cd35a3b3f62100b54b51d6d.js:2:28757
I was careful for hidden chars, checked both code with https://beta.observablehq.com/@randomfractals/notebook-info but cannot find the difference. Although I must be missing something obvious but I fail to see. Please help ?
Thank you