fix(图表): 表格序号列标签溢出

This commit is contained in:
wisonic 2024-09-04 18:18:37 +08:00
parent a3881c2f6b
commit 3d7a45926b
3 changed files with 16 additions and 29 deletions

View File

@ -147,18 +147,15 @@ export class TableInfo extends S2ChartView<TableSheet> {
}
// 开启序号之后第一列就是序号列修改 label 即可
if (s2Options.showSeriesNumber) {
s2Options.colCell = (node, sheet, config) => {
if (node.colIndex === 0) {
let indexLabel = customAttr.tableHeader.indexLabel
if (!indexLabel) {
indexLabel = ''
}
const cell = new TableColCell(node, sheet, config)
const shape = cell.getTextShape() as any
shape.attrs.text = indexLabel
return cell
let indexLabel = customAttr.tableHeader.indexLabel
if (!indexLabel) {
indexLabel = ''
}
s2Options.layoutCoordinate = (_, __, col) => {
if (col.colIndex === 0 && col.rowIndex === 0) {
col.label = indexLabel
col.value = indexLabel
}
return new TableColCell(node, sheet, config)
}
}
s2Options.dataCell = viewMeta => {

View File

@ -135,21 +135,15 @@ export class TableNormal extends S2ChartView<TableSheet> {
}
// 开启序号之后第一列就是序号列修改 label 即可
if (s2Options.showSeriesNumber) {
s2Options.colCell = (node, sheet, config) => {
if (node.colIndex === 0) {
let indexLabel = customAttr.tableHeader.indexLabel
if (!indexLabel) {
indexLabel = ''
}
const cell = new TableColCell(node, sheet, config)
const shape = cell.getTextShape() as any
shape.attrs.text = indexLabel
return cell
}
return new TableColCell(node, sheet, config)
let indexLabel = customAttr.tableHeader.indexLabel
if (!indexLabel) {
indexLabel = ''
}
s2Options.dataCell = viewMeta => {
return new TableDataCell(viewMeta, viewMeta?.spreadsheet)
s2Options.layoutCoordinate = (_, __, col) => {
if (col.colIndex === 0 && col.rowIndex === 0) {
col.label = indexLabel
col.value = indexLabel
}
}
}
// tooltip

View File

@ -83,10 +83,6 @@ export abstract class S2ChartView<P extends SpreadSheet> extends AntVAbstractCha
break
case 'rowCell':
case 'colCell':
if (meta.field === SERIES_NUMBER_FIELD) {
content = cell.getTextShape()['attrs'].text
break
}
content = meta.label
field = find(metaConfig, item => item.field === content)
if (field) {