d3 / d3-force

Force-directed graph layout using velocity Verlet integration.
https://d3js.org/d3-force
ISC License
1.81k stars 376 forks source link

Accept iterables? #178

Open Fil opened 4 years ago

Fil commented 4 years ago

Use case:

It would be nice to write:

const group = d3.group(data, d => d.title) simulation.nodes(group)

and have 1 node per title, indexed with the title.

This is easy to do currently with nodes(d3.groups(…)), accepting an iterable form would be a simple addition of Array.from(), as shown in this notebook which groups the Misérables by the group id: https://observablehq.com/d/ea47e3f4c38082e0

We could have something similar for links, although it's not clear to me yet how:

simulationLinks.links(d3.rollup(groups, v => v.map(d => d.title), d => d.publisher)) to group titles that have a common publisher (it's not 1-to-1 links in this case).