Accept iterables?

Open
#178 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
d3, javascript

Research direction

Read the nodes and links APIs in the d3-force documentation and inspect the implementation and tests for those methods. The issue proposes accepting iterable input for nodes, but leaves the behavior for grouped links unresolved. Determine the intended iterable behavior and how it should be tested before implementation; done means the agreed input form is supported and covered by tests.

Written by the indexing model from the issue text.

Description

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

Dominant language
JavaScript
Stars
2k
Forks
395
Avg merge
5h 46m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from d3/d3-force

All issues in d3/d3-force

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.