Skip to content

Commit

Permalink
Merge branch 'chore-merge-master-12-19' of github.com:antvis/S2 into …
Browse files Browse the repository at this point in the history
…chore-merge-master-12-19
  • Loading branch information
lijinke666 committed Jan 11, 2024
2 parents a369fd7 + 4a34fe7 commit c7b9633
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 73 deletions.
8 changes: 5 additions & 3 deletions packages/s2-core/src/common/constant/basic.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { i18n } from '../i18n';

// 约定这个 z-index 为 0 的 container 作为基准
export const BACK_GROUND_GROUP_CONTAINER_Z_INDEX = 0;

// foregroundGroup 上的 children 层叠顺序
export const FRONT_GROUND_GROUP_CONTAINER_Z_INDEX = 3; // 约定这个 z-index 为 0 的 container 作为基准
export const FRONT_GROUND_GROUP_CONTAINER_Z_INDEX = 3;
export const FRONT_GROUND_GROUP_SCROLL_Z_INDEX = 3;
export const FRONT_GROUND_GROUP_FROZEN_Z_INDEX = 4;
export const FRONT_GROUND_GROUP_RESIZE_AREA_Z_INDEX = 5;
Expand All @@ -12,7 +13,9 @@ export const FRONT_GROUND_GROUP_BRUSH_SELECTION_Z_INDEX = 5;
// panelGroup 上的 children 层叠顺序
export const PANEL_GROUP_GROUP_CONTAINER_Z_INDEX = 1;
export const PANEL_GROUP_SCROLL_GROUP_Z_INDEX = 1;
export const PANEL_GROUP_FROZEN_GROUP_Z_INDEX = 2;
export const PANEL_GRID_GROUP_Z_INDEX = 2;
export const PANEL_MERGE_GROUP_Z_INDEX = 3;
export const PANEL_GROUP_FROZEN_GROUP_Z_INDEX = 4;

// group's key
export const KEY_GROUP_BACK_GROUND = 'backGroundGroup';
Expand Down Expand Up @@ -60,7 +63,6 @@ export enum MiniChartTypes {
Bullet = 'bullet',
}


export const getDefaultSeriesNumberText = (defaultText?: string) =>
defaultText ?? i18n('序号');

Expand Down
58 changes: 0 additions & 58 deletions packages/s2-core/src/facet/pivot-facet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -661,64 +661,6 @@ export class PivotFacet extends FrozenFacet {
}
}

/**
* @description adust the coordinate of subTotal nodes when there is just one value
* @param hierarchy Hierarchy
* @param isRowHeader boolean
*/
private adjustSubTotalNodesCoordinate(
hierarchy: Hierarchy,
isRowHeader?: boolean,
) {
const subTotalNodes = hierarchy
.getNodes()
.filter((node) => node.isSubTotals);

if (isEmpty(subTotalNodes)) {
return;
}

const { maxLevel } = hierarchy;

forEach(subTotalNodes, (subTotalNode: Node) => {
const subTotalChildNode = subTotalNode.children;

if (isRowHeader) {
// 填充行总单元格宽度
subTotalNode.width = getSubTotalNodeWidthOrHeightByLevel(
hierarchy.sampleNodesForAllLevels,
subTotalNode.level,
'width',
);

// 调整其叶子节点位置
forEach(subTotalChildNode, (node: Node) => {
node.x = hierarchy.getNodes(maxLevel)[0].x;
});
} else {
// 填充列总单元格高度
const totalHeight = getSubTotalNodeWidthOrHeightByLevel(
hierarchy.sampleNodesForAllLevels,
subTotalNode.level,
'height',
);
const subTotalNodeChildrenHeight = subTotalChildNode?.[0]?.height ?? 0;

subTotalNode.height = totalHeight - subTotalNodeChildrenHeight;
// 调整其叶子节点位置, 以非小计行为准
const positionY =
find(
hierarchy.getNodes(maxLevel),
(node: Node) => !node.isTotalMeasure,
)?.y || 0;

forEach(subTotalChildNode, (node: Node) => {
node.y = positionY;
});
}
});
}

/**
* 计算 grid 模式下 node 宽度
* @param node
Expand Down
24 changes: 14 additions & 10 deletions packages/s2-core/src/group/grid-group.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Group } from '@antv/g';
import { last } from 'lodash';
import { KEY_GROUP_GRID_GROUP } from '../common/constant';
import {
KEY_GROUP_GRID_GROUP,
PANEL_GRID_GROUP_Z_INDEX,
} from '../common/constant';
import type { GridInfo } from '../common/interface';
import type { GridGroupConstructorParameters } from '../common/interface/group';
import type { SpreadSheet } from '../sheet-type/spread-sheet';
Expand All @@ -27,21 +30,24 @@ export class GridGroup extends Group {
};

public updateGrid = (gridInfo: GridInfo, id = KEY_GROUP_GRID_GROUP) => {
const width = last(gridInfo.cols) ?? 0;
const height = last(gridInfo.rows) ?? 0;
const { theme } = this.s2;

const style = theme.dataCell!.cell;

if (!this.gridGroup || !this.getElementById(id)) {
this.gridGroup = this.appendChild(
new Group({
id,
style: {
zIndex: PANEL_GRID_GROUP_Z_INDEX,
},
}),
);
} else {
this.gridGroup.removeChildren();
}

this.gridGroup.removeChildren();
const width = last(gridInfo.cols) ?? 0;
const height = last(gridInfo.rows) ?? 0;
const { theme } = this.s2;

const style = theme.dataCell!.cell;

const verticalBorderWidth = style?.verticalBorderWidth;

Expand Down Expand Up @@ -74,7 +80,5 @@ export class GridGroup extends Group {
lineWidth: horizontalBorderWidth,
});
});

this.gridGroup.toFront();
};
}
9 changes: 7 additions & 2 deletions packages/s2-core/src/group/panel-scroll-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import type { GridGroupConstructorParameters } from '../common/interface/group';
import { updateMergedCells } from '../utils/interaction/merge-cell';
import { S2Event } from '../common';
import type { MergedCell } from './../cell/merged-cell';
import { KEY_GROUP_MERGED_CELLS } from './../common/constant/basic';
import {
KEY_GROUP_MERGED_CELLS,
PANEL_MERGE_GROUP_Z_INDEX,
} from './../common/constant/basic';
import { GridGroup } from './grid-group';

export class PanelScrollGroup extends GridGroup {
Expand All @@ -27,14 +30,16 @@ export class PanelScrollGroup extends GridGroup {
this.mergedCellsGroup = this.appendChild(
new Group({
id: KEY_GROUP_MERGED_CELLS,
style: {
zIndex: PANEL_MERGE_GROUP_Z_INDEX,
},
}),
);
}

updateMergedCells() {
this.initMergedCellsGroup();
updateMergedCells(this.s2, this.mergedCellsGroup);
this.mergedCellsGroup.toFront();
}

addMergeCell(mergedCell: MergedCell) {
Expand Down

0 comments on commit c7b9633

Please sign in to comment.