Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: add sample code for transitions into README docs #283

Closed
curran opened this issue May 24, 2021 · 1 comment
Closed

Proposal: add sample code for transitions into README docs #283

curran opened this issue May 24, 2021 · 1 comment

Comments

@curran
Copy link
Contributor

curran commented May 24, 2021

In order to make the documentation in the README more complete for people looking for the appropriate pattern to use d3.join with transitions, I suggest to add the following snippet directly inside the README, so that one may study it without leaving the page:

    svg.selectAll("text")
      .data(randomLetters(), d => d)
      .join(
        enter => enter.append("text")
            .attr("fill", "green")
            .attr("x", (d, i) => i * 16)
            .attr("y", -30)
            .text(d => d)
          .call(enter => enter.transition(t)
            .attr("y", 0)),
        update => update
            .attr("fill", "black")
            .attr("y", 0)
          .call(update => update.transition(t)
            .attr("x", (d, i) => i * 16)),
        exit => exit
            .attr("fill", "brown")
          .call(exit => exit.transition(t)
            .attr("y", 30)
            .remove())
      );

For what it's worth, I personally find this to be a most useful reference that I look to repeatedly. It would be great to skip the steps of clicking through to the Observable notebook, and scrolling down that page to search for this snippet. Thanks!

curran added a commit to curran/d3-selection that referenced this issue May 24, 2021
@mbostock
Copy link
Member

mbostock commented Jun 7, 2021

This is covered by #284, so closing.

@mbostock mbostock closed this as completed Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants