Comments (8)
š
from d3-hierarchy.
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.
Some possible API improvements:
- 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. - 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. - 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?). - 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.
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.
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.
Thanks! #46 is definitely an improvement, and a good working solution in the absence of generalized stable updates.
from d3-hierarchy.
Thanks for the feedback. Iāll push a new patch release shortly.
from d3-hierarchy.
Released in 0.2.4.
from d3-hierarchy.
Related Issues (20)
- Treemap leaf nodes with rect height = 0 HOT 1
- How can I handle the ts error "Type 'number | undefined' is not assignable to type 'number'." ? HOT 1
- IE11 issue - Const must be initialized in each.js HOT 1
- the json result convert to d3-hierarchy can not generate the correct format without children HOT 1
- tree layout: Support transparent intermediary nodes to keep the tree tidy HOT 3
- Undesirable padding behaviour with disparately sized children HOT 3
- node.sum/count for non-numeric data
- New nodesAtDepth(depth) function HOT 3
- d3 partition: ability to choose different "value" size variable
- document d3.Node
- Seemingly non-weird ball collection throws an error in d3.packEnclose() HOT 1
- Suggestion: pack() layouts with deterministic outputs HOT 5
- Inner and outer padding for partition layout
- How can you add new attributes to d3.heirarchy() object? HOT 1
- why non-negative for node.sum
- Using @ant-design/plots and this error is popping up
- d3.stratify().path() doesn't bind data HOT 1
- Stratify nodes that are both a leaf (with value) and a parent
- d3__WEBPACK_IMPORTED_MODULE_0__.hierarchy is not a function HOT 3
- d3__WEBPACK_IMPORTED_MODULE_0__.hierarchy is not a function HOT 4
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-hierarchy.