Skip to content

Commit

Permalink
fix: fix row series number position and height bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wuding.why committed Nov 14, 2023
1 parent bbcd43b commit 02d823c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/s2-core/src/facet/header/series-number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ export class SeriesNumberHeader extends BaseHeader<BaseHeaderConfig> {
leafNodes.forEach((node: Node): void => {
// 1、is spreadsheet and node is not total(grand or sub)
// 2、is listSheet
if (!node.isTotals || isHierarchyTreeType) {
const sNode = new Node({
id: '',
key: '',
value: `${seriesNodes.length + 1}`,
});
sNode.x = node.x;
sNode.y = node.y;
sNode.height = node.height;
sNode.width = seriesNumberWidth;
seriesNodes.push(sNode);
}
const sNode = new Node({
id: '',
key: '',
value: `${seriesNodes.length + 1}`,
});
sNode.x = node.x;
sNode.y = node.y;
sNode.height = isHierarchyTreeType
? node.getTotalHeightForTreeHierarchy()
: node.height;
sNode.width = seriesNumberWidth;
seriesNodes.push(sNode);
});
return new SeriesNumberHeader({
width: cornerWidth,
Expand Down
13 changes: 13 additions & 0 deletions packages/s2-core/src/facet/layout/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,17 @@ export class Node {
}
return leafChild;
}

/**
* 获取树状模式下,当前节点以及其所有子节点的高度总和
* */
public getTotalHeightForTreeHierarchy(): number {
if (this.height === 0 || isEmpty(this.children)) {
return this.height;
}
return this.children.reduce(
(sum, child) => sum + child.getTotalHeightForTreeHierarchy(),
this.height,
);
}
}

0 comments on commit 02d823c

Please sign in to comment.