logo

Ant Design Charts

  • Manual
  • Components
  • Examples
  • Options
  • Productsantv logo arrow
  • 2.0.0
  • Component Overview
  • Statistical Charts
    • Chart overview
    • Line
    • Column
    • Bar
    • Area
    • Pie
    • DualAxes
    • Scatter
    • WordCloud
    • Funnel
    • Heatmap
    • Histogram
    • Liquid
    • BidirectionalBar
    • Box
    • Bullet
    • CirclePacking
    • Gauge
    • Radar
    • Rose
    • Sankey
    • Stock
    • Sunburst
    • Treemap
    • Venn
    • Tiny
    • Violin
    • Waterfall
    • RadialBar
  • Relation Graph Components
    • Overview
    • MindMap
    • Fishbone
    • IndentedTree
    • Dendrogram
    • OrganizationChart
    • FlowGraph
    • FlowDirectionGraph
    • NetworkGraph
    • FAQ

Treemap

Previous
Sunburst
Next
Venn

Resources

Ant Design
Galacea Effects
Umi-React Application Framework
Dumi-Component doc generator
ahooks-React Hooks Library

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference

Help

GitHub
StackOverflow

more productsMore Productions

Ant DesignAnt Design-Enterprise UI design language
yuqueYuque-Knowledge creation and Sharing tool
EggEgg-Enterprise-class Node development framework
kitchenKitchen-Sketch Tool set
GalaceanGalacean-互动图形解决方案
xtechLiven Experience technology
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

矩阵树图根据每个节点的关联值递归地将空间划分为矩形,适用于展示带权的树形数据。 矩形树图适合展现具有层级关系的数据,能够直观体现同级之间的比较。一个 Tree 状结构转化为平面空间矩形的状态。矩形树图的好处在于,相比起传统的树形结构图,矩形树图能更有效得利用空间,并且拥有展示占比的功能。

开始使用

treemap

import { schemeTableau10 } from 'd3-scale-chromatic';
{
data: {
type: 'fetch',
value: 'https://assets.antv.antgroup.com/g2/flare-treemap.json',
},
valueField: 'size',
scale: {
color: {
range: schemeTableau10
}
},
layout: {
path: (d) => d.name.replace(/\./g, '/'),
tile: 'treemapBinary',
paddingInner: 1,
},
style: {
labelText: (d) =>
d.data.name
.split('.')
.pop()
.split(/(?=[A-Z][a-z])/g)[0],
labelFill: '#000',
labelPosition: 'top-left',
fillOpacity: 0.5
}
}

选项

属性描述类型默认值
layout布局配置TreemapLayout-
style配置图形样式和标签样式--
labels自定义数据标签的配置label[][]

layout

属性描述类型默认值
tile布局方式'treemapBinary' | 'treemapDice' | 'treemapSlice' | 'treemapSliceDice' | 'treemapSquarify' | 'treemapResquarify''treemapSquarify'
padding外间距,另外还有 paddingInner | paddingOuter | paddingTop | paddingBottom | paddingRight | paddingLeftnumber0
sort排序规则(a: any, b: any): number(a, b) => b.value - a.value
layer渲染层级number | (d) => number0

style

复合图形标记需要通过不同的前缀来区分图形的配置。

  • <label>: 数据标签的前缀,例如:labelText 设置标签的 text 文本。