占比图颜色修改

This commit is contained in:
jingna 2025-07-29 16:30:29 +08:00
parent 97317baeee
commit 4e726e671d

View File

@ -126,16 +126,16 @@ export class G2Pie extends G2ChartView {
showTitle: false,
eachView: (view, facet) => {
const data:any = facet.data
let color
if(customAttr.basicStyle.seriesColor.length>0){
customAttr.basicStyle.seriesColor.forEach((item) => {
if(data.name == item.name){
color = item.color
}
})
}else{
color = colorList[0]
}
// let color
// if(customAttr.basicStyle.seriesColor.length>0){
// customAttr.basicStyle.seriesColor.forEach((item) => {
// if(data.name == item.name){
// color = item.color
// }
// })
// }else{
// color = colorList[0]
// }
data.push({ name: '其他', value: 100 - data[0].value })
view.data(data)
view.coordinate('theta', {
@ -155,7 +155,12 @@ export class G2Pie extends G2ChartView {
}
})
}else{
colorval = colorList[0]
const dataIndex = resdata.findIndex(item => item.name === facet.data[0].name);
if (dataIndex === 0) {
colorval = colorList[0]
} else {
colorval = colorList[(dataIndex - 1) % (colorList.length - 1) + 1]
}
}
if (colorval.startsWith('#')) {
colorval = hexColorToRGBA(colorval, customAttr.basicStyle.alpha)
@ -209,8 +214,10 @@ export class G2Pie extends G2ChartView {
})
}
})
}
}
}
})
g2.render()
this.resizeObserver = new ResizeObserver(() => {