Skip to content

Commit

Permalink
fix: fix tree layout problem (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun authored Jun 28, 2023
1 parent bb33255 commit 86c3eab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions packages/vtable/examples/pivot/pivot-tree.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as VTable from '../../src';
import { bindDebugTool } from '../../src/scenegraph/debug-tool';
const PivotTable = VTable.PivotTable;
const Table_CONTAINER_DOM_ID = 'vTable';

Expand Down Expand Up @@ -445,6 +446,10 @@ export function createTable() {
const tableInstance = new PivotTable(option);
// 只为了方便控制太调试用,不要拷贝
(window as any).tableInstance = tableInstance;

bindDebugTool(tableInstance.scenegraph.stage as any, {
customGrapicKeys: ['role', '_updateTag']
});
})
// eslint-disable-next-line no-console
.catch(e => console.log(e));
Expand Down
4 changes: 2 additions & 2 deletions packages/vtable/src/scenegraph/layout/update-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import type { Scenegraph } from '../scenegraph';
export function updateRow(removeCells: CellAddress[], addCells: CellAddress[], table: BaseTableAPI) {
const scene = table.scenegraph;
// deduplication
const removeRows = deduplication(removeCells.map(cell => cell.row)).sort();
const addRows = deduplication(addCells.map(cell => cell.row)).sort();
const removeRows = deduplication(removeCells.map(cell => cell.row)).sort((a, b) => a - b);
const addRows = deduplication(addCells.map(cell => cell.row)).sort((a, b) => a - b);

// remove cells
removeRows.forEach(row => {
Expand Down
7 changes: 5 additions & 2 deletions packages/vtable/src/scenegraph/stick-text/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { BaseTableAPI } from '../../ts-types/base-table';
import { PIVOT_TABLE_EVENT_TYPE } from '../../ts-types/pivot-table/PIVOT_TABLE_EVENT_TYPE';
import type { Group } from '../graphic/group';
import type { WrapText } from '../graphic/text';
import { table } from 'console';
import type { PivotHeaderLayoutMap } from '../../layout/pivot-header-layout';
const changedCells: { col: number; row: number }[] = [];
export function handleTextStick(table: BaseTableAPI) {
changedCells.forEach(cellPos => {
Expand Down Expand Up @@ -49,7 +49,10 @@ export function handleTextStick(table: BaseTableAPI) {
// 行表头单元格
for (let row = rowStart; row <= rowEnd; row++) {
for (let col = 0; col < frozenColCount; col++) {
if (table._getCellStyle(col, row)?.textStick) {
if (
table._getCellStyle(col, row)?.textStick &&
(table.internalProps.layoutMap as PivotHeaderLayoutMap).rowHierarchyType !== 'tree'
) {
const cellGroup = table.scenegraph.getCell(col, row);
// adjust cell vertical
adjustCellContentVerticalLayout(cellGroup, frozenRowsHeight, table.tableNoFrameHeight);
Expand Down

0 comments on commit 86c3eab

Please sign in to comment.