d3 / d3-selection

Transform the DOM by selecting elements and joining to data.

Home Page:https://d3js.org/d3-selection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible issue with exit() selection and .data() key function

bobOnGitHub opened this issue · comments

D3 doesn't appear to identify data as new / removed on the basis of the key function (alone) as supplied to the .data() function.

I've already documented it here ;
https://stackoverflow.com/q/54814079/4779501

but thought I might have more luck posting here .

Sounds like you figured it out—you were mutating the data, thus changing the computed key of the previously-bound data. Keys are not stored on elements, but recomputed with whatever key function you pass to selection.data on the old data.

Please use Stack Overflow tag d3.js to ask for help. Stack Overflow provides a better collaborative forum: thousands of D3-related questions have been asked there, and some answers may be relevant to you.

When asking for help, please include a link to demonstrate the issue, preferably as an Observable notebook. It is often impossible to debug from code snippets alone. Isolate the issue and reduce your code as much as possible before asking for help. The less code you post, the easier it is for someone to debug, and the more likely you are to get a helpful response.

If you have a question about D3’s behavior and want to discuss it with other users, also consider the d3-js Google Group or joining the d3-js Slack.

Thank you! 🤗

Thanks for the quick response and the clarification (Keys are not stored on elements).

Had a few more questions but all resolved now ( documented in comments on the stack overflow question )