Charts

Treemap

Visualize hierarchical data as nested rectangles

Treemap displays hierarchical data as nested rectangles where the area of each rectangle is proportional to its value.

Simple Treemap

A basic treemap with nested data groups. Each group gets a distinct color from the colors palette.

Custom Content

Use the #content slot to fully customize how each node is rendered. The slot receives coordinates, dimensions, name, value, and fill color.

Nest Mode

Set type="nest" for interactive drill-down. Click a group to zoom into its children. A breadcrumb trail appears for navigating back.

Props

PropTypeDefaultDescription
dataArrayrequiredHierarchical data with optional children arrays
data-keyrow path or accessor'value'Field with the numeric value
name-keyrow path or accessor'name'Field with the node label
width / height / aspectnumberfills the parentSize. See chart size
initial-dimension{ width, height }{ width: 640, height: 360 }Size before the first measurement. See chart size
titlestring'Treemap'Accessible name of the chart
descstring—Accessible description of the chart
tile-aspect-rationumber4 / 3Target rectangle aspect ratio of the squarify layout
type'flat' | 'nest''flat'flat shows all leaves; nest enables drill-down
fillstringseries 1 tokenFill when colors is not set
strokestring'var(--v-charts-background, #fff)'Rectangle border color
colorsstring[]numbered series tokensPalette, one color per top-level group
is-animation-activebooleantrueAnimate entrance and data changes
transitionChartTransitionmotion tokensTiming and easing of data changes

Events

EventPayloadDescription
@node-click(node, index, event: MouseEvent | KeyboardEvent)A node is clicked, or Enter is pressed on the focused node
@node-mouseenter, @node-mouseleave(node, index, event: MouseEvent)The pointer enters or leaves a node; the tooltip follows
@animation-start, @animation-end()An animation starts or ends

node is a TreemapLayoutNode (an exported type). The chart pointer events (@click, @mousemove, …) are also available. See Events and v-model.

Slots

SlotPropsDescription
#content{ x, y, width, height, depth, name, value, payload, color, root, entryIndex, index, fill, stroke }Replace a node rectangle and its label
default—Place <Tooltip> or other child components here

Data structure

const data = [
  {
    name: 'Group A',
    children: [
      { name: 'Item 1', value: 100 },
      { name: 'Item 2', value: 200 },
    ],
  },
  {
    name: 'Group B',
    children: [
      { name: 'Item 3', value: 300 },
    ],
  },
]

Leaf nodes must have a numeric value (or whatever dataKey specifies). Parent nodes derive their value by summing all descendants.

Copyright © 2026