Comments (5)
Thanks for the suggestion and pull request. However, I don’t understand why it is useful to allow these names to be specified by the caller (other than the linked Vega issue, which seems to be a Vega feature request rather than an issue with d3.nest’s API), especially given that the caller could map the return value of nest.entries if different names are desired.
from d3-collection.
@mbostock nest() mixes together user's data and the generated data in the output. If input data already contains key
or values
fields, and I had to analyze the output, it might be more difficult to tell apart original vs generated.
How about a different implementation: a factory(key, values)
that gets called by nest to create new elements? By default it will be (key, values) => ({ key, values })
, but user would be able to supply a different implementation?
from d3-collection.
nest.entries returns a nested structure dictated by how many keys you define using nest.key; there is no ambiguity or mixing of input data fields with the {key, values} entries.
from d3-collection.
@mbostock understood. Would my alternative idea work though? Because there could be a lot of cases when you want to customize the creation of the new nodes?
from d3-collection.
@mbostock here's a PR for a more generic approach - a factory method to customize new node creation. With this approach, users won't need to do complex post-processing iteration of the whole tree if they need to calculate sub-aggregations on the portion of the tree, or if they want to attach additional values to each node. What's more, they might not even want to construct the result tree at all - making nest() into an iteration system instead of an object generation. #27
from d3-collection.
Related Issues (19)
- Fix prototype.constructor.
- d3.map could take an optional value accessor function? HOT 1
- ES6 Collections. HOT 2
- d3.group convenience function? HOT 3
- Support natural sorting of keys. HOT 5
- sortValues after rollup HOT 2
- Feature request HOT 1
- value/values on rollup function HOT 2
- d3.nest reformats a Date object to a string HOT 1
- Nest: individual key sorting HOT 1
- es6 import syntax example? HOT 4
- d3.nest retains node properties after rollup HOT 4
- Feature Request - same level nesting by multiple key HOT 1
- Why does d3.nest.map prepend a prefix? HOT 4
- nest.rollup should create {key, value} for leaf entries. HOT 9
- Add nest.count or nest.visit? HOT 1
- Mutable nests? HOT 1
- Support string as accessor? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-collection.