8.legend格式化
<script> const getname = ["时长异常", "时长正常", "无时长"]; //初始化getname const getNum = [0, 0, 0]; //初始化getNum export default{ data(){ return{ chartOption:{ legend: { x: "right", //可设定图例在左、右、居中 y: "center", //可设定图例在上、下、居中 align: "left", //字在图例的左边或右边【left/right】 orient: "vertical", //图例方向【horizontal/vertical】 icon: "circle", //图例形状【circle、rect、roundRect、triangle、diamond、pin、arrow、none】 itemGap: 12, textStyle: { rich: { name: { color: "#595959", fontSize: 14, width: 100, fontWeight: 400 }, value: { color: "#595959", fontSize: 14, width: 100, fontWeight: 400 } } }, // legend加百分号 formatter: function(name) { for (let i = 0; i < getname.length; i++) { if (name == getname[i]) { return `{name|${name}}{value${i}|${getNum[i]}%}`; } } } }, } } } } </script>
转载请注明原文链接:https://www.cnblogs.com/chenJieLing/