占比图颜色修改
This commit is contained in:
parent
97317baeee
commit
4e726e671d
@ -126,16 +126,16 @@ export class G2Pie extends G2ChartView {
|
|||||||
showTitle: false,
|
showTitle: false,
|
||||||
eachView: (view, facet) => {
|
eachView: (view, facet) => {
|
||||||
const data:any = facet.data
|
const data:any = facet.data
|
||||||
let color
|
// let color
|
||||||
if(customAttr.basicStyle.seriesColor.length>0){
|
// if(customAttr.basicStyle.seriesColor.length>0){
|
||||||
customAttr.basicStyle.seriesColor.forEach((item) => {
|
// customAttr.basicStyle.seriesColor.forEach((item) => {
|
||||||
if(data.name == item.name){
|
// if(data.name == item.name){
|
||||||
color = item.color
|
// color = item.color
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
}else{
|
// }else{
|
||||||
color = colorList[0]
|
// color = colorList[0]
|
||||||
}
|
// }
|
||||||
data.push({ name: '其他', value: 100 - data[0].value })
|
data.push({ name: '其他', value: 100 - data[0].value })
|
||||||
view.data(data)
|
view.data(data)
|
||||||
view.coordinate('theta', {
|
view.coordinate('theta', {
|
||||||
@ -155,7 +155,12 @@ export class G2Pie extends G2ChartView {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}else{
|
}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('#')) {
|
if (colorval.startsWith('#')) {
|
||||||
colorval = hexColorToRGBA(colorval, customAttr.basicStyle.alpha)
|
colorval = hexColorToRGBA(colorval, customAttr.basicStyle.alpha)
|
||||||
@ -210,7 +215,9 @@ export class G2Pie extends G2ChartView {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
g2.render()
|
g2.render()
|
||||||
this.resizeObserver = new ResizeObserver(() => {
|
this.resizeObserver = new ResizeObserver(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user