ICEN UI 饼图
Docs ⌘K
Beta · 演进中

饼图

环形分割图:多段占比 + 图例百分比。

Preview
图表 chart-pie

工时分布(环形)

html
<div class="chart-grid">  <div>    <p class="chart-cap">工时分布(环形)</p>    <div class="icen-chart" id="pie-demo"></div>  </div></div>

特性

接口

导出
renderDonut 共享行为模块,清单含族内导出
事件
icen:chart-legend-toggleicen:chart-legend-visibilityicen:chart-zoom detail 契约见 IcenEventMap;共享行为模块,清单含族内事件
类型
dist/behaviors/charts.d.mts(随 npm 包发布,含全部 JSDoc 约束)

安装

bun add @icen.ai/ui

一行引入该组件(CSS 与 behavior 自动带上,无需关心内部 CSS 文件名):

js
import '@icen.ai/ui/kit/chart-pie';

也可以用脚手架直接打印引入行:

bash
bunx --bun @icen.ai/ui add chart-pie

Astro 项目注意:kit 入口里的 CSS import 在页面 <script> 里会被 Astro 的 client bundle 摇掉——请改在布局 frontmatter 里引 CSS(import '@icen.ai/ui/components/chart-pie.css';),JS 行为仍可走 kit。Vite SPA / webpack 项目无此问题。

用法

js
import { renderDonut } from '@icen.ai/ui/kit/chart-pie';renderDonut(el, {  segments: [    { label: '研发', value: 48 },    { label: '设计', value: 32, tone: 'success' },    { label: '测试', value: 20, tone: 'warning' },  ],});