核心代码

    
        childOption.legend.formatter = (name) => {
            const itemValueArr = ChildSeruesData.filter(el => el.variable == name)
            const itemValueAll = ChildSeruesData.reduce((total, num) => {
                return total + Math.round(num.value);
            }, 0)
            return `${name}(${(itemValueArr[0].value / itemValueAll * 100).toFixed(2)}%)`
        }

效果

 

 echarts实现legend添加数据显示(百分比)功能

 

相关文章:

  • 2022-02-05
  • 2022-02-01
  • 2022-12-23
  • 2021-07-21
  • 2021-12-25
  • 2022-01-06
  • 2021-05-05
  • 2021-11-27
猜你喜欢
  • 2021-07-25
  • 2022-12-23
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2021-08-23
  • 2022-12-23
相关资源
相似解决方案