rich使用
在echarts中rich主要是用於設置用戶自定樣式,我們可以在title,legend中使用rich
在做項目的時候需要自定義echarts圖中字體樣式
但是這個地方數字和文字的顏色是一樣的,但是UI設計的圖需要文字是黑色字體,數字是根據環形圖的顏色一樣
這里就需要用到rich屬性來自定義字體的顏色,如:
series: [{
type: 'pie',
radius: ['40%', '60%'],
center: ['35%', '50%'],
data: echartData,
labelLine: {
normal: {
length: 20,
length2: 20
},
},
label: {
normal: {
formatter: (params)=> {
let str =(`{value|${params.value}}`)+ '\n'+(`{name|${params.name}}`);
return str
},
borderWidth: 5,
borderRadius: 5,
// padding: [0, 86],
height: 70,
fontSize: 20,
show: true,
rich: {
value:{
fontSize:28,
},
name:{
color:'#666666',
fontSize:20,
},
}
}
},
}]