-
Notifications
You must be signed in to change notification settings - Fork 315
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
d3.stratifyDot? d3.stratifySlash? #75
Comments
They should be immutable, of course: var stratifyDot = d3.stratify().parentId(d => d.id.substring(0, d.id.lastIndexOf("."))),
stratifySlash = d3.stratify().parentId(d => d.id.substring(0, d.id.lastIndexOf("/")));
d3.stratifyDot = function(data) {
return stratifyDot(data);
};
d3.stratifySlash = function(data) {
return stratifySlash(data);
}; |
Or with implied parents (#33): var stratifyDot = d3.stratify().ancestorId(id => id.substring(0, id.lastIndexOf("."))),
stratifySlash = d3.stratify().ancestorId(id => id.substring(0, id.lastIndexOf("/")));
d3.stratifyDot = function(data) {
return stratifyDot(data);
};
d3.stratifySlash = function(data) {
return stratifySlash(data);
}; |
So, it might be nice if it’s configurable, since you could have datum.path rather than datum.id (e.g., the D3 source treemap’s d3.csv). In that case, you might want to do something like this: var root = d3.stratifySlash().id(d => d.path)(data); Though perhaps it could be an optional accessor, like d3-array methods: var root = d3.stratifySlash(data, d => d.path); Either way it’s certainly simpler than: var root = d3.stratify()
.id(d => d.path)
.parentId(d => d.path.substring(0, d.path.lastIndexOf("/")))
(data); |
Hi @mbostock. This is a really cool module. Wondering if you'd consider having the delimiter be specifiable? Something like |
It'd also be useful to pass in arrays -- e.g. for a taxonomic tree where the leaf nodes (species) have groupings at various levels, that data could be passed in array form as Stratify is essentially creating a hierarchy using an array of items to group or classify the data—in the cases mentioned above, the array items are separated by dots or by slashes—so (to me) it makes more sense to have the most generic form, the array, and allow users to specify separators such as |
Those other approaches are all possible using d3.stratify directly as the general solution. If we generalize “d3.stratifySlash” too much the it won’t be more useful than the existing d3.stratify. |
I feel this is mostly addressed by the new stratify.path #185. That could be extended to take a different delimiter, but you can also remap the input to use slashes, too (just be careful about escaping). |
It’d be nice to have this convenience method for dot-separated ids such as Java class names:
Similarly for path names?
The text was updated successfully, but these errors were encountered: