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

stratify.path #185

Merged
merged 7 commits into from
Dec 4, 2021
Merged

stratify.path #185

merged 7 commits into from
Dec 4, 2021

Conversation

mbostock
Copy link
Member

This new d3.stratify feature imputes internal nodes using the specified path function, which returns slash-separated ids (as per a typical UNIX-y file system). Alternative to #184. Fixes #33.

@mbostock mbostock requested a review from Fil October 24, 2021 19:58
@mbostock mbostock mentioned this pull request Oct 24, 2021
@mbostock
Copy link
Member Author

mbostock commented Oct 24, 2021

Demo here: https://observablehq.com/d/067a15f32eee749a

I think d3.stratify should not impute a root node "/" if there is only one explicit root (e.g., "/flare"). Update: done.

Copy link
Member

@Fil Fil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some documentation.

Would it make sense to accept the path being returned as an array?
with data = [{path: "a,b,c,d,e,f"}, ...], we could say d3.stratify().path(d => d.path.split(","))(data)

this would avoid massaging a string and having to escape existing slashes in the identifiers.

@mbostock
Copy link
Member Author

mbostock commented Nov 5, 2021

Would it make sense to accept the path being returned as an array?

Maybe. At the least if we don’t, we should allow escaping of backslashes…

I can try to do the array-based approach. I think we’ll still need some normalization so that "/foo/bar".split("/") and "foo/bar".split("/") are considered equivalent.

@mbostock mbostock requested a review from Fil November 5, 2021 18:04
Copy link
Member

@Fil Fil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!

@mbostock mbostock merged commit 6498cc7 into main Dec 4, 2021
@mbostock mbostock deleted the mbostock/stratify-path-alt branch December 4, 2021 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Stratify could infer implied parent nodes?
2 participants