I'm creating a network graph with d3.js.
I want to group the nodes just like this example. The example uses d3 v4, but I'm using v6.
In the migration guide it says the (d3).map()
doesn't work anymore(it gives me an error when I use .map()
) and I have to use new Map()
.
But when I do this I get the following error:
Uncaught TypeError: function is not iterable (cannot read property Symbol(Symbol.iterator)) at new Map ()
This is my code atm:
const groupIds = new Set(nodes.map(function(n) {
//get ids
}))
.values()
new Map(function(departmentId) {
return {
departmentId: departmentId,
count: nodes.filter(function(n) {
//some code
}).length
};
})
.filter(function(department) {return department.count > 0;})
new Map(function(department) {return department.departmentId;});
I also tried let map = new Map()
, but gives the same error.
How can I use the new Map()
in this context?
When I use .map()
instead of new Map()
it says:
Uncaught TypeError: (intermediate value).values(...).map is not a function