Skip to content

Add padding and gap props to Treemap #7043

Description

@MaximSrour

Is your feature request related to a problem? Please describe.
Treemap currently renders child nodes directly on top of parent geometry and sibling nodes, making it difficult to see the association between them without an excellent colour palette. This makes dense hierarchical data harder to read and limits visual separation compared to other charts that expose spacing controls (e.g., paddingAngle in Pie, nodePadding in Sankey, barGap/barCategoryGap in bar-based charts).

Describe the solution you'd like
Add Treemap spacing props:

  • nodePadding?: number
    Insets the layout area used for a node’s children.
  • nodeGap?: number
    Adds spacing between sibling nodes at the same depth.

Expected behavior:

  • Defaults preserve current rendering (0 for both).
  • Works in both type="flat" and type="nest".
  • Included in docs/story examples and typed API.

Describe alternatives you've considered

  • Using custom rendering to visually fake spacing.
    Drawback: does not affect actual layout geometry/hit areas. It also doesn't work so well since it isn't possible (or practical) to simulate the whole rendering pipeline to get the correct size of gaps and padding on each node at all depths.

Example attached of the custom junk I managed to produce. You can clearly see the difference in gap between different levels.

Image

Additional context
I do actually have a branch for this ready to go, so I will open a PR and link it to this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions