From b7e21cafcd82d1b4101a02a76eccd03c8ca06c6e Mon Sep 17 00:00:00 2001 From: jianneng-fit2cloud Date: Wed, 29 Apr 2026 12:36:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=9B=BE=E4=BE=8B=E5=AF=BC=E8=88=AA=E6=96=B9=E5=90=91=E5=92=8C?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/chart/components/js/panel/charts/g2/bar/bar.ts | 6 +++--- .../src/views/chart/components/js/panel/types/impl/g2.ts | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/g2/bar/bar.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/g2/bar/bar.ts index 3eae5e258d..5fa23f90bf 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/g2/bar/bar.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/g2/bar/bar.ts @@ -421,6 +421,7 @@ export class Bar extends G2ChartView { ? 'flex-end' : 'center' } + const verticalLegend = position === 'left' || position === 'right' legend = { color: { orientation: orient, @@ -435,9 +436,8 @@ export class Bar extends G2ChartView { navPageNumFontSize: legendSize, navPageNumFill: legendColor, navButtonSize: legendSize, - navOrientation: - position === 'left' || position === 'right' ? 'vertical' : 'horizontal', - maxRows: 1, + navOrientation: verticalLegend ? 'vertical' : 'horizontal', + ...(verticalLegend ? { maxCols: 1 } : { maxRows: 1 }), navControllerSpacing: 20 } } diff --git a/core/core-frontend/src/views/chart/components/js/panel/types/impl/g2.ts b/core/core-frontend/src/views/chart/components/js/panel/types/impl/g2.ts index fdd8b23a92..ed34c2ee60 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/types/impl/g2.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/types/impl/g2.ts @@ -56,6 +56,7 @@ export abstract class G2ChartView< } else { position = l.hPosition } + const verticalLegend = position === 'left' || position === 'right' legend = { position, layout: { @@ -70,7 +71,9 @@ export abstract class G2ChartView< navPageNumFontSize: legendSize, navPageNumFill: legendColor, navButtonSize: legendSize, - navOrientation: position === 'left' || position === 'right' ? 'vertical' : 'horizontal' + navOrientation: verticalLegend ? 'vertical' : 'horizontal', + navControllerSpacing: 4, + ...(verticalLegend ? { maxCols: 1 } : { maxRows: 1 }) } } else { legend = false @@ -136,6 +139,8 @@ export abstract class G2ChartView< } public setupSubSeriesColor(chart: ChartObj, data?: any[]): ChartBasicStyle['seriesColor'] { + void chart + void data return undefined }