vue+echarts显示百分数功能

            const arr = res.data.data.list
            for (let item of arr) {
              var str = Number(item.getScoreRatio * 100).toFixed(2)
              item.getScoreRatio = parseFloat(str)
            }
            this.myChart.setOption({
              title: {
                text: this.planName1 + '结果展示'
              },
              tooltip: {
                formatter: function name(params) {
                  // console.log(params)
                  return (
                    '得分:' +
                    params[0].value +
                    '<br />' +
                    '扣分:' +
                    params[1].value +
                    '<br />' +
                    '得分率:' +
                    params[2].value +
                    '%'
                  )
                }
              },
              xAxis: {
                data: arr.map(item => item.orgName)
              },
              series: [
                {
                  type: 'bar',
                  name: '得分',
                  barWidth: '20px',
                  data: arr.map(item => {
                    if (item.modifiedScore > item.score) {
                      return item.modifiedScore
                    }
                    return item.score > 0 ? item.score : 0
                  })
                },
                {
                  type: 'bar',
                  name: '扣分',
                  barWidth: '20px',
                  data: arr.map(item => item.lostScore)
                },
                {
                  type: 'line',
                  name: '得分率',
                  barWidth: '20px',
                  data: arr.map(item => item.getScoreRatio)
                }
              ]
            })

猜你喜欢

转载自blog.csdn.net/weixin_43173924/article/details/89380019