d3/d3-force

Accept iterables?

Fil opened this issue · 0 comments

Fil commented

Use case:

  • a list of top scientific journals, yearly data such as citation index, etc.
  • links are certain similarities (same publisher, same domain area…)

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).