diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/pie/proportion.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/pie/proportion.ts index 0f994d6..e5152d1 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/pie/proportion.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/pie/proportion.ts @@ -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(() => {