占比图颜色修改
This commit is contained in:
parent
97317baeee
commit
4e726e671d
@ -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(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user