mirror of
https://github.com/dataease/dataease.git
synced 2026-05-14 12:22:10 +08:00
fix(图表): 修复明细表开启自动换行之后表头居中计算错误 ##17767
This commit is contained in:
@@ -2528,15 +2528,19 @@ function getTextStartX(cell, textStyle) {
|
||||
)
|
||||
const padding = cell.theme.colCell?.cell?.padding ?? { left: 0, right: 0 }
|
||||
const align = cell.getTextStyle()?.textAlign ?? 'left'
|
||||
const paddingLeft = padding.left || 0
|
||||
const paddingRight = padding.right || 0
|
||||
// 可用宽度(扣除 padding)
|
||||
const availableWidth = area.width - paddingLeft - paddingRight
|
||||
switch (align) {
|
||||
case 'left':
|
||||
return area.x + (padding.left || 0)
|
||||
return area.x + paddingLeft
|
||||
case 'center':
|
||||
return area.x + (area.width - textWidth) / 2
|
||||
return area.x + paddingLeft + (availableWidth - textWidth) / 2
|
||||
case 'right':
|
||||
return area.x + area.width - textWidth - (padding.right || 0)
|
||||
return area.x + area.width - textWidth - paddingRight
|
||||
default:
|
||||
return area.x + (padding.left || 0)
|
||||
return area.x + paddingLeft
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user