legend: {
  formatter(name) {
    let total = 0; // 总数量
    let target; // 当前项的数据
    for (let item of dataList) {
      total += item.value;
      if (item.name === name) {
        target = item.value;
      }
    }
    let percent = ((target / total) * 100).toFixed(2); // 计算百分比
    return `${name}:${percent}%`;
  },
  // 其他配置...
}

By lxcss

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注