• echarts 实现tooltip提示框样式自定义


            实现echarts图提示框自定义样式,最重要的是给tooltip加一个自定义class,下面是我写的例子:

    1. tooltip: {
    2. trigger: "axis",
    3. axisPointer: {
    4. type: "line",
    5. },
    6. className: "custom-tooltip-box",
    7. formatter: function (params) {
    8. return `
    9. ${params[0].name}
    10. 缺材飞机数量:
    11. ${params[0].value}
  • `;
  • },
  • }
    1. ::v-deep .custom-tooltip-box {
    2. padding: 0 !important;
    3. border: none !important;
    4. background-color: transparent !important;
    5. // 给子盒子自定义样式
    6. .custom-tooltip-style {
    7. width: 25rem;
    8. min-height: 12rem;
    9. background: url("../../../../assets/images/tooltipBg.webp") no-repeat center
    10. center;
    11. background-size: 100% 100%;
    12. color: #fff;
    13. display: flex;
    14. flex-direction: column;
    15. padding: 1rem 2rem;
    16. font-size: 1.6rem;
    17. .span {
    18. display: flex;
    19. justify-content: space-between;
    20. margin-top: 0.5rem;
    21. :last-child {
    22. font-weight: 600;
    23. font-size: 1.8rem;
    24. }
    25. }
    26. }
    27. }

            该实例提示框背景是切的图片,内容通过formatter进行配置,样式上通过赋予className并在style标签中编写,实现如下效果:

    (该tooltip自定义样式适用于所有的echarts图,如折线图、柱状图、饼图)

  • 相关阅读:
    openGauss学习笔记-128 openGauss 数据库管理-设置透明数据加密(TDE)
    专访通过 OBCP V3 首位考生:V3 让知识更加结构化、体系化
    【PyTorch实战演练】深入剖析MTCNN(多任务级联卷积神经网络)并使用30行代码实现人脸识别
    CC1,3,6回顾
    C++-字符串处理函数-查找-截取-分割-替换-删除-格式化-与数值互转-拼接-正则表达式-常用功能
    Ajax详解
    深度学习-Pytorch同时使用Numpy和Tensors各自特效
    不同版本vue安装vue-router
    2021 Java面试题大全(整理版)1000+面试题附答案详解,最全面详细,看完稳了!
    基于Java+JSP+MySQL共享单车管理系统的设计与实现-计算机毕业设计
  • 原文地址:https://blog.csdn.net/SM_Cute/article/details/134463224