echarts 自定义tooltip样式

1.echarts options设置

复制代码
    tooltip: {
      trigger: 'item',
      className: 'custom-tooltip-box', // 命名父级类名
      formatter: function (params) {
        const { name, value } = params
        var htmlText = `<div class='custom-tooltip-style'>  // 用html自定义样式
                            <div class='custom-tooltip-top'>
                                <div class='custom-tooltip-topImg'></div>
                                ${name}专利量
                            </div>
                            <div class='custom-tooltip-middle'></div>
                            <div class='custom-tooltip-bbotton'>
                              ${value || 0}
                            </div>
                        </div>`
        return htmlText
      }
    },
复制代码

2.设置样式

复制代码
<style scoped lang="scss">
// 给父盒子清除默认已有样式
/deep/ .custom-tooltip-box {
  padding: 0 !important;
  border: none !important;
  // 给子盒子自定义样式
  .custom-tooltip-style {
    margin: 16px 25px 19px 25px;
    display: flex;
    flex-direction: column;
    .custom-tooltip-top {
      display: flex;
      color: #000000;
      align-items: center;
      .custom-tooltip-topImg {
        background-image: url('/static/images/icon.png');
        width: 12px;
        height: 14px;
        margin-right: 8px;
      }
    }
    .custom-tooltip-middle {
      opacity: 0.5;
      height: 1px;
      background: #a3a199;
      margin: 8px 0 12px 0;
    }
    .custom-tooltip-bbotton {
      color: #000000;
      font-size: 30px;
      font-family: Helvetica;
      font-weight: bold;
    }
  }
}
</style>
复制代码

 

posted on   ChoZ  阅读(1826)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示