fix(图表): 优化图例导航方向和布局逻辑

This commit is contained in:
jianneng-fit2cloud
2026-04-29 12:36:46 +08:00
parent f34a11382b
commit b7e21cafcd
2 changed files with 9 additions and 4 deletions

View File

@@ -421,6 +421,7 @@ export class Bar extends G2ChartView<ViewSpec, G2Column> {
? 'flex-end'
: 'center'
}
const verticalLegend = position === 'left' || position === 'right'
legend = {
color: {
orientation: orient,
@@ -435,9 +436,8 @@ export class Bar extends G2ChartView<ViewSpec, G2Column> {
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
}
}

View File

@@ -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
}