I am new to D3.js and I am trying to make some animation with my graph,
but I can't resolve a problem with the .get() method called on a d3.map for D3 version 6.
When I run the code it throws an error:
nodeById.get is not a function
My code is based on: https://bl.ocks.org/ctufts/bd6956a45ea69734f5909c8b526c13b5
//some fetch data in json file
d3.json("someURLjsonfile").then(function (graph) {
let nodes = graph.nodes,
nodeById = d3.map(nodes, function (d) {
return d.id;
}),
links = graph.links,
bilinks = [];
links.forEach(function (link) {
var s = nodeById.get(link.source), // <-- error
t = nodeById.get(link.target), // <-- error
i = {}; // intermediate node
nodes.push(i);
links.push({
source: s,
target: i
}, {
source: i,
target: t
});
bilinks.push([s, i, t]);
});