一、图例形状
这里看常用的两种,更多可以查看/rudy_zhou/article/details/111474179?spm=1001..3001.5502
1、icon包括:
circle, rect, roundRect, triangle, diamond, pin, arrow, none
legend: {top: '5%',left: 'center',itemWidth: 20,itemHeight: 20,data: [{icon: 'circle', name: '搜索引擎'},{icon: 'rect', name: '直接访问'},{icon: 'roundRect', name: '邮件营销'},{icon: 'triangle', name: '联盟广告'},{icon: 'diamond', name: '视频广告'},{icon: 'pin', name: 'SEO'},{icon: 'arrow', name: '定点投放'}]}
2、使用图片链接或者base64 图片
图片转base64在线工具链接:/tools/imgtobase/
图片使用前缀为image://
legend: {top: '5%',left: 'center',itemWidth: 30,itemHeight: 30,data: [{icon: 'image:///F/0/1/3_rudy_zhou', name: '搜索引擎'},{icon: 'image://data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAYAAAA4TnrqAAAI2klEQVR4nO2bf2hUVxbHP29mkkwy+Wkm2fywxtRutia7htSa7dYatbBChbBQ7CrL2haCiLTUQqFS2G0Xygp1QSwtVQoWbCtbxK6lloqEyiolWcnqrtVU13Q1MT9M0sT8/p2Zt3+cdzNJ3ozus+9lUnhfuJDMnHfvfZ/ce+65595ogI6r/0ueeHfgxyQXlgW5sCzIhWVBLiwLcmFZkAvLglxYFuTCsiAXlgW5sCzIhWVBLiwL8sW7A/Olzfp5saVDFgUsDRniPqNoCKhpo4RZHODiDksDEoAUIBXwI52aBsaBEaNMEX9gcYflA9KAbKOkI/CmgEGgFxl1g8Zn8VRcYXmQkbQEKAAeAKq2bOGhqir++/XXnD12DD8yoqaAEDIl4yk9XsUHeh7ovwT996CfevVVfbZOv/aavt34Ps+wj2d/lS+Ni/xAPlACrAL26eau7PF4uKTrNAEdiB+Ll+IaZ3kRYKlAtqZFtQl6vaQZdt6F61pULTgszSg+BEAKEEAcezSlGTZ+IIn4AlsQB6/iqATkZb1AIgIoBUhGYERTslFSEHAhJKxQcZhy+gvhSxyHpSAFkOmWYjTqMT7LQGAk3KWDScazQe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cnae3vpRKZ2JzKa+pCI3WlQ6l0W5DKbSjmnEbn7oEqm8XkAWUk9RE51xogk/HqRnUGP8fu9Tobs1oLe/Jt9L0vdyUolAioJZk6ndWQbNI5kSIcRnzRk/KxOhBby2mJcrkmqqam2N+qiWiLme/AqOzpulHhexI3rnVLVAQ8Cz2MU1anZycTF8I8DcYf1Y5L7j04W5MKyIBeWBbmwLMiFZUEuLAtyYVmQC8uCXFgW5MKyIBeWBbmwLMiFZUEuLAtyYVmQC8uCXFgW9D8oBE7AzUnPcAAAAABJRU5ErkJggg==', name: '定点投放'}]},
二、图例文字颜色与图例一致的配置及图例文字多种颜色的配置
原文链接:/YiFeng-Liu/p/15308026.html
1、设置textStyle的 color为’auto’即可,但是使用 color为’auto’需要注意的是,如果需要对文字样式进行格式化处理的话,必须把自定义样式rich放在后面,否侧color为’auto’会被覆盖
2、如果非要让图例文字前半部分颜色固定,而后半部分文字颜色与图例颜色一致【不建议这种UI效果】,解决方法同样是最上面的2两种方式:
(1)在lengend 中配置data属性,data里面定义各图例的文本,以及该文本对应的样式:
(2)在farmatter中做if判断处理,当然这种不好的地方就是要一个个判断并对每一个图例进行富文本样式处理: