Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This helper for d3.stratify imputes internal nodes using the specified path function, which returns slash-separated ids (as per a typical UNIX-y file system). Fixes #33.
Now that JavaScript has all sorts of niceties for destructuring and optional arguments, I’d also like to start moving away from the D3 “getter-setter” pattern in favor of options objects. For example, instead of:
You’d say:
This allows D3 classes to favor immutability, and makes it easier to share options via the spread operator, too. I’ve done that internally here for d3.stratify, but the new option-based API is not exposed externally. I figure we can explore changing the internal API first, although I’m happy to revert this part if you think it’s too aggressive.
I originally thought about this being a path option for d3.stratify, but it’s a little awkward since if you specify the path option, it’ll ignore the id and parentId, so I thought maybe it would be better to separate the two. That said I might try a variant of this PR that is more minimal.