d3 / d3-hierarchy

2D layout algorithms for visualizing hierarchical data.
https://d3js.org/d3-hierarchy
ISC License
1.13k stars 315 forks source link

stratify.path #185

Closed mbostock closed 2 years ago

mbostock commented 2 years ago

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 commented 2 years ago

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.

mbostock commented 2 years ago

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.