Skip to content
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

Undesirable padding behaviour with disparately sized children #175

Open
russss opened this issue Oct 17, 2020 · 3 comments
Open

Undesirable padding behaviour with disparately sized children #175

russss opened this issue Oct 17, 2020 · 3 comments

Comments

@russss
Copy link

russss commented Oct 17, 2020

I'm fairly new to d3, so forgive me if I'm wildly wrong here...

I've got a treemap which looks like this:

image

Note that the brown category at the bottom right is quite small compared to all the others.

I'd like to add 25px of paddingTop so that I can add titles to these categories, but when I do so, the brown category is unfortunately squashed to 1px high:

image

I don't entirely understand what's going on here, but it looks like the layout algorithm (I'm using the default in this case, but others are similarly bad) is stealing the same constant amount of padding space from each child, when I guess it should be proportionally taken from (in this case) all of the children in the same vertical column.

@ianstormtaylor
Copy link

ianstormtaylor commented May 5, 2021

Running in to this as well, I assumed the padding would be aware enough to not distort the resulting data. Seems like all the Treemap examples on Observable suffer from this?

Looks like this was brought up in #19 and #20 but forgotten.

@mshd
Copy link

mshd commented Oct 24, 2021

@Santas
Copy link

Santas commented Nov 22, 2022

A two-pass approach might be an acceptable if imperfect solution: compute the layout without padding, compute the area lost to padding for each cell, add this to the value for the cell, and then recompute the layout.

We do something similar to what @mbostock suggested in #19. We call treemap twice and hack around the issue by reordering some nodes to better fit which is not ideal, but works for our use case as a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants