-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Squarify algorithm unresponsive to changed aspect ratio. #45
Comments
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. |
Some possible API improvements:
|
Generalized stable updates sounds quite attractive! In that case, might the top-level treemap method accept a One additional benefit might be some memory savings for very large trees. When |
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.) |
Thanks! #46 is definitely an improvement, and a good working solution in the absence of generalized stable updates. |
Thanks for the feedback. I’ll push a new patch release shortly. |
Released in 0.2.4. |
🎉 |
When a squarified layout is first calculated, partition decisions are cached on the tree nodes. If one then updates
treemap.tile
to use a squarified layout with a different target aspect ratio, this new ratio is effectively ignored in favor of the cached data. While stable layout is valuable in many situations, it is not always desired. In the case of assigning a new tiling method, my expectation was that this assignment would (by default) override any cached results. Perhaps the API could include a mechanism to make this determination user controllable.This issue affects changes to the
treemap.size
parameter as well. Sometimes one may want the treemap to re-partition on changes of width/height rather than stay stable.For now, it appears that the resolution is to either generate a new hierarchy instance or walk the existing hierarchy and clear out the
_squarify
caches.The text was updated successfully, but these errors were encountered: