生态产品多个设计器现已发布候选版本

查看生态总览
跳转到内容

HierarchyChart 层级图 new ​

看层级数据中各部分的占比,并逐层下钻。同一个组件用四种方式铺满空间:矩形树图、旭日图、冰柱图与圆堆积图。

用法 ​

缺省画成矩形树图:面积与数值成正比,第一层分支各取一个颜色;点一个部门下钻,路径回到上层

全年预算(万元)

全年预算: 5 items, total 2,380. Largest: 研发 950 (39.9%).

Data table
PathValueShare of parent
研发95039.9%
研发 / 平台42044.2%
研发 / 移动端26027.4%
研发 / 数据18018.9%
研发 / 测试909.5%
销售63026.5%
销售 / 华东24038.1%
销售 / 华南18028.6%
销售 / 华北15023.8%
销售 / 西部609.5%
市场49020.6%
市场 / 品牌21042.9%
市场 / 渠道16032.7%
市场 / 活动12024.5%
运营1908.0%
运营 / 客服11057.9%
运营 / 内容8042.1%
行政1205.0%
行政 / 办公7058.3%
行政 / 人事5041.7%

组件结构 ​

加粗的是必需部件。

data-scope="hierarchy-chart":root · caption · path · path-item · legend · legend-scale · legend-scale-name · legend-scale-bar · legend-scale-value · viewport · plot · node · node-label · group-header · focus-ring · tooltip · tooltip-header · tooltip-row · tooltip-swatch · tooltip-value · tooltip-name · empty · summary · table-region · table

示例 ​

旭日图 ​

layout="sunburst" 从中间往外一层一环,自 12 点顺时针;点中间的空洞上钻一层

全年预算(万元)

全年预算: 5 items, total 2,380. Largest: 研发 950 (39.9%).

Data table
PathValueShare of parent
研发95039.9%
研发 / 平台42044.2%
研发 / 移动端26027.4%
研发 / 数据18018.9%
研发 / 测试909.5%
销售63026.5%
销售 / 华东24038.1%
销售 / 华南18028.6%
销售 / 华北15023.8%
销售 / 西部609.5%
市场49020.6%
市场 / 品牌21042.9%
市场 / 渠道16032.7%
市场 / 活动12024.5%
运营1908.0%
运营 / 客服11057.9%
运营 / 内容8042.1%
行政1205.0%
行政 / 办公7058.3%
行政 / 人事5041.7%

冰柱图 ​

layout="icicle" 一层一条带,每一段的宽度就是它的占比,层级的深浅一眼看得出

全年预算(万元)

全年预算: 5 items, total 2,380. Largest: 研发 950 (39.9%).

Data table
PathValueShare of parent
研发95039.9%
研发 / 平台42044.2%
研发 / 移动端26027.4%
研发 / 数据18018.9%
研发 / 测试909.5%
销售63026.5%
销售 / 华东24038.1%
销售 / 华南18028.6%
销售 / 华北15023.8%
销售 / 西部609.5%
市场49020.6%
市场 / 品牌21042.9%
市场 / 渠道16032.7%
市场 / 活动12024.5%
运营1908.0%
运营 / 客服11057.9%
运营 / 内容8042.1%
行政1205.0%
行政 / 办公7058.3%
行政 / 人事5041.7%

圆堆积 ​

layout="pack" 用圆套圆:看层级的包含关系与大致的大小,不适合精确比较

全年预算(万元)

全年预算: 5 items, total 2,380. Largest: 研发 950 (39.9%).

Data table
PathValueShare of parent
研发95039.9%
研发 / 平台42044.2%
研发 / 移动端26027.4%
研发 / 数据18018.9%
研发 / 测试909.5%
销售63026.5%
销售 / 华东24038.1%
销售 / 华南18028.6%
销售 / 华北15023.8%
销售 / 西部609.5%
市场49020.6%
市场 / 品牌21042.9%
市场 / 渠道16032.7%
市场 / 活动12024.5%
运营1908.0%
运营 / 客服11057.9%
运营 / 内容8042.1%
行政1205.0%
行政 / 办公7058.3%
行政 / 人事5041.7%

扁平的行 ​

数据是一张表时写 idField 与 parentField,按父节点的身份组树

各部门人数

公司: 3 items, total 159. Largest: 研发中心 85 (53.5%).

Data table
PathValueShare of parent
研发中心8553.5%
研发中心 / 后端4249.4%
研发中心 / 前端2832.9%
研发中心 / 测试1517.6%
业务中心5836.5%
业务中心 / 销售3662.1%
业务中心 / 运营2237.9%
职能1610.1%
职能 / 人事956.3%
职能 / 财务743.8%

按值着色 ​

colorBy="value" 让颜色深浅对应数值,palette 换色相;图例每层一条色阶,translations.levelLabel 给各层起名

全年预算(万元)

全年预算: 5 items, total 2,380. Largest: 研发 950 (39.9%).

Data table
PathValueShare of parent
研发95039.9%
研发 / 平台42044.2%
研发 / 移动端26027.4%
研发 / 数据18018.9%
研发 / 测试909.5%
销售63026.5%
销售 / 华东24038.1%
销售 / 华南18028.6%
销售 / 华北15023.8%
销售 / 西部609.5%
市场49020.6%
市场 / 品牌21042.9%
市场 / 渠道16032.7%
市场 / 活动12024.5%
运营1908.0%
运营 / 客服11057.9%
运营 / 内容8042.1%
行政1205.0%
行政 / 办公7058.3%
行政 / 人事5041.7%

设计指引 ​

何时使用 ​

  • 数据天然是一棵树,读者要看的是「整体怎么切分」:预算按部门与项目、销售额按大区与城市、磁盘占用按目录。
  • 层级不止一层,读者需要从整体逐层钻到细处,再退回来。
  • 叶子多到饼图与条形图装不下,但每一块的相对大小仍然有意义。

何时不用 ​

  • 只有一层、类目不超过 6 个:用饼图,或者条形图更好比较。
  • 要比较几个相近的数:面积与角度都不如长度好比,改用直角坐标图的条形图。
  • 值有正有负:占比没有意义,层级图报错;改用条形图。
  • 关心的是流向而不是包含关系:用桑基图。

特性 ​

  • 数据有两种形状:嵌套的树(子节点在 childrenField 里,缺省 children),或扁平的行(写 idField 与 parentField,按父节点的身份组树)。扁平的行缺这两个字段、有多个根、父节点缺失或成环时报 chart.hierarchy-shape,根上写 data-state="error"。
  • 只取叶子的值(valueField,缺省 value),上层的值是子孙之和,上层行里写的值不计。值为负时报 chart.negative-share。兄弟按值从大到小排:矩形树图大的块铺在前面,旭日图自 12 点顺时针。
  • 节点的身份是 idField 的值;没有身份字段时是从最顶层往下的名字路径(华东/上海),同一个父节点下重名的兄弟后面加上次序。受控的 rootKey、activeKey 与数据引用的 seriesId 都是这个身份。
  • layout 决定空间怎么填:treemap(缺省)按 tile 铺矩形(squarify 缺省、binary、slice-dice),看得见子节点的分组顶部留一条标题;sunburst 从中间的空洞往外一层一环;icicle 一层一条带,orientation="horizontal" 时层自左而右;pack 用圆套圆,只看层级与相对大小。
  • depth(缺省 2)是同时看得见的层数。到了这个深度还有子节点的节点画成一整块,下钻才看得到里面。
  • 着色由 colorBy 决定:branch(缺省)按数据次序给第一层分支分配分类色 1–8,后代继承分支的颜色、按层向承载面混色变浅;第一层多于 8 个分支时报 chart.too-many-series,改用 value 或 uniform。value 按值取顺序色阶(palette 换色相),同一层里按最大值归一;uniform 全部用色槽 1,靠标签区分。
  • 按值着色时图例(部件 legend)给每个看得见的层一条色阶:名字、低端的值(0)、渐变条、高端的值(这一层的最大值)。颜色在同一层里各自归一,所以一层一条,同一种深浅在不同层代表的数不一样;只看得见一层时色阶的名字取 translations.valueLabel,多于一层时取 translations.levelLabel(层号)(缺省 Level 1、Level 2,层号从当前的根数起),务必按本地语言与数据的层级名改写。下钻、上钻后色阶跟着换。其余着色方式图例收起。
  • 标签先量再放:矩形树图的分组标题写在顶部的标题条里,放不下时截断;叶子与旭日、冰柱、圆堆积的节点名只在整段放得下时写,放不下的交给提示框与数据表。
  • 下钻:点有子节点的节点,或键盘聚焦后按 Enter,把它设为当前的根;点叶子报告按下(onDatumPress)。下钻路径(path)列出从最顶层到当前的根,点上层的项回到那一层;还在最顶层时路径收起。旭日图点中间的空洞上钻一层。rootKey / defaultRootKey / onRootKeyChange 让宿主受控或记住下钻的位置;api.drillTo(key) 与 api.drillUp() 供作者从外部下钻。
  • 悬停取指针下最深的节点:提示框的头部是从当前的根到这个节点的路径,下面是数值、占上一层与占总体;与它不在同一条祖孙链上的节点淡出到 --xh-chart-dim-alpha。
  • format 指定数值格式(数字格式或函数),标签、提示框、可及名与数据表共用。
  • pending 表示正在重新取数:保留上一帧、整体降低不透明度并在根上写 aria-busy。首次取数、手里还没有数据时,空态写 translations.loadingText 并转一个圈,取完仍没有数据才写 emptyText。
  • 首次出现时矩形淡入,旭日的扇区顺着扫开,圆堆积的圆从圆心长出,标签淡入,数据晚于挂载到达(异步取数,或 Web Components 连上之后才赋 data)时同样播这段入场。下钻与上钻从当前的画面插值到新画面:留下的节点从原位放大或缩回,新露出的节点出现、离开的淡出。animated={false}(Web Components 写 animated="false")关闭过渡;系统开了减弱动效或容器写了 data-motion="reduce" 时几何直接到位,只保留淡入淡出。
  • 三个适配器的作者侧写法不同,最终 DOM 一致:Vue 与 React 不写默认内容时铺开缺省结构(标题、下钻路径、图例、视口与绘图区、空态、提示框),提示框内容可由作用域插槽 / 函数式 children 替换;Web Components 侧作者写外壳(root、caption、path、viewport 与其中空的 <svg> plot,可选 legend、empty 与 tooltip),路径项、色阶、节点与提示框的缺省内容由元素生成进去。
  • Web Components 侧的数据与数值格式只走 JS property;字段名、布局、铺法、层数、着色、色板、方向与 root-key 另有同名属性。宿主元素缺省是行内元素,放进 flex / grid 时要给它一个宽度。

最佳实践 ​

  • 为图写标题:caption 是图的可访问名称,也要说明切分的是什么。
  • 第一层分支控制在 8 个以内;更多时把小的合并成「其他」,或者改用 colorBy="value"。
  • 缺省的两层通常就够:层数越多,每一块越小,标签越写不下;让读者下钻,而不是一次铺开。
  • 名字简短:标签只在整段放得下时显示,长名字多半只能靠提示框读到。
  • 需要读出准确数字时,在旁边放一张表格,或把 api.table 交给表格组件(Vue 与 React 从根的作用域插槽 / 函数式 children 取 table,Web Components 读元素的 table)。

反模式 ​

  • 用面积比较相近的值:面积差 10% 肉眼几乎看不出来。
  • 把没有包含关系的类目硬凑成一棵树:层级图的每一层都在说「这些加起来是上一层」。
  • 给每一层换一套颜色:颜色表示分支,换层就换色会让读者以为是不同的分支。
  • 用提示框作为读取数值的唯一途径:提示框对读屏隐藏,数值要能从可及名、摘要或数据表读到。

API 参考 ​

产物 ​

层值
自定义元素<xh-hierarchy-chart>
Vue 组件XhHierarchyChartCaption XhHierarchyChartEmpty XhHierarchyChartLegend XhHierarchyChartPath XhHierarchyChartPlot XhHierarchyChartRoot XhHierarchyChartTooltip XhHierarchyChartViewport
组合式函数useHierarchyChart
状态机hierarchyChartMachine
皮肤@xihan-ui/styles/hierarchy-chart.css

事件 ​

自定义元素将载荷放在 detail;Vue 使用同名 emit。

事件载荷说明
root-key-changeHierarchyRootKeyChangeDetails下钻或上钻换了根;detail 为 { rootKey },最顶层为 null
active-key-changeChartActiveKeyChangeDetails指针或键盘换了激活的节点;detail 为 { activeKey },收起时为 null
datum-activeChartDatumDetails悬停或聚焦到某个节点;detail 为节点详情,收起时为 null
datum-pressChartDatumDetails指针点击叶子、Enter 按在叶子上或 Space 按在节点上;detail 为节点详情

插槽 ​

仅列出带载荷的插槽。

Vue 组件插槽载荷说明
XhHierarchyChartRootdefaultHierarchyChartRootSlotProps自行摆放部件;不写时铺开缺省结构:下钻路径、视口(绘图区与空态)、提示框。
XhHierarchyChartRootcaption—缺省结构里的标题内容。
XhHierarchyChartRoottooltipHierarchyChartTooltipSlotProps缺省结构里的提示框内容。
XhHierarchyChartRootempty—缺省结构里的空态内容。
XhHierarchyChartTooltipdefaultHierarchyChartTooltipSlotProps

React 适配器 props ​

只列各组件自己声明的那些:继承自 ComponentPropsWithRef 的 DOM 属性不在其中,根组件上与上面 Props 表同名的也不重复列。Vue 的对应物是上面的插槽表。

React 组件属性类型必填说明
XhHierarchyChartRootdataChartRow | readonly ChartRow[]数据:嵌套的树,或扁平的行(配合 idField 与 parentField)。
XhHierarchyChartRootchildrenFieldstring嵌套数据的子节点字段,缺省 children。
XhHierarchyChartRootidFieldstring扁平数据:行的身份字段。
XhHierarchyChartRootparentFieldstring扁平数据:父节点的身份字段。
XhHierarchyChartRootnameFieldstring名字字段,缺省 name。
XhHierarchyChartRootvalueFieldstring数值字段,缺省 value:只取叶子的值。
XhHierarchyChartRootlayoutHierarchyLayout空间填充的方式,缺省 treemap。
XhHierarchyChartRoottileHierarchyTile矩形树图的铺法,缺省 squarify。
XhHierarchyChartRootdepthnumber同时看得见的层数,缺省 2。
XhHierarchyChartRootcolorByHierarchyColorBy着色,缺省 branch。
XhHierarchyChartRootpaletteChartPalette按值着色时顺序色阶的色板。
XhHierarchyChartRootorientation'vertical' | 'horizontal'冰柱图的方向,缺省 vertical。
XhHierarchyChartRootrootKeystring | null当前的根(受控):节点的身份,null 是最顶层。
XhHierarchyChartRootdefaultRootKeystring | null初始的根(非受控)。
XhHierarchyChartRootformatNumberFormatSpec | ((value: number) => string)数值格式。
XhHierarchyChartRootactiveKeyChartKey | null激活的键(受控):与别的图联动时是节点的身份。
XhHierarchyChartRootpendingboolean数据重取中:保留上一帧、整体降低不透明度。
XhHierarchyChartRootanimatedboolean播放过渡动画,缺省 true;false 时直接画终态。
XhHierarchyChartRootlocalestring
XhHierarchyChartRoottranslationsPartial<HierarchyChartTranslations>
XhHierarchyChartRootonRootKeyChangeHierarchyChartProps['onRootKeyChange']
XhHierarchyChartRootonActiveKeyChangeHierarchyChartProps['onActiveKeyChange']
XhHierarchyChartRootonDatumActiveHierarchyChartProps['onDatumActive']
XhHierarchyChartRootonDatumPressHierarchyChartProps['onDatumPress']
XhHierarchyChartRootcaptionReactNode缺省结构里的标题内容。
XhHierarchyChartRootrenderTooltip(props: HierarchyChartTooltipSlotProps) => ReactNode缺省结构里的提示框内容。
XhHierarchyChartRootemptyReactNode缺省结构里的空态内容。
XhHierarchyChartRootchildrenSlotChildren<HierarchyChartRootSlotProps>自行摆放部件;不写时铺开缺省结构:下钻路径、视口(绘图区与空态)、提示框。
XhHierarchyChartTooltipchildrenSlotChildren<HierarchyChartTooltipSlotProps>替换缺省内容;函数式 children 拿到激活的节点与缺省的内容模型。

状态 ​

公开状态写入 data-state。

部件取值
root'error' | undefined
tooltip'visible' | 'hidden'
empty'loading' | undefined

以下名称仅用于内部状态机。

状态:idle

事件:ROOT.SET

connect API ​

getXxxProps() 返回对应部件的宿主属性。

成员类型说明
modelHierarchyModel管线产物:树、布局、场景与无障碍模型。
sceneScene要画的场景;尚未测量时为空场景。
overlayHierarchyOverlay前景层:焦点环。
measuredboolean视口尚未测量(服务端与首帧)。
emptyboolean没有可画的节点。
pathreadonly HierarchyPathItem[]下钻路径:从最顶层到当前的根。
legendScalesreadonly HierarchyLegendScale[]按值着色时图例里的色阶,每个看得见的层一条;不按值着色时为空。
rootKeystring | null当前的根的身份;null 是最顶层。
activeChartDatumDetails | null激活的节点;没有时为 null。
tooltipHierarchyTooltipModel | null提示框内容;收起时为 null。
summarystring
tableTableModel数据表模型:全部节点,路径、数值与占上一层的比例。
emptyTextstring
tableCaptionstring
activeKeyChartKey | null
drillTo(key: string | null) => void下钻到某个节点(有子节点才下得去),null 回到最顶层。
drillUp() => void上钻一层。
setFocusedDatum(ref: { seriesId: string, index: number } | null) => void移动键盘锚点:只改锚点,不移动 DOM 焦点,也不派发回调。
markTag(mark: Mark) => HierarchyMarkTag
getRootProps() => T['element']
getCaptionProps() => T['element']
getPathProps() => T['element']
getPathItemProps(item: HierarchyPathItem) => T['button']
getLegendProps() => T['element']
getLegendScaleProps(scale: HierarchyLegendScale) => T['element']
getLegendScaleNameProps() => T['element']
getLegendScaleBarProps() => T['element']
getLegendScaleValueProps(edge: 'min' | 'max') => T['element']
getViewportProps() => T['element']
getPlotProps() => T['element']
getMarkProps(mark: Mark) => T['element']
getTooltipProps() => T['element']
getTooltipHeaderProps() => T['element']
getTooltipRowProps(row: HierarchyTooltipRow) => T['element']
getTooltipSwatchProps(row: HierarchyTooltipRow) => T['element']
getTooltipValueProps(row: HierarchyTooltipRow) => T['element']
getTooltipNameProps(row: HierarchyTooltipRow) => T['element']
getEmptyProps() => T['element']
getSummaryProps() => T['element']
getTableRegionProps() => T['element']数据表的视觉隐藏区域:块级、1px、裁掉,表格放在里面;隐藏不写在表格上,表格的高度收不住。
getTableProps() => T['element']

无障碍 ​

键盘 ​

规格出处:W3C APG

按键生效条件行为
Tab / Shift+Tab总是绘图区只占一个 Tab 位:焦点落到锚点节点,首次为第一层的第一个节点
ArrowRight焦点在绘图区同一层的下一个兄弟:矩形树图与圆堆积按阅读序,旭日图顺时针,冰柱图自左而右;已在最后一个则原地不动
ArrowLeft焦点在绘图区同一层的上一个兄弟
ArrowDown焦点在绘图区进入第一个子节点(看得见的层内)
ArrowUp焦点在绘图区回到父节点(看得见的层内)
Home焦点在绘图区同一层的第一个兄弟
End焦点在绘图区同一层的最后一个兄弟
Enter焦点在有子节点的节点下钻:把它设为根,焦点落到它的第一个子节点;在叶子上报告按下(onDatumPress)
Space焦点在绘图区报告聚焦的节点(onDatumPress)
Backspace已下钻上钻一层,焦点落回刚才的根
Escape提示框显示着收起提示框,焦点留在原处;按键不拦截,外层浮层的关闭仍归它自己

ARIA ​

以下属性由 connect 生成。

部件属性值
rootaria-busy'true' | undefined
patharia-labeltranslations.pathLabel
path-itemaria-current'location' | undefined
path-itemaria-disabled'true' | undefined
legendaria-hidden'true'
plotaria-describedbysummary 部件的 id
plotaria-roledescriptiontranslations.chartRoleDescription
plotrole'tree'
tooltiparia-hidden'true'
markaria-hidden'true'
  • 根是 <figure>,可访问名称来自 caption;不放标题时在根上写 aria-label 或 aria-labelledby。绘图区念同一个名字:有 caption 时引用它,没有时沿用根上的那一条。
  • 绘图区是 role="tree",角色说明取 translations.chartRoleDescription(缺省 tree chart:说明里留着「树」,读屏才知道能按方向键展开、收起,不要改成笼统的「图表」),aria-describedby 指向组件生成的摘要;每个看得见的节点是 role="treeitem",带 aria-level、aria-setsize 与 aria-posinset。有子节点的节点带 aria-expanded:子节点看得见时为 true,到了可见层数的底为 false,按 Enter 下钻才看得到。节点的名称取 translations.datumLabel(缺省「名字, 数值, 占比 of 上一层」),务必按本地语言改写。
  • 绘图区只占一个 Tab 位,焦点落在节点上:左右键在同一层的兄弟之间走(矩形树图与圆堆积按阅读序,旭日图顺时针,冰柱图按排列次序),下键进入第一个子节点,上键回到父节点,Home / End 到同一层的头尾。Enter 下钻、Backspace 上钻,焦点跟着落到新的一层。焦点环画在节点之外,只在键盘聚焦时出现。
  • 下钻路径是一组按钮(与面包屑的链接同一身份),当前的根写 aria-current="location"、不可按。
  • 标签与焦点环一律 aria-hidden;提示框同样 aria-hidden:它显示的内容与节点的名称是同一份。图例的色阶也 aria-hidden:每个节点的可及名与数据表里都写着它的值。
  • 组件在根内生成一段摘要与一张数据表,视觉隐藏、对读屏可见:摘要写当前的根、下面一层的项数、合计与最大的一项(模板是 translations.summary);数据表列出整棵树,首列是路径(列名取 translations.nameLabel),其余两列是数值与占上一层的比例。
  • 颜色不是区分分支的唯一线索:路径、标签、提示框与可及名都写出名字。
  • 过渡只改画面:节点的名称、摘要与数据表在数据或根变化的那一刻就更新;收场中的节点 aria-hidden、不可聚焦。

样式参考 ​

皮肤 ​

@xihan-ui/styles/hierarchy-chart.css 按 [data-scope="hierarchy-chart"][data-part="root"] 部件选择器书写,发布产物以挂载类 .xh-scope-hierarchy-chart 代替其中的 data-scope(特异性相同),位于 xihan.components 层。覆盖样式使用 xihan.overrides,部件选择器照常可用。

forced-colors: active 下另有一套规则:颜色交给系统,边框与状态标记改用系统色关键字。

数据属性 ​

由 connect 生成;条件不成立时不输出无值属性。

部件属性值
rootdata-loading''(条件成立时才出现)
rootdata-paletteprops.palette | undefined
rootdata-state'error' | undefined
rootdata-xh-chart-part'root'
captiondata-xh-chart-part'caption'
path-itemdata-current''(条件成立时才出现)
path-itemdata-pressed''(条件成立时才出现)
path-itemdata-xh-collection-context'nav'
path-itemdata-xh-collection-item''
path-itemdata-xh-collection-size'sm'
path-itemdata-xh-collection-terminal''(条件成立时才出现)
legenddata-xh-chart-part'legend'
legend-scaledata-levelscale.level
legend-scale-valuedata-edgeedge
viewportdata-xh-chart-part'viewport'
plotdata-xh-chart-part'plot'
tooltipdata-placement'top' | 'bottom'-'right' | 'left' | undefined
tooltipdata-state'visible' | 'hidden'
tooltipdata-xh-chart-part'tooltip'
tooltip-headerdata-xh-chart-part'tooltip-header'
tooltip-rowdata-xh-chart-part'tooltip-row'
tooltip-swatchdata-xh-chart-part'tooltip-swatch'
tooltip-valuedata-xh-chart-part'tooltip-value'
tooltip-namedata-xh-chart-part'tooltip-name'
emptydata-loading''(条件成立时才出现)
emptydata-state'loading' | undefined
emptydata-xh-chart-part'empty'
emptydata-xh-loading-ring''
markdata-dimmed''(条件成立时才出现)
markdata-levelString(Math.min(geometry.level, 4)) | undefined
markdata-xh-chart-partmark.part | undefined

CSS 变量 ​

本组件公开覆盖槽由独立皮肤的实际消费位生成;默认来源、作用部件和状态均与 CSS 同源。

变量部件CSS 属性状态默认来源说明
--xh-hierarchy-chart-empty-gapemptygapstate=loading--xh-space-2hierarchy-chart 的 empty 部件 gap 覆盖槽。
--xh-hierarchy-chart-gaprootgapdefault--xh-space-3hierarchy-chart 的 root 部件 gap 覆盖槽。
--xh-hierarchy-chart-heightviewportblock-sizedefault--xh-chart-heighthierarchy-chart 的 viewport 部件 block-size 覆盖槽。
--xh-hierarchy-chart-icon-sizeroot--xh-icon-sizedefault--xh-glyph-size-smhierarchy-chart 的 root 部件 --xh-icon-size 覆盖槽。
--xh-hierarchy-chart-legend-gaplegendgapdefault--xh-space-4hierarchy-chart 的 legend 部件 gap 覆盖槽。
--xh-hierarchy-chart-legend-scale-bar-radiuslegend-scale-barborder-radiusdefault--xh-shape-insethierarchy-chart 的 legend-scale-bar 部件 border-radius 覆盖槽。
--xh-hierarchy-chart-legend-scale-gaplegend-scalegapdefault--xh-space-2hierarchy-chart 的 legend-scale 部件 gap 覆盖槽。
--xh-hierarchy-chart-legend-scale-widthlegend-scale-barinline-sizedefault--xh-chart-legend-scale-widthhierarchy-chart 的 legend-scale-bar 部件 inline-size 覆盖槽。
--xh-hierarchy-chart-node-gaproot--xh-_chart-metric-gapdefault--xh-chart-gaphierarchy-chart 的 root 部件 --xh-_chart-metric-gap 覆盖槽。
--xh-hierarchy-chart-node-radiusroot--xh-_chart-metric-radiusdefault--xh-shape-insethierarchy-chart 的 root 部件 --xh-_chart-metric-radius 覆盖槽。
--xh-hierarchy-chart-path-column-gappathcolumn-gapdefault--xh-icon-sizehierarchy-chart 的 path 部件 column-gap 覆盖槽。
--xh-hierarchy-chart-path-fgpath-itemcolordefault
xh-collection-context=nav
--xh-fg-mutedhierarchy-chart 的 path-item 部件 color 覆盖槽。
--xh-hierarchy-chart-path-font-sizepath
path-item
font-sizedefault--xh-control-font-smhierarchy-chart 的 path、path-item 部件 font-size 覆盖槽。
--xh-hierarchy-chart-path-item-bg-hoverpath-itembackground-colordisabled
error
hover
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
xh-collection-context=nav
--xh-bg-subtlehierarchy-chart 的 path-item 部件 background-color 覆盖槽。
--xh-hierarchy-chart-path-item-bg-pressedpath-itembackground-colordisabled
error
is(:active, [data-pressed])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
pressed
xh-collection-context=nav
--xh-bg-subtle-hoverhierarchy-chart 的 path-item 部件 background-color 覆盖槽。
--xh-hierarchy-chart-path-item-fg-currentpath-itemcolorcurrent
xh-collection-context=nav
xh-collection-terminal
--xh-fg-defaulthierarchy-chart 的 path-item 部件 color 覆盖槽。
--xh-hierarchy-chart-path-item-fg-hoverpath-itemcolordisabled
error
hover
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
xh-collection-context=nav
--xh-fg-defaulthierarchy-chart 的 path-item 部件 color 覆盖槽。
--xh-hierarchy-chart-path-item-font-weight-currentpath-itemfont-weightcurrent
xh-collection-context=nav
xh-collection-terminal
--xh-font-weight-mediumhierarchy-chart 的 path-item 部件 font-weight 覆盖槽。
--xh-hierarchy-chart-path-item-pxpath-itempadding-inlinedefault--xh-space-1hierarchy-chart 的 path-item 部件 padding-inline 覆盖槽。
--xh-hierarchy-chart-path-item-radiuspath-itemborder-radiusdefault--xh-shape-controlhierarchy-chart 的 path-item 部件 border-radius 覆盖槽。
--xh-hierarchy-chart-path-row-gappathrow-gapdefault--xh-space-1hierarchy-chart 的 path 部件 row-gap 覆盖槽。
--xh-hierarchy-chart-path-separator-fgpath-itembackground-colordefault--xh-fg-subtlehierarchy-chart 的 path-item 部件 background-color 覆盖槽。
--xh-hierarchy-chart-series-colorlegend-swatch
node
pattern-line
tooltip-swatch
background
border
fill
stroke
@media (forced-colors: active)
@media print
mark=line
where([data-xh-chart-patterns])
xh-chart-pattern
xh-chart-pattern=1
xh-chart-pattern=2
xh-chart-pattern=3
xh-chart-pattern=4
xh-chart-pattern=5
xh-chart-pattern=6
xh-chart-pattern=7
xh-chart-pattern=8
xh-chart-patterns
xh-chart-slot=1
xh-chart-slot=2
xh-chart-slot=3
xh-chart-slot=4
xh-chart-slot=5
xh-chart-slot=6
xh-chart-slot=7
xh-chart-slot=8
--xh-chart-categorical-1
--xh-chart-categorical-2
--xh-chart-categorical-3
--xh-chart-categorical-4
--xh-chart-categorical-5
--xh-chart-categorical-6
--xh-chart-categorical-7
--xh-chart-categorical-8
hierarchy-chart 的 legend-swatch、node、pattern-line、tooltip-swatch 部件 background、border、fill、stroke 覆盖槽。
--xh-hierarchy-chart-tooltip-gaptooltipgapdefault--xh-space-1hierarchy-chart 的 tooltip 部件 gap 覆盖槽。
--xh-hierarchy-chart-tooltip-pxtooltippadding-inlinedefault--xh-surface-pad-smhierarchy-chart 的 tooltip 部件 padding-inline 覆盖槽。
--xh-hierarchy-chart-tooltip-pytooltippadding-blockdefault--xh-surface-pad-smhierarchy-chart 的 tooltip 部件 padding-block 覆盖槽。
--xh-hierarchy-chart-tooltip-radiustooltipborder-radiusdefault--xh-shape-overlayhierarchy-chart 的 tooltip 部件 border-radius 覆盖槽。
--xh-hierarchy-chart-tooltip-row-gaptooltip-rowgapdefault--xh-space-2hierarchy-chart 的 tooltip-row 部件 gap 覆盖槽。
--xh-hierarchy-chart-tooltip-shadowtooltipbox-shadowdefault--xh-material-frosted-shadowhierarchy-chart 的 tooltip 部件 box-shadow 覆盖槽。
--xh-hierarchy-chart-tooltip-swatch-radiustooltip-swatchborder-radiusdefault--xh-shape-insethierarchy-chart 的 tooltip-swatch 部件 border-radius 覆盖槽。

动效 ​

动效角色:按压 · 状态 · 出现(见动效规范)。

共享关键帧 xh-fade-in 由 family/motion.css 提供,皮肤 @import 它,单独引入仍成立;opacity 走 transition 过渡。时长与缓动读动效令牌,改令牌即改全局节奏。

系统开启减弱动效时由令牌层统一收敛,皮肤不另作判断。

RTL ​

皮肤用逻辑属性排布(inline-start 一族),dir="rtl" 下自动镜像;只认物理方向的量乘 --xh-direction-sign 换向,按就近的 dir 走;另有按 dir 分支的规则。

  • 绘图区不随文字方向镜像:矩形树图的铺法、旭日图的顺时针与冰柱图的方向都不变,右键始终是阅读序或顺时针的下一个。
  • 下钻路径、标题与提示框的内容随文字方向排列。

Released under The MIT License