GithubHelp home page GithubHelp logo

Comments (8)

jheer avatar jheer commented on April 20, 2024 1

šŸŽ‰

from d3-hierarchy.

mbostock avatar mbostock commented on April 20, 2024

This is the expected behavior, but I agree it should at least be better documented. If you donā€™t want a stable update, you can use root.copy to create a fresh hierarchy and pass that to the treemap.

from d3-hierarchy.

mbostock avatar mbostock commented on April 20, 2024

Some possible API improvements:

  1. Make the cached layout (_squarify) specific to the aspect ratio, such that if the aspect ratio changes, a new layout is computed from scratch. This seems reasonable, although a little magical.
  2. Make opting out of the stable update more obvious, say d3.treemapSquarify.stable(false). I donā€™t know if this is significantly better than just improving the API documentation, however.
  3. Make opting in to the stable update explicit, say by exposing d3.treemapResquarify as a tiling algorithm (that requires the input to have been previously computed using d3.treemapResquarifyā€¦ or possibly d3.treemapSquarify?).
  4. Generalize stable updates to the treemap (#36), i.e., like the previous approach, you might use d3.treemapSquarify to compute the initial layout, and then d3.treemapStable to update that layout with new values. The stable update wouldnā€™t rely on hidden fields (_squarify); it would automatically determine topology of the previous layout and preserve it on update.

from d3-hierarchy.

jheer avatar jheer commented on April 20, 2024

Generalized stable updates sounds quite attractive! In that case, might the top-level treemap method accept a stable parameter to opt-in or opt-out of stable updates? (Not unlike sticky in D3 v3, but all the more reasonable if shared across tiling methods.) From the perspective of higher-level tools built on top of D3, it would be expedient to be able to parameterize the treemap once and have it behave appropriately, rather than swapping tiling methods around for the sake of stable layout.

One additional benefit might be some memory savings for very large trees. When stable === false the layout need not generate and cache partition decisions. However, one must consider the case when toggling the stable value. If toggled from false to true, should the layout cache the current layout or only future layout runs? I find the latter is reasonable (and simpler to implement).

from d3-hierarchy.

mbostock avatar mbostock commented on April 20, 2024

Iā€™ve implemented the third proposal in #46. Care to take a look?

For generalized stable update, I was imagining that youā€™d use d3.treemapStable to update an existing treemapā€™s layout, rather than needing to set tile.stable(true) on each tiling function. The problem with the latter approach is that it requires each tiling function to expose a stable parameter, and given that itā€™s easy for people to writing tiling functions outside the library, itā€™d be better to centralize the stable update logic.

I suppose another way to do it, though, would be to set treemap.stable(true), which could override the treemapā€™s tiling function (treemap.tile) and instead use treemapStable, which could then just be a private internal function. (Or it could still be publicā€¦ it doesnā€™t matter.) Though then youā€™d need some additional logic to detect whether a layout was previously computed, but that could potentially be as simple as checking whether node.x0 is defined.

Anyhow, a generalized stable update is still theoretical at this point. I took a brief crack at it previously and wasnā€™t successful, though I still think it should be possible.

The proposed implementation in #46 avoids saving the partition decisions if you use d3.treemapSquarify rather than d3.treemapResquarify. (Though the objects are created internally and then discarded to simplify the implementation. I could optimize that, I suppose, but itā€™d make the logic a bit more complicated.)

from d3-hierarchy.

jheer avatar jheer commented on April 20, 2024

Thanks! #46 is definitely an improvement, and a good working solution in the absence of generalized stable updates.

from d3-hierarchy.

mbostock avatar mbostock commented on April 20, 2024

Thanks for the feedback. Iā€™ll push a new patch release shortly.

from d3-hierarchy.

mbostock avatar mbostock commented on April 20, 2024

Released in 0.2.4.

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.