GithubHelp home page GithubHelp logo

Comments (3)

akre54 avatar akre54 commented on April 25, 2024 1

Thanks! I was just about to ask for this. (c.f. d3/d3#1518)

from d3-hierarchy.

mbostock avatar mbostock commented on April 25, 2024

It’s tempting to make this a configurable function:

var root = d3.hierarchy()
    .children(function(d) { return d.values; })
    (data);

This would allow us to specify a default value function and a default sort comparator. These could be disabled if you didn’t want them:

var root = d3.hierarchy()
    .value(null)
    .sort(null)
    (data);

However, I think it’s probably not a good idea to do this, and instead keep d3.hierarchy as minimal as possible. First, it avoids this awkward construct in the common case:

var root = d3.hierarchy()(data);

And second, we’ll still need node.sum and node.sort if we want to do in-place modifications of an existing hierarchy. Currently, calling node.sum is the only way to implement a stable update of a squarified treemap because it updates node.value without destroying node._squarify (the latter being where the tiling method stores the previously-computed layout). We could of course provide both, but that violates the principle of parsimony, as well as doing some unnecessary work by default (if you don’t want to sum values or sort siblings).

from d3-hierarchy.

mbostock avatar mbostock commented on April 25, 2024

Also, if we supported hierarchy.value and hierarchy.sort, we’d have to add similar methods to d3.stratify for consistency. That’s another reason to stick with node.sum and node.sort, which works with both.

from d3-hierarchy.

Related Issues (20)

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.