• echarts 里面的 rich(富文本)使用方法


    先解释一下这里的rich 是干啥的, rich 的目的就是给文字加上一些自定义的样式, 或者通过背景加上一张图片

    在 echarts 里面很有地方都可以使用 formatter 属性, 而使用 formatter 的地方大多都是可以使用 rich 属性的,

    在这里需要注意的是 formatter 里面返回的 styleName 一定要和 rich 里面的相互对应, 否则不会生效

       label: {
                formatter: '{Sunny| 我是太阳}',
                rich: {
                  Sunny: {
                    color: '#fff',
                    textBorderWidth: 1,
                    fontSize: 22
                  }
                }
              }
    

    echarts 相关文档

    ecahrts 拓展

    1. 设置平均线 and 自定义线的位置

    这里就用到了上面的 rich 富文本, rich 富文本理解之后真的是好用

    自定义线的位置就是用利用 yAxis 属性

    markLine: {
              symbol: 'none', // 取消线两端的 cap, 不展示箭头等形状
              data: [
                {
                  type: 'average',
                  name: '平均值',
                  label: {
                    show: 'true',
                    position: 'insideEndTop',
                    formatter: `{label|平均用时:}{value|{c}}{unit|min}`,
                    rich: {
                      label: { fontSize: '10px', color: 'rgba(223, 229, 252, 1)' },
                      unit: { fontSize: '10px', color: 'rgba(223, 229, 252, 1)' },
                      value: {
                        color: 'rgba(25, 217, 251, 1)',
                        fontSize: '10px'
                      }
                    }
                  },
                  lineStyle: {
                     '0.5',
                    type: 'soild',
                    color: 'rgba(223, 229, 252, 1)'
                  },
    
                  emphasis: {
                    lineStyle: {
                       '0.5',
                      type: 'soild',
                      color: 'rgba(223, 229, 252, 1)'
                    }
                  }
                },
                {
                  // 自定义线的位置, 这里就是指定一个 y 轴坐标, 
                  name: '建议用时',
                  yAxis: 40,
                  label: {
                    show: 'true',
                    position: 'insideEndBottom',
                    formatter: `{label|建议用时:}{value|{c}}{unit|min}`,
                    rich: {
                      label: { fontSize: '10px', color: 'rgba(223, 229, 252, 1)' },
                      unit: { fontSize: '10px', color: 'rgba(223, 229, 252, 1)' },
                      value: {
                        color: 'rgba(25, 217, 251, 1)',
                        fontSize: '10px'
                      }
                    }
                  },
                  lineStyle: {
                     '0.5',
                    type: 'soild',
                    color: 'rgba(223, 229, 252, 1)'
                  },
                  symbolSize: 0,
                  emphasis: {
                    lineStyle: {
                       '0.5',
                      type: 'soild',
                      color: 'rgba(223, 229, 252, 1)'
                    }
                  }
                }
              ]
            }
    
  • 相关阅读:
    Android属性动画ObjectAnimator的使用1
    通过Android反编译技术研究国内陌生人社交即时通讯的技术方案
    滴滴出行开源项目doraemonkit食用指南
    Android开发利器之pidcat
    Spinner在Dialog中的使用效果
    python抓取知识星球精选帖,制作为pdf文件
    [设计模式]观察者模式
    C语言实现进度条
    [设计模式]策略模式
    线程链表与线程切换
  • 原文地址:https://www.cnblogs.com/shiazhen/p/16276565.html
Copyright © 2020-2023  润新知