Skip to content

Commit 4ba8234

Browse files
committed
fix: 常量抽取
1 parent b2def8e commit 4ba8234

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

packages/s2-core/src/common/constant/basic.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export const KEY_GROUP_COL_HORIZONTAL_RESIZE_AREA =
4444
export const KEY_GROUP_COL_SCROLL = 'colScrollGroup';
4545
export const KEY_GROUP_COL_FROZEN = 'colFrozenGroup';
4646
export const KEY_GROUP_COL_FROZEN_TRAILING = 'colFrozenTrailingGroup';
47+
export const KEY_GROUP_GRID_GROUP = 'gridGroup';
4748

4849
// key of series number node in corner header
4950
export const KEY_SERIES_NUMBER_NODE = 'series-number-node';

packages/s2-core/src/group/grid-group.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { IGroup } from '@antv/g-canvas';
33
import { Group } from '@antv/g-canvas';
44
import { renderLine } from 'src/utils/g-renders';
55
import { GridInfo } from 'src/common/interface';
6+
import { KEY_GROUP_GRID_GROUP } from 'src/common/constant';
67

78
export class GridGroup extends Group {
89
private ss: SpreadSheet;
@@ -19,7 +20,7 @@ export class GridGroup extends Group {
1920
rows: [],
2021
};
2122

22-
public updateGrid = (gridInfo: GridInfo, id = 'foobar') => {
23+
public updateGrid = (gridInfo: GridInfo, id = KEY_GROUP_GRID_GROUP) => {
2324
const bbox = this.getBBox();
2425
const style = this.ss.theme.dataCell.cell;
2526

@@ -33,11 +34,12 @@ export class GridGroup extends Group {
3334

3435
this.gridInfo = gridInfo;
3536
this.gridInfo.cols.forEach((item) => {
37+
const x = item - style.verticalBorderWidth / 2;
3638
renderLine(
3739
this.gridGroup as Group,
3840
{
39-
x1: item - style.verticalBorderWidth / 2,
40-
x2: item - style.verticalBorderWidth / 2,
41+
x1: x,
42+
x2: x,
4143
y1: Math.ceil(bbox.minY),
4244
y2: Math.floor(bbox.maxY),
4345
},
@@ -50,13 +52,14 @@ export class GridGroup extends Group {
5052
});
5153

5254
this.gridInfo.rows.forEach((item) => {
55+
const y = item - style.horizontalBorderWidth / 2;
5356
renderLine(
5457
this.gridGroup as Group,
5558
{
5659
x1: Math.ceil(bbox.minX),
5760
x2: Math.floor(bbox.maxX),
58-
y1: item - style.verticalBorderWidth / 2,
59-
y2: item - style.verticalBorderWidth / 2,
61+
y1: y,
62+
y2: y,
6063
},
6164
{
6265
stroke: style.horizontalBorderColor,

0 commit comments

Comments
 (0)