Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
doc: forceLink seems to replace string IDs with links to objects, but this is not documented #103
forceLink seems to replace string IDs with links to objects, but this is not documented. I. e. https://github.com/d3/d3-force/blob/master/README.md#forceLink doesn't say anything about this. I discovered this only by experimenting with code
It’s implied in two places, but I agree it should be clearer. In link.links:
And in link.id:
So the implication is that if you don’t specify link objects whose link.source and link.target properties are objects, they will be replaced by object references whenever the link force is initialized. See the implementation here:
This applies not just to string identifiers but the default numeric indexes, too (when you haven’t specified a custom link.id accessor).
Forces are initialized when they are attached to simulations and when the simulation’s nodes change. Related, simulation.force and simulation.nodes should explicitly mention that they (re-)initialize forces; this is currently only documented by force.initialize.