百度echarts如何在legend中显示数字百分比

1018 ℃

百度echarts如何在legend中显示数字和百分比,下面web建站小编给大家简单介绍一下具体代码!

实现代码如下:

legend: {
  type: 'plain',
  orient: 'vertical',
  left: '65%',
  top: 'center',
  align: 'left',
  itemGap: 6,
  itemWidth: 12,
  itemHeight: 12,
  icon: 'circle',
  symbolKeepAspect: false,
  formatter: function (name) {
    let data = option.series[0].data
    let total = 0
    let tarValue
    for (let i = 0; i < data.length; i++) {
      total += data[i].value
      if (data[i].name == name) {
        tarValue = data[i].value
      }
    }
    let v = tarValue + '人'
    let p = Math.round((tarValue / total) * 100) + '%'  
    return `${name}  ${v}  ${p}`
  },
}

百度echarts雷达图radar根据分数点显示每个不同颜色

百度ECharts文档官网介绍

百度echarts柱状图设置不同颜色(每根柱子一种颜色)

百度echarts图表数据为空如何展示"暂无数据"

百度echarts柱状图/折线图x轴显示全部文本(太长自动换行)

标签: legend, 百度echarts

上面是“百度echarts如何在legend中显示数字百分比”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。

当前网址:https://m.ipkd.cn/webs_3705.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

织梦DedeCMS定时自动生成首页HTML的实现方法
Hexo插件的基本用法(Hexo安装)
wordpress如何获取当前分类的顶级id
为什么你在网上赚不到钱?你具备哪些能力
js数组转换,把第三层数组遍历到第二层,根据名