Closed staysh closed 1 year ago
works as expected; see https://github.com/d3/d3-force#link_id for details
I think the confusion here is that you can only chain when you pass link.id an argument. If you donโt pass an argument, then link.id is a getter, returning the current id. So:
const link = d3.forceLink();
console.log(link.id()); // returns the current id accessor
link.id((d) => d.id); // sets the id accessor and returns link
So, this is fine:
link.id((d) => d.id).strength(10); // ๐
But this is nonsensical because link.id() without an argument returns the current id accessor, not the link force.
link.id().strength(); // ๐
d3.forceLink().id().strength()
results in an uncaught TypeError that it is not a functiond3.forceLink().id() //ok
d3.forceLink().strength() //ok