Skip to content
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
18a830b
perf: 优化100万数据下的滚动性能
Alexzjt Mar 25, 2025
96bf596
perf: 优化pivot-chart的滚动性能
Alexzjt Mar 26, 2025
ea0b36d
perf: 优化100万数据下的PivotChartDataCell滚动性能
Alexzjt Mar 27, 2025
c0fb9a9
fix: 媒体渲染场景等异步场景不能复用单元格
Alexzjt Mar 27, 2025
a151749
perf: 列头行头滚动性能优化
Alexzjt Mar 31, 2025
7d3733e
perf: 列头行头滚动性能优化
Alexzjt Apr 1, 2025
c0f3008
perf: 字段标记icon情况下优化渲染
Alexzjt Apr 1, 2025
0cc6887
perf: 优化icon的位置渲染
Alexzjt Apr 2, 2025
5fb9bcc
chore: 更新依赖版本
Alexzjt Jun 20, 2025
5a7d765
perf: 使用g的新版优化性能
Alexzjt Jul 1, 2025
433fae1
test: 更新快照
Alexzjt Jul 1, 2025
902753a
test: 导出超时
Alexzjt Jul 1, 2025
5596c66
test: 修复测试用例
Alexzjt Jul 4, 2025
b8e5a28
test: 修复测试用例
Alexzjt Jul 4, 2025
616032b
Merge branch 'chore/dep0620' of github.com:antvis/S2 into perf/100w
Alexzjt Jul 7, 2025
862334e
Merge branch 'next' of github.com:antvis/S2 into perf/100w
Alexzjt Jul 7, 2025
e18f5fb
Merge branch 'next' of github.com:antvis/S2 into perf/100w
Alexzjt Jul 18, 2025
61c3b1e
Merge branch 'perf/100w_0718' of github.com:antvis/S2 into perf/100w_…
Alexzjt Jul 18, 2025
5ab89af
perf: 使用性能更好的pop
Alexzjt Jul 22, 2025
74e23af
Merge branch 'next' of github.com:antvis/S2 into perf/100w_0718
Alexzjt Aug 14, 2025
7662c76
perf: 提供开关
Alexzjt Aug 14, 2025
7ac940d
perf: 百万滚动场景关闭showDefaultHeaderActionIcon
Alexzjt Aug 28, 2025
433e347
perf: updateGrid过程中复用line
Alexzjt Aug 29, 2025
b419116
Merge branch 'perf/100w_0718' of github.com:antvis/S2 into perf/100w_…
Alexzjt Sep 1, 2025
e3dd07d
perf: updateGrid过程中复用line
Alexzjt Sep 2, 2025
a77c8fb
perf: 设置ClipPath时,不再重新new Rect,而是直接修改已有rect的style
Alexzjt Sep 2, 2025
cef4c9a
refactor: 轻微重构相同函数
Alexzjt Sep 4, 2025
a620c3d
Merge branch 'next' of github.com:antvis/S2 into perf/updateGrid
Alexzjt Sep 4, 2025
3d18acd
fix: 删除错误参数
Alexzjt Sep 4, 2025
35e6f83
perf: 允许用户自定义G的渲染器参数
Alexzjt Sep 4, 2025
59656f1
refactor: 轻微重构
Alexzjt Sep 4, 2025
dc3fe48
refactor: 轻微重构
Alexzjt Sep 4, 2025
f88bbce
fix: 增加兜底分支
Alexzjt Sep 5, 2025
c54efda
perf: 提升getBackgroundColor性能
Alexzjt Sep 5, 2025
14e5e8a
refactor: 完善类型
Alexzjt Sep 8, 2025
2c7a394
Merge branch 'perf/updateGrid' of github.com:antvis/S2 into perf/100w…
Alexzjt Sep 8, 2025
ddc35cf
perf: 批量设置样式
Alexzjt Sep 8, 2025
930d5c6
Merge branch 'perf/100w_0718' of github.com:antvis/S2 into perf/100w_…
Alexzjt Sep 8, 2025
1840a7b
perf: 适配新版写法
Alexzjt Sep 8, 2025
e4a0b4b
perf: 适配新版写法
Alexzjt Sep 8, 2025
158f400
refactor: 接受CR意见
Alexzjt Sep 9, 2025
afe2642
Merge branch 'perf/100w_header' of github.com:antvis/S2 into perf/100…
Alexzjt Dec 3, 2025
4254614
Merge branch 'next' of github.com:antvis/S2 into perf/100w_header
Alexzjt Dec 3, 2025
24cdae0
chore: 使用beta版的G
Alexzjt Dec 15, 2025
01ff2d3
Merge branch 'next' of github.com:antvis/S2 into perf/100w_header
Alexzjt Dec 15, 2025
8ea2ade
Revert "chore: 使用beta版的G"
Alexzjt Dec 25, 2025
9e5c33a
chore: 使用G的新版本
Alexzjt Dec 25, 2025
e682050
Merge branch 'next' of github.com:antvis/S2 into perf/100w_header
Alexzjt Dec 25, 2025
29b59be
chore: 增大limit
Alexzjt Dec 25, 2025
e283d1a
Merge branch 'next' into perf/100w_header
Alexzjt Dec 25, 2025
f1fe0a1
refactor: 增加experimentalReuseCell文档
Alexzjt Dec 25, 2025
edd001a
chore: 修复CodeQL CI问题
Alexzjt Dec 25, 2025
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
5 changes: 2 additions & 3 deletions packages/s2-core/__tests__/unit/utils/g-mini-charts-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import {
scale,
transformRatioToPercent,
} from '@/utils/g-mini-charts';
import type { IElement } from '@antv/g-lite';
import { forEach, last, map } from 'lodash';
import { forEach, map } from 'lodash';
import { data } from 'tests/data/mock-dataset.json';
import { assembleDataCfg, assembleOptions } from 'tests/util';
import { createPivotSheet, getContainer } from 'tests/util/helpers';
Expand Down Expand Up @@ -411,7 +410,7 @@ describe('Render Chart Shape Tests', () => {
cell,
);

const text = last(cell.getChildren()) as IElement;
const text = cell.children.find((child) => child.style.text);

expect(text.attr('text')).toEqual('10.00%');
});
Expand Down
110 changes: 80 additions & 30 deletions packages/s2-core/src/cell/base-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
Text,
TextStyleProps,
} from '@antv/g';
import { Group } from '@antv/g';
import { Group, RectStyleProps } from '@antv/g';
import {
each,
get,
Expand Down Expand Up @@ -78,6 +78,7 @@ import {
renderText,
updateShapeAttr,
} from '../utils/g-renders';
import { batchSetStyle } from '../utils/g-utils';
import { isLinkFieldNode } from '../utils/interaction/link-field';
import { isMobile } from '../utils/is-mobile';
import {
Expand Down Expand Up @@ -125,6 +126,8 @@ export abstract class BaseCell<T extends SimpleBBox> extends Group {
// interactive control shapes, unify read and manipulate operations
protected stateShapes = new Map<StateShapeLayer, DisplayObject>();

protected borders: Map<keyof typeof CellBorderPosition, Line> = new Map();

/* -------------------------------------------------------------------------- */
/* abstract functions that must be implemented by subtype */
/* -------------------------------------------------------------------------- */
Expand Down Expand Up @@ -414,47 +417,70 @@ export abstract class BaseCell<T extends SimpleBBox> extends Group {
this.getStyle()?.cell!,
);

renderLine(this, { ...position, ...style });
const borderStyle = { ...position, ...style };

if (this.borders.has(type)) {
batchSetStyle(this.borders.get(type)!, borderStyle);
} else {
this.borders.set(type, renderLine(this, borderStyle));
}
});
}

/**
* 绘制 hover 悬停,刷选的外框
*/
protected drawInteractiveBorderShape() {
this.stateShapes.set(
const style = {
...this.getBBoxByType(CellClipBox.PADDING_BOX),
visibility: 'hidden',
pointerEvents: 'none',
} as RectStyleProps;

const interactiveBorderShape = this.stateShapes.get(
'interactiveBorderShape',
renderRect(this, {
...this.getBBoxByType(CellClipBox.PADDING_BOX),
visibility: 'hidden',
pointerEvents: 'none',
}),
);

if (interactiveBorderShape) {
batchSetStyle(interactiveBorderShape, style);
} else {
this.stateShapes.set('interactiveBorderShape', renderRect(this, style));
}
}

/**
* 交互使用的背景色
*/
protected drawInteractiveBgShape() {
this.stateShapes.set(
'interactiveBgShape',
renderRect(this, {
...this.getBBoxByType(),
visibility: 'hidden',
pointerEvents: 'none',
}),
);
const style = {
...this.getBBoxByType(),
visibility: 'hidden',
pointerEvents: 'none',
} as RectStyleProps;

const reuseInteractiveBgShape = this.stateShapes.get('interactiveBgShape');

if (reuseInteractiveBgShape) {
batchSetStyle(reuseInteractiveBgShape, style);
} else {
this.stateShapes.set('interactiveBgShape', renderRect(this, style));
}
}

protected drawBackgroundShape() {
const { backgroundColor, backgroundColorOpacity } =
this.getBackgroundColor();

this.backgroundShape = renderRect(this, {
const style = {
...this.getBBoxByType(),
fill: backgroundColor,
fillOpacity: backgroundColorOpacity,
});
};

if (this.backgroundShape) {
batchSetStyle(this.backgroundShape, style);
} else {
this.backgroundShape = renderRect(this, style);
}
}

public renderTextShape(
Expand All @@ -464,15 +490,23 @@ export abstract class BaseCell<T extends SimpleBBox> extends Group {
const text = getDisplayText(style.text, this.getEmptyPlaceholder());
const shallowRender = options?.shallowRender || this.isShallowRender();

this.textShape = renderText({
group: this,
textShape: shallowRender ? undefined : this.textShape,
style: {
if (this.textShape && !shallowRender) {
batchSetStyle(this.textShape, {
...style,
// 文本必须为字符串
text: `${text}`,
},
});
});
} else {
this.textShape = renderText({
group: this,
textShape: shallowRender ? undefined : this.textShape,
style: {
...style,
// 文本必须为字符串
text: `${text}`,
},
});
}

this.addTextShape(this.textShape);

Expand Down Expand Up @@ -560,16 +594,21 @@ export abstract class BaseCell<T extends SimpleBBox> extends Group {
}

const { bottom: maxY } = this.textShape.getBBox();

this.linkFieldShape = renderLine(this, {
const options = {
x1: startX,
y1: maxY + 1,
// 不用 bbox 的 maxX,因为 g-base 文字宽度预估偏差较大
x2: startX + actualTextWidth,
y2: maxY + 1,
stroke: linkFillColor,
lineWidth: 1,
});
};

if (this.linkFieldShape) {
batchSetStyle(this.linkFieldShape, options);
} else {
this.linkFieldShape = renderLine(this, options);
}
}

this.textShape.style.fill = linkFillColor;
Expand Down Expand Up @@ -727,13 +766,20 @@ export abstract class BaseCell<T extends SimpleBBox> extends Group {
const position = this.getIconPosition();
const { size } = this.getStyle()!.icon!;

this.conditionIconShape = renderIcon(this, {
const iconCfg = {
...position,
name: attrs?.name!,
width: size,
height: size,
fill: attrs?.fill,
});
};

if (this.conditionIconShape) {
this.conditionIconShape.reRender(iconCfg);
} else {
this.conditionIconShape = renderIcon(this, iconCfg);
}

this.addConditionIconShape(this.conditionIconShape);
}
}
Expand Down Expand Up @@ -890,4 +936,8 @@ export abstract class BaseCell<T extends SimpleBBox> extends Group {
(m) => m.field === this.getMetaField(),
)?.renderer;
}

public getConditionIntervalShape() {
return this.conditionIntervalShape;
}
}
75 changes: 50 additions & 25 deletions packages/s2-core/src/cell/col-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
} from '../utils/cell/cell';
import { adjustTextIconPositionWhileScrolling } from '../utils/cell/text-scrolling';
import { renderIcon, renderLine } from '../utils/g-renders';
import { batchSetStyle } from '../utils/g-utils';
import {
getHiddenColumnContinuousSiblingNodes,
isEqualDisplaySiblingNodeId,
Expand All @@ -46,6 +47,10 @@ import { normalizeTextAlign } from '../utils/normalize';
import { HeaderCell } from './header-cell';

export class ColCell extends HeaderCell<ColHeaderConfig> {
private verticalResizeArea: CustomRect;

private horizontalResizeArea: CustomRect;

public get cellType() {
return CellType.COL_CELL;
}
Expand Down Expand Up @@ -311,20 +316,28 @@ export class ColCell extends HeaderCell<ColHeaderConfig> {
cell: this,
});

resizeArea.appendChild(
new CustomRect(
{
name: resizeAreaName,
style: {
...attrs.style,
x: 0,
y: offsetY + height - resizeStyle.size!,
width: resizeAreaWidth,
const style = {
...attrs.style,
x: 0,
y: offsetY + height - resizeStyle.size!,
width: resizeAreaWidth,
};

if (this.horizontalResizeArea) {
this.horizontalResizeArea.name = resizeAreaName;
this.horizontalResizeArea.appendInfo = attrs.appendInfo;
batchSetStyle(this.horizontalResizeArea, style);
} else {
this.horizontalResizeArea = resizeArea.appendChild(
new CustomRect(
{
name: resizeAreaName,
style,
},
},
attrs.appendInfo,
),
);
attrs.appendInfo,
),
);
}
}

private getResizeAreaWidth() {
Expand Down Expand Up @@ -465,19 +478,26 @@ export class ColCell extends HeaderCell<ColHeaderConfig> {
cell: this,
});

resizeArea.appendChild(
new CustomRect(
{
style: {
...attrs.style,
x: offsetX + width - resizeStyle.size!,
y: offsetY,
height,
const style = {
...attrs.style,
x: offsetX + width - resizeStyle.size!,
y: offsetY,
height,
};

if (this.verticalResizeArea) {
this.verticalResizeArea.appendInfo = attrs.appendInfo;
batchSetStyle(this.verticalResizeArea, style);
} else {
this.verticalResizeArea = resizeArea.appendChild(
new CustomRect(
{
style,
},
},
attrs.appendInfo,
),
);
attrs.appendInfo,
),
);
}
}

// 绘制热区
Expand Down Expand Up @@ -635,4 +655,9 @@ export class ColCell extends HeaderCell<ColHeaderConfig> {
})
);
}

public setHeaderConfig(headerConfig: ColHeaderConfig) {
super.setHeaderConfig(headerConfig);
// this.drawResizeArea();
}
}
Loading
Loading