Skip to content

饼图与环图 Pie

效果

在线预览
在线模拟尺寸:

基本饼图

typescript
{
  data: [
    { name: '直接访问', value: 335 },
    { name: '邮件营销', value: 310 },
    { name: '联盟广告', value: 234 },
    { name: '搜索引擎', value: 580 }
  ],
  series: [{
    type: 'pie',
    colorField: 'name',
    angleField: 'value'
  }]
}

环形图

设置 pieInnerRadius 大于 0 即为环形图。

typescript
series: [{
  type: 'pie',
  colorField: 'name',
  angleField: 'value',
  pieInnerRadius: 50    // 内半径(px)
}]

环形图中心文字

typescript
series: [{
  type: 'pie',
  colorField: 'name',
  angleField: 'value',
  pieInnerRadius: 60,
  pieCenterText: '总计',
  pieCenterSubText: '1459'
}]

进度环

数据只有一条且 pieInnerRadius > 0 时自动切换为进度环模式。

typescript
{
  data: [{ progress: 75 }],
  series: [{
    type: 'pie',
    angleField: 'progress',
    pieInnerRadius: 40,
    color: '#3b82f6',
    pieRoundCap: true     // 端点圆角
  }]
}

玫瑰图

typescript
series: [{
  type: 'pie',
  colorField: 'name',
  angleField: 'value',
  pieRoseType: 'radius'   // 'radius'(半径按值) 或 'area'(面积按值)
}]

扇区间隙与圆角

typescript
series: [{
  type: 'pie',
  colorField: 'name',
  angleField: 'value',
  pieInnerRadius: 40,
  pieGap: 3,            // 扇区间隙角度
  pieRoundCap: true     // 端头圆角(需 innerRadius > 0 且 pieGap > 0)
}]

嵌套环图

多个 pie 系列,通过 pieOuterRadiuspieInnerRadius 控制各层半径。

typescript
series: [
  { type: 'pie', colorField: 'name', angleField: 'value', pieInnerRadius: 60, pieOuterRadius: 80 },
  { type: 'pie', colorField: 'name', angleField: 'count', pieInnerRadius: 85, pieOuterRadius: 110 }
]

系列配置项

属性类型默认值说明
typestring-固定 'pie'
colorFieldstring-分类字段(也可用 xField)
angleFieldstring-数值字段(也可用 yField)
colorstring自动指定颜色(进度环时)
pieInnerRadiusnumber0内半径,>0 为环形图
pieRadiusScalenumber0.9外半径占比 0.4~1
pieOuterRadiusnumber0外半径像素值(优先于 pieRadiusScale)
pieCenterTextstring''中心主文字
pieCenterSubTextstring''中心副标题
pieGapnumber0扇区间隙角度
pieRoundCapbooleanfalse端头圆角
pieRoseTypestring''玫瑰图模式 'radius' / 'area'
labelChartLabelOptions-标签配置
最近更新