echart tooltip 跟随鼠标,鼠标在左半部分时靠右,反之

tooltip: {
        trigger: 'axis',
        position(pos, params, el, elRect, size) {
          const obj = { top: 10 };
          // 鼠标在canvas左侧
          if (pos[0] < size.viewSize[0] / 2) {
            obj.left = pos[0];
          } else {
            obj.right = size.viewSize[0] - pos[0];
          }
          return obj;
        },
        axisPointer: {
          type: 'cross',
          label: {
            backgroundColor: '#6a7985',
          },
        },
        backgroundColor: 'rgba(0,0,0,0.7)',
        textStyle: {
          fontSize: 12,
        },
        formatter: `{b0}:<br/>{a0}{c0}%<br/>{a1}{c1}%<br/>{a2}{c2}%<br/>{a3}{c3}%<br/>{a4}{c4}%<br/>{a5}{c5}%<br/>
        {a6}{c6}%<br/>{a7}{c7}%<br/>{a8}{c8}%<br/>{a9}{c9}%<br/>{a10}{c10}%<br/>`,
      },
      legend: {
        bottom: 0,
        icon: 'rect',
        textStyle: {
          color: '#818A9A',
          fontSize: 12,
        },
        itemWidth: 12,
        itemHeight: 4,
      },
      grid: {
        top: 35,
        left: 15,
        bottom: 50,
        right: 28,
        containLabel: true, // 文案展示全
      },
      xAxis: [
        {
          type: 'category',
          boundaryGap: false,
          data: DDTimeData,
          splitLine: {
            show: false,
          },
          axisLine: {
            lineStyle: {
              color: '#515968',
            },
          },
          axisLabel: {
            // interval: inter,
            color: '#F0F0F0',
            fontSize: 10,
          },
          axisTick: {
            show: false,
          },
        },
      ],
      yAxis: [
        {
          name: '%',
          axisLine: {
            lineStyle: {
              color: '#818A9A',
            },
          },
          splitLine: {
            show: true,
            lineStyle: {
              color: ['#515968'],
              width: 1,
              type: 'dotted',
            },
          },
          type: 'value',
        },
      ],
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值