美文网首页
【echarts】分享一个echarts里series里labe

【echarts】分享一个echarts里series里labe

作者: 西叶web | 来源:发表于2021-01-23 16:06 被阅读0次

分享一个echarts里series里label添加图片的代码
也是网上找的,链接https://blog.csdn.net/zm_miner/article/details/102689266
这个例子比官方的更直观,一看就知道fomatter和rich的结合使用方法了

series:{
        name: '峰值',
        type: 'bar',
        stack: 'b',
        yAxisIndex: 0,
        barGap: '-100%',
        barWidth: 15,
        data: [100, 200],
        itemStyle: {normal: { color: '#fff' } },
        z: 1
        //上面是一些杂七杂八的设置,不是重点,label里面才是重点
        label: {
          normal: {
            show: true,
            position: 'right',
            distance: 10,
            textStyle: {  color: '#ccc',  fontSize: '16'  },
            rich: {
              img1: {
                backgroundColor: {image: '本地路径或者http都可以'}
              }
            },
            formatter: function (param) {
               // img1是rich里面的对应的规则名,自定义即可,
              // {img|}表示那个规则或者说是空间的占位符的意思
              var res = param.value + '\n {img1|}'
              return res;
            }
          }
        }
      },

也可以先遍历好rich里的数据,再给rich附上,这样可以自定义label标签显示什么

欢迎点赞、留言、关注!

相关文章

网友评论

      本文标题:【echarts】分享一个echarts里series里labe

      本文链接:https://www.haomeiwen.com/subject/dhluzktx.html