From 5c046f32582612bc20be50041ecec7fc29c8314e Mon Sep 17 00:00:00 2001 From: jianneng-fit2cloud Date: Wed, 3 Jun 2026 10:03:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=A5=BC=E5=9B=BE=E3=80=81=E7=8E=AB=E7=91=B0=E5=9B=BE=E5=86=8D?= =?UTF-8?q?=E5=8F=AA=E6=9C=89=E4=B8=80=E4=B8=AA=E6=95=B0=E6=8D=AE=E6=97=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=9B=BE=E5=BD=A2=E4=B8=8D=E5=AE=8C=E6=95=B4?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/panel/charts/g2/relation/pie/common.ts | 17 +++++++++++++++++ .../js/panel/charts/g2/relation/pie/pie.ts | 6 ++++-- .../js/panel/charts/g2/relation/pie/rose.ts | 6 ++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/g2/relation/pie/common.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/g2/relation/pie/common.ts index ce8120c407..78db1b304b 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/g2/relation/pie/common.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/g2/relation/pie/common.ts @@ -1,4 +1,5 @@ import { useI18n } from '@/hooks/web/useI18n' +import type { G2Spec } from '@antv/g2' const { t } = useI18n() @@ -61,3 +62,19 @@ export const PIE_AXIS_CONFIG: AxisConfig = { limit: 1 } } + +export const configSingleSectorScale = (options: G2Spec, data: any[]): G2Spec => { + if (data.length !== 1) { + return options + } + options.scale = { + ...options.scale, + x: { + ...options.scale?.x, + padding: 0, + paddingInner: 0, + paddingOuter: 0 + } + } + return options +} diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/g2/relation/pie/pie.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/g2/relation/pie/pie.ts index 08da9db628..9015d9bf3d 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/g2/relation/pie/pie.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/g2/relation/pie/pie.ts @@ -11,6 +11,7 @@ import { PIE_EDITOR_PROPERTY, PIE_EDITOR_PROPERTY_INNER } from '@/views/chart/components/js/panel/charts/g2plot/pie/common' +import { configSingleSectorScale } from './common' import { getTooltipSeriesTotalMap, handleChartDashboardHidden, @@ -136,8 +137,9 @@ export class Pie extends G2ChartView { } data.push(initOtherItem) } - options.coordinate.outerRadius = basicStyle.radius / 100 - return options + const singleSectorOptions = configSingleSectorScale(options, data) + singleSectorOptions.coordinate.outerRadius = basicStyle.radius / 100 + return singleSectorOptions } protected configColor(chart: Chart, options: G2Spec): G2Spec { diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/g2/relation/pie/rose.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/g2/relation/pie/rose.ts index bea860abfb..ea60f7b83c 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/g2/relation/pie/rose.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/g2/relation/pie/rose.ts @@ -11,6 +11,7 @@ import { PIE_EDITOR_PROPERTY, PIE_EDITOR_PROPERTY_INNER } from '@/views/chart/components/js/panel/charts/g2plot/pie/common' +import { configSingleSectorScale } from './common' import { getTooltipSeriesTotalMap, handleChartDashboardHidden, @@ -141,8 +142,9 @@ export class Rose extends G2ChartView { } data.push(initOtherItem) } - options.coordinate.outerRadius = basicStyle.radius / 100 - return options + const singleSectorOptions = configSingleSectorScale(options, data) + singleSectorOptions.coordinate.outerRadius = basicStyle.radius / 100 + return singleSectorOptions } protected configColor(chart: Chart, options: G2Spec): G2Spec {