echarts自定义label,echarts自定义formatter

echarts自定义label,echarts自定义formatter,echarts样式自定义

呈现效果

在这里插入图片描述

formatter代码

formatter: (params)=> {
            let str = '<div style="padding: 3px 12px;width: 161px;background: #FFFFFF;border: 1px solid #DCDFE6;box-shadow:none; opacity: 1;border-radius: 4px;"><span style="color:#606062;font-size: 12px;">' + params[0].axisValue + "</span><br />";
            params.forEach((item) => {
              str +=
                '<span style="color:#f00;font-size: 12px;color: #1D1D20;"><span style="float:left; margin-top:8px; margin-right:5px;border-radius:50%;width:6px;height:6px;background-color:'+item.color+'"></span>' + this.name + "&nbsp;&nbsp;&nbsp;&nbsp;" + item.data + "</span>";
            });
            str += '</div>'
            return str;
          }

option完整代码

{
        grid: grid,
        tooltip: {
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#111"
            }
          },
          padding: 0,
          formatter: (params)=> {
            let str = '<div style="padding: 3px 12px;width: 161px;background: #FFFFFF;border: 1px solid #DCDFE6;box-shadow:none; opacity: 1;border-radius: 4px;"><span style="color:#606062;font-size: 12px;">' + params[0].axisValue + "</span><br />";
            params.forEach((item) => {
              str +=
                '<span style="color:#f00;font-size: 12px;color: #1D1D20;"><span style="float:left; margin-top:8px; margin-right:5px;border-radius:50%;width:6px;height:6px;background-color:'+item.color+'"></span>' + this.name + "&nbsp;&nbsp;&nbsp;&nbsp;" + item.data + "</span>";
            });
            str += '</div>'
            return str;
          },
          trigger: "axis",
          confine: true
        },
        xAxis: {
          type: "category",
          axisLine: {
            show: true,
            lineStyle: {
              color: "#f1f1f1"
            }
          },
          axisLabel: {
            interval: interval,
            color: "#222222",
            rotate: 0
          },
          data: xAxisData
        },
        yAxis: {
          type: "value",
          axisLine: {
            show: false,
            lineStyle: {
              color: "#f1f1f1"
            }
          },
          splitLine: {
            show: true,
            lineStyle: {
              color: "#f1f1f1"
            }
          },
          axisLabel: {
            color: "#222222"
          }
        },
        series: [
          {
            data: seriesData,
            smooth: true,
            type: "line",
            itemStyle: {
              color: "#4563F8",
              borderWidth: 3,
              borderType: 'solid',
              borderCap: 'square'
            },
            lineStyle: {
              color: "#4563F8",
              width: 3
            }
          }
        ]
      }
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值