echarts 给formatter文字添加不同颜色

legend: {
                    x : 'center',
                    y : 'bottom',
                    icon: "circle",
                    itemWidth: 8,  // 设置宽度
                    itemHeight: 8, // 设置高度
                    itemGap: 20,// 设置间距
                    orient: 'vertical',
                    top:'80%',
                    data:this.labels,
                    formatter: function(value) {
                            if (value.length > 4) {
                            return  value.substring(0, 4) + "..." + '{a|'+ '|  20%' +'}' + '20';
                            } else {
                            return value + '{a|'+ '|  20%' +'}' + '20';
                            }
                    },
                    textStyle:{
                        fontSize:15,
                        //在rich中给formatter添加个别字体颜色
                        rich:{
                            a:{
                                color:'#03a9f4',
                                padding:[0,10],
                                fontSize:15
                            },
                        },
                    },
                    tooltip: {
                        show: true
                    }
                },
原文地址:https://www.cnblogs.com/yhhBKY/p/11835136.html