Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

echarts 自定义tooltip #63

Open
Lee981265 opened this issue Feb 22, 2022 · 0 comments
Open

echarts 自定义tooltip #63

Lee981265 opened this issue Feb 22, 2022 · 0 comments

Comments

@Lee981265
Copy link
Member

image

tooltip: {
          trigger: 'axis',
          formatter: function (params, ticket, callback) {
            let htmlStr = ''
            for (let i = 0; i < params.length; i++) {
              let param = params[i]
              let xName = param.name //x轴的名称
              let seriesName = param.seriesName //图例名称
              let value = param.value //y轴值
              let color = param.color //图例颜色
              if (i === 0) {
                htmlStr += xName + '<br/>'//x轴的名称
              }
              htmlStr += '<div>'
              //为了保证和原来的效果一样,这里自己实现了一个点的效果
              htmlStr += '<span style="margin-right:6px;display:inline-block;width:10px;height:10px;border-radius:5px;background-color:' + color + ';"></span>'
              // 文本颜色设置--2020-07-23(需要设置,请解注释下面一行)
              //htmlStr += '<span style="color:'+color+'">';
              //圆点后面显示的文本
              htmlStr += seriesName + '<b style="margin-left: 15px;">' + value + '%' + '</b>'
              // 文本颜色设置--2020-07-23(需要设置,请解注释下面一行)
              //htmlStr += '</span>';
              htmlStr += '</div>'
            }
            return htmlStr
          }
        },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant