GithubHelp home page GithubHelp logo

Comments (5)

mbostock avatar mbostock commented on April 18, 2024

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.

nyurik avatar nyurik commented on April 18, 2024

@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.

mbostock avatar mbostock commented on April 18, 2024

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.

nyurik avatar nyurik commented on April 18, 2024

@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.

nyurik avatar nyurik commented on April 18, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.