echarts showTip 无法触发解决 (调整grid)

编程入门 行业动态 更新时间:2024-10-16 20:24:00

<a href=https://www.elefans.com/category/jswz/34/1767945.html style=echarts showTip 无法触发解决 (调整grid)"/>

echarts showTip 无法触发解决 (调整grid)

"echarts": "5.4.0",

"vue": "2.6.12",

在interval的时候 showtip 发现如果数据为0,那么 dispatchAction showTip 不会触发,

 

        myChart.dispatchAction({

          type: "showTip",

          seriesIndex: 0,

          dataIndex: currentIndex,

          // name: option.xAxis[0].data[currentIndex],

        });

经过多次测试发现 是showTip 与grid设置冲突

当grid设置中有百分比时  showTip 数据为0时不会触发,后改为具体数值 showTip为0也会触发

grid: {

          top: 30,

          left: 20,

          right: 20,

          bottom: 10,

          containLabel: true,

       },

    tooltip: {

          show: true,

          backgroundColor: "RGBA(3, 12, 53, 0.9)",

          trigger: "axis",

          formatter: function (param) {

            let total = 0;

            let xName = "";

            let qoq = "";

            let yoy = "";

            param.map((item) => {

              total = item.data.docSum;

              xName = item.axisValue;

              item.data.qoq ? (qoq = item.data.qoq) : "";

              item.data.yoy ? (yoy = item.data.yoy) : "";

            });

            let isUpDownQOQ = qoq.indexOf("-");

            let isUpDownYOY = yoy.indexOf("-");

            let str = "";

            if (isUpDownQOQ === -1) {

              str = `<img src="${_this.upImg}" width="10px">`;

            } else {

              str = `<img src="${_this.downImg}" width="10px">`;

            }

            let str2 = "";

            if (isUpDownYOY === -1) {

              str2 = `<img src="${_this.upImg}" width="10px">`;

            } else {

              str2 = `<img src="${_this.downImg}" width="10px">`;

            }

            console.log(param);

            return `${xName}文件统计<br/>文件总量:${total}<br/>环比:${qoq}%${str}<br/>同比:${yoy}%${str2}`;

          },

          textStyle: { color: "#fff" },

          borderWidth: 0,

        },

更多推荐

echarts showTip 无法触发解决 (调整grid)

本文发布于:2023-12-06 20:59:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1668897.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:echarts   showTip   grid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!