Skip to content

Fix/large merge auto height #3782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vtable",
"comment": "fix: fix merge cell autoHeight #3752",
"type": "none"
}
],
"packageName": "@visactor/vtable"
}
6 changes: 4 additions & 2 deletions packages/vtable/src/scenegraph/layout/compute-row-height.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,9 @@ function computeCustomRenderHeight(col: number, row: number, table: BaseTableAPI
const padding = getQuadProps(getProp('padding', actStyle, col, row, table));
height += padding[0] + padding[2];
}
const minSingleRowHeight = table.options.customConfig?.minSingleRowHeight ?? 2;
return {
height: height / spanRow,
height: Math.max(height / spanRow, minSingleRowHeight),
renderDefault
};
}
Expand Down Expand Up @@ -880,7 +881,8 @@ function computeTextHeight(col: number, row: number, cellType: ColumnTypeOption,
}
}
}
return (Math.max(maxHeight, iconHeight) + padding[0] + padding[2]) / spanRow;
const minSingleRowHeight = table.options.customConfig?.minSingleRowHeight ?? 2;
return Math.max((Math.max(maxHeight, iconHeight) + padding[0] + padding[2]) / spanRow, minSingleRowHeight);
}

function getCellRect(col: number, row: number, table: BaseTableAPI) {
Expand Down
39 changes: 30 additions & 9 deletions packages/vtable/src/scenegraph/stick-text/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export function handleTextStick(table: BaseTableAPI) {
return;
}

const horizontalUpdateTimeStamp = Date.now();
const verticalUpdateTimeStamp = Date.now();

// column header
for (let row = 0; row < frozenRowCount; row++) {
if (colEnd < colStart) {
Expand All @@ -61,7 +64,8 @@ export function handleTextStick(table: BaseTableAPI) {
table.tableNoFrameWidth - table.getRightFrozenColsWidth() + table.tableX,
changedCells,
style?.textStickBaseOnAlign,
table
table,
horizontalUpdateTimeStamp
);
}
});
Expand All @@ -87,7 +91,8 @@ export function handleTextStick(table: BaseTableAPI) {
table.tableNoFrameHeight - table.getBottomFrozenRowsHeight() + table.tableY,
changedCells,
style?.textStickBaseOnAlign,
table
table,
verticalUpdateTimeStamp
);
}
});
Expand All @@ -109,7 +114,8 @@ export function handleTextStick(table: BaseTableAPI) {
table.tableNoFrameHeight - table.getBottomFrozenRowsHeight() + table.tableY,
changedCells,
style?.textStickBaseOnAlign,
table
table,
verticalUpdateTimeStamp
);
}
});
Expand All @@ -129,7 +135,8 @@ export function handleTextStick(table: BaseTableAPI) {
table.tableNoFrameWidth - table.getRightFrozenColsWidth() + table.tableX,
changedCells,
style?.textStickBaseOnAlign,
table
table,
horizontalUpdateTimeStamp
);
}
});
Expand All @@ -147,7 +154,8 @@ function adjustCellContentVerticalLayout(
maxTop: number,
changedCells: Map<string, StickCell>,
textStickBaseOnAlign: boolean | undefined,
table: BaseTableAPI
table: BaseTableAPI,
updateTimeStamp: number
) {
if (
isNumber(cellGroup.mergeStartCol) &&
Expand All @@ -158,11 +166,17 @@ function adjustCellContentVerticalLayout(
const { colStart, colEnd, rowStart, rowEnd } = getCellMergeRange(cellGroup, table.scenegraph);
for (let col = colStart; col <= colEnd; col++) {
for (let row = rowStart; row <= rowEnd; row++) {
const singleCellGroup = table.scenegraph.getCell(col, row);
const singleCellGroup = table.scenegraph.highPerformanceGetCell(col, row);
if (singleCellGroup.role !== 'cell') {
continue;
}
dealVertical(singleCellGroup, minTop, maxTop, changedCells, textStickBaseOnAlign);
if ((singleCellGroup as any).updateTimeStamp !== updateTimeStamp) {
dealVertical(singleCellGroup, minTop, maxTop, changedCells, textStickBaseOnAlign);
(singleCellGroup as any).updateTimeStamp = updateTimeStamp;
} else {
// do nothing
// console.log('ignore');
}
}
}
} else {
Expand Down Expand Up @@ -260,7 +274,8 @@ function adjustCellContentHorizontalLayout(
maxLeft: number,
changedCells: Map<string, StickCell>,
textStickBaseOnAlign: boolean | undefined,
table: BaseTableAPI
table: BaseTableAPI,
updateTimeStamp: number
) {
if (
isNumber(cellGroup.mergeStartCol) &&
Expand All @@ -275,7 +290,13 @@ function adjustCellContentHorizontalLayout(
if (singleCellGroup.role !== 'cell') {
continue;
}
dealHorizontal(singleCellGroup, minLeft, maxLeft, changedCells, textStickBaseOnAlign);
if ((singleCellGroup as any).updateTimeStamp !== updateTimeStamp) {
dealHorizontal(singleCellGroup, minLeft, maxLeft, changedCells, textStickBaseOnAlign);
(singleCellGroup as any).updateTimeStamp = updateTimeStamp;
} else {
// do nothing
// console.log('ignore');
}
}
}
} else {
Expand Down
3 changes: 3 additions & 0 deletions packages/vtable/src/ts-types/base-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,9 @@ export interface BaseTableConstructorOptions {

// 是否禁用内置图表激活
disableBuildInChartActive?: boolean;

// 多行合并行号自动计算时单行最小行高,用在大量行合并的情况下,行高自动计算过小导致无法显示完整内容
minSingleRowHeight?: number;
}; // 部分特殊配置,兼容xTable等作用

animationAppear?: boolean | IAnimationAppear;
Expand Down
Loading