From 4e726e671d2fe013996d4d6ed10ccc088bb2e601 Mon Sep 17 00:00:00 2001 From: jingna <1264204245@qq.com> Date: Tue, 29 Jul 2025 16:30:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=A0=E6=AF=94=E5=9B=BE=E9=A2=9C=E8=89=B2?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/panel/charts/pie/proportion.ts | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) 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(() => {