From 021e004335af78a35aa8786aa8cd712b91991aaa Mon Sep 17 00:00:00 2001 From: wjgogogo <906626481@qq.com> Date: Thu, 9 Feb 2023 10:47:36 +0800 Subject: [PATCH 1/6] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E5=86=97?= =?UTF-8?q?=E4=BD=99=E7=9A=84=20isScrollContainsRowHeader=20=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/s2-core/__tests__/unit/cell/col-cell-spec.ts | 2 +- .../s2-core/__tests__/unit/facet/bbox/cornerBBox-spec.ts | 6 +++--- .../s2-core/__tests__/unit/facet/bbox/panelBBox-spec.ts | 4 ++-- packages/s2-core/__tests__/unit/facet/pivot-facet-spec.ts | 1 - packages/s2-core/__tests__/unit/facet/table-facet-spec.ts | 1 - .../s2-core/__tests__/unit/sheet-type/pivot-sheet-spec.ts | 1 - packages/s2-core/__tests__/util/helpers.ts | 1 - packages/s2-core/src/cell/col-cell.ts | 5 ++--- packages/s2-core/src/facet/base-facet.ts | 7 +++---- packages/s2-core/src/facet/bbox/cornerBBox.ts | 6 +++--- packages/s2-core/src/facet/header/frame.ts | 2 +- packages/s2-core/src/sheet-type/pivot-sheet.ts | 8 -------- packages/s2-core/src/sheet-type/spread-sheet.ts | 6 ------ packages/s2-core/src/sheet-type/table-sheet.ts | 8 -------- s2-site/docs/api/basic-class/spreadsheet.en.md | 1 - s2-site/docs/api/basic-class/spreadsheet.zh.md | 1 - s2-site/examples/case/comparison/demo/time-spend.tsx | 2 +- 17 files changed, 16 insertions(+), 46 deletions(-) diff --git a/packages/s2-core/__tests__/unit/cell/col-cell-spec.ts b/packages/s2-core/__tests__/unit/cell/col-cell-spec.ts index 3276a1da54..df95296f1c 100644 --- a/packages/s2-core/__tests__/unit/cell/col-cell-spec.ts +++ b/packages/s2-core/__tests__/unit/cell/col-cell-spec.ts @@ -17,7 +17,7 @@ describe('Col Cell Tests', () => { beforeEach(() => { s2 = new MockPivotSheet(getContainer()); - s2.isScrollContainsRowHeader = () => true; + s2.isFrozenRowHeader = () => false; s2.dataSet = new MockPivotDataSet(s2); }); diff --git a/packages/s2-core/__tests__/unit/facet/bbox/cornerBBox-spec.ts b/packages/s2-core/__tests__/unit/facet/bbox/cornerBBox-spec.ts index 38a3a19d53..a325d27050 100644 --- a/packages/s2-core/__tests__/unit/facet/bbox/cornerBBox-spec.ts +++ b/packages/s2-core/__tests__/unit/facet/bbox/cornerBBox-spec.ts @@ -21,8 +21,8 @@ describe('cornerBBox test', () => { return 80; }, spreadsheet: { - isScrollContainsRowHeader() { - return false; + isFrozenRowHeader() { + return true; }, options: { width: 400, @@ -37,7 +37,7 @@ describe('cornerBBox test', () => { }); test('should return original width when scroll contains row header', () => { - mockFacet.spreadsheet.isScrollContainsRowHeader = () => true; + mockFacet.spreadsheet.isFrozenRowHeader = () => false; const bbox = new CornerBBox(mockFacet, true); diff --git a/packages/s2-core/__tests__/unit/facet/bbox/panelBBox-spec.ts b/packages/s2-core/__tests__/unit/facet/bbox/panelBBox-spec.ts index 4528dd52bd..57f169a83d 100644 --- a/packages/s2-core/__tests__/unit/facet/bbox/panelBBox-spec.ts +++ b/packages/s2-core/__tests__/unit/facet/bbox/panelBBox-spec.ts @@ -37,8 +37,8 @@ describe('PanelBBox test', () => { }, spreadsheet: { - isScrollContainsRowHeader() { - return false; + isFrozenRowHeader() { + return true; }, enableFrozenHeaders() { return shouldEnableFrozenHeaders; diff --git a/packages/s2-core/__tests__/unit/facet/pivot-facet-spec.ts b/packages/s2-core/__tests__/unit/facet/pivot-facet-spec.ts index 073e0125cc..479aa9fc0b 100644 --- a/packages/s2-core/__tests__/unit/facet/pivot-facet-spec.ts +++ b/packages/s2-core/__tests__/unit/facet/pivot-facet-spec.ts @@ -64,7 +64,6 @@ jest.mock('@/sheet-type', () => { getLayoutWidthType: jest.fn().mockReturnValue('adaptive'), emit: jest.fn(), getColumnLeafNodes: jest.fn().mockReturnValue([]), - isScrollContainsRowHeader: jest.fn(), isHierarchyTreeType: jest.fn(), facet: { getFreezeCornerDiffWidth: jest.fn(), diff --git a/packages/s2-core/__tests__/unit/facet/table-facet-spec.ts b/packages/s2-core/__tests__/unit/facet/table-facet-spec.ts index c57152c43e..57ab58b335 100644 --- a/packages/s2-core/__tests__/unit/facet/table-facet-spec.ts +++ b/packages/s2-core/__tests__/unit/facet/table-facet-spec.ts @@ -48,7 +48,6 @@ jest.mock('@/sheet-type', () => { getTotalsConfig: jest.fn(), getLayoutWidthType: jest.fn().mockRejectedValue('adaptive'), emit: jest.fn(), - isScrollContainsRowHeader: jest.fn(), getColumnLeafNodes: jest.fn().mockReturnValue([]), isHierarchyTreeType: jest.fn(), getCanvasElement: () => diff --git a/packages/s2-core/__tests__/unit/sheet-type/pivot-sheet-spec.ts b/packages/s2-core/__tests__/unit/sheet-type/pivot-sheet-spec.ts index 618be30570..51ad14fafd 100644 --- a/packages/s2-core/__tests__/unit/sheet-type/pivot-sheet-spec.ts +++ b/packages/s2-core/__tests__/unit/sheet-type/pivot-sheet-spec.ts @@ -643,7 +643,6 @@ describe('PivotSheet Tests', () => { test('should default frozen row header', () => { expect(s2.isFrozenRowHeader()).toBeTruthy(); - expect(s2.isScrollContainsRowHeader()).toBeFalsy(); }); test('should get value is in columns', () => { diff --git a/packages/s2-core/__tests__/util/helpers.ts b/packages/s2-core/__tests__/util/helpers.ts index da8682cf48..26fe8d434a 100644 --- a/packages/s2-core/__tests__/util/helpers.ts +++ b/packages/s2-core/__tests__/util/helpers.ts @@ -127,7 +127,6 @@ export const createFakeSpreadSheet = () => { s2.isCustomHeaderFields = jest.fn(() => false); s2.isCustomRowFields = jest.fn(() => false); s2.isCustomColumnFields = jest.fn(() => false); - s2.isScrollContainsRowHeader = jest.fn(() => true); const interaction = new RootInteraction(s2 as unknown as SpreadSheet); diff --git a/packages/s2-core/src/cell/col-cell.ts b/packages/s2-core/src/cell/col-cell.ts index cb6a33ef02..49d080b835 100644 --- a/packages/s2-core/src/cell/col-cell.ts +++ b/packages/s2-core/src/cell/col-cell.ts @@ -146,8 +146,7 @@ export class ColCell extends HeaderCell { const { isLeaf } = this.meta; const { width, cornerWidth = 0, scrollX = 0 } = this.headerConfig; - const scrollContainsRowHeader = - this.spreadsheet.isScrollContainsRowHeader(); + const scrollContainsRowHeader = !this.spreadsheet.isFrozenRowHeader(); const textStyle = this.getTextStyle(); const contentBox = this.getBBoxByType(CellClipBox.CONTENT_BOX); const iconStyle = this.getIconStyle(); @@ -330,7 +329,7 @@ export class ColCell extends HeaderCell { spreadsheet, } = this.headerConfig; - const scrollContainsRowHeader = spreadsheet.isScrollContainsRowHeader(); + const scrollContainsRowHeader = !spreadsheet.isFrozenRowHeader(); const resizeStyle = this.getResizeAreaStyle(); const resizeAreaBBox: SimpleBBox = { diff --git a/packages/s2-core/src/facet/base-facet.ts b/packages/s2-core/src/facet/base-facet.ts index 7072c7ddcf..e8c66f8d98 100644 --- a/packages/s2-core/src/facet/base-facet.ts +++ b/packages/s2-core/src/facet/base-facet.ts @@ -534,7 +534,7 @@ export abstract class BaseFacet { } getRealScrollX = (scrollX: number, hRowScroll = 0) => - this.spreadsheet.isScrollContainsRowHeader() ? scrollX : hRowScroll; + this.spreadsheet.isFrozenRowHeader() ? hRowScroll : scrollX; protected calculateCornerBBox() { this.cornerBBox = new CornerBBox(this, true); @@ -675,7 +675,7 @@ export abstract class BaseFacet { renderRowScrollBar = (rowScrollX: number) => { if ( - !this.spreadsheet.isScrollContainsRowHeader() && + this.spreadsheet.isFrozenRowHeader() && this.cornerBBox.width < this.cornerBBox.originalWidth ) { const maxOffset = this.cornerBBox.originalWidth - this.cornerBBox.width; @@ -749,8 +749,7 @@ export abstract class BaseFacet { if (Math.floor(width) < Math.floor(realWidth)) { const halfScrollSize = this.scrollBarSize / 2; const { maxY } = this.getScrollbarPosition(); - const isScrollContainsRowHeader = - this.spreadsheet.isScrollContainsRowHeader(); + const isScrollContainsRowHeader = !this.spreadsheet.isFrozenRowHeader(); const finalWidth = width + (isScrollContainsRowHeader ? this.cornerBBox.width : 0); const finalPosition = { diff --git a/packages/s2-core/src/facet/bbox/cornerBBox.ts b/packages/s2-core/src/facet/bbox/cornerBBox.ts index 469411256b..8e00c4cd38 100644 --- a/packages/s2-core/src/facet/bbox/cornerBBox.ts +++ b/packages/s2-core/src/facet/bbox/cornerBBox.ts @@ -42,11 +42,11 @@ export class CornerBBox extends BaseBBox { ); // 在行头不固定时,无需对角头 BBox 进行裁剪 - if (this.spreadsheet.isScrollContainsRowHeader()) { - return this.originalWidth; + if (this.spreadsheet.isFrozenRowHeader()) { + return this.adjustCornerBBoxWidth(); } - return this.adjustCornerBBoxWidth(); + return this.originalWidth; } private adjustCornerBBoxWidth() { diff --git a/packages/s2-core/src/facet/header/frame.ts b/packages/s2-core/src/facet/header/frame.ts index b7a71881b7..262571be0d 100644 --- a/packages/s2-core/src/facet/header/frame.ts +++ b/packages/s2-core/src/facet/header/frame.ts @@ -168,7 +168,7 @@ export class Frame extends Group { cornerWidth + Frame.getVerticalBorderWidth(spreadsheet)! + viewportWidth + - (spreadsheet.isScrollContainsRowHeader() ? scrollX : 0); + (spreadsheet.isFrozenRowHeader() ? 0 : scrollX); const y = position.y + cornerHeight + horizontalBorderWidth! / 2; renderLine( diff --git a/packages/s2-core/src/sheet-type/pivot-sheet.ts b/packages/s2-core/src/sheet-type/pivot-sheet.ts index e20fad50dc..bd74e27cf9 100644 --- a/packages/s2-core/src/sheet-type/pivot-sheet.ts +++ b/packages/s2-core/src/sheet-type/pivot-sheet.ts @@ -79,14 +79,6 @@ export class PivotSheet extends SpreadSheet { return this.options.hierarchyType === 'tree'; } - /** - * Check whether scroll contains row header - * For now contains row header in ListSheet mode by default - */ - public isScrollContainsRowHeader(): boolean { - return !this.isFrozenRowHeader(); - } - /** * Scroll Freeze Row Header */ diff --git a/packages/s2-core/src/sheet-type/spread-sheet.ts b/packages/s2-core/src/sheet-type/spread-sheet.ts index 78525985d9..e70a181710 100644 --- a/packages/s2-core/src/sheet-type/spread-sheet.ts +++ b/packages/s2-core/src/sheet-type/spread-sheet.ts @@ -228,12 +228,6 @@ export abstract class SpreadSheet extends EE { */ public abstract isHierarchyTreeType(): boolean; - /** - * Check whether scroll contains row header - * For now contains row header in ListSheet mode by default - */ - public abstract isScrollContainsRowHeader(): boolean; - /** * Scroll Freeze Row Header */ diff --git a/packages/s2-core/src/sheet-type/table-sheet.ts b/packages/s2-core/src/sheet-type/table-sheet.ts index 858e628e5c..3413ecd637 100644 --- a/packages/s2-core/src/sheet-type/table-sheet.ts +++ b/packages/s2-core/src/sheet-type/table-sheet.ts @@ -76,14 +76,6 @@ export class TableSheet extends SpreadSheet { return false; } - /** - * Check whether scroll contains row header - * For now contains row header in ListSheet mode by default - */ - public isScrollContainsRowHeader(): boolean { - return false; - } - /** * Scroll Freeze Row Header */ diff --git a/s2-site/docs/api/basic-class/spreadsheet.en.md b/s2-site/docs/api/basic-class/spreadsheet.en.md index 8c231170a6..6aade0b997 100644 --- a/s2-site/docs/api/basic-class/spreadsheet.en.md +++ b/s2-site/docs/api/basic-class/spreadsheet.en.md @@ -38,7 +38,6 @@ s2.xx() | getDataSet | get dataset | (options: [S2Options](/docs/api/general/S2Options) ) => [BaseDataSet](/docs/api/basic-class/base-data-set) | | | isPivotMode | Is it a pivot table | `() => boolean` | | | isHierarchyTreeType | Is it a tree structure | `() => boolean` | | -| isScrollContainsRowHeader | Whether it is a scroll that includes the line header | `() => boolean` | | | isFrozenRowHeader | Whether it is the state of freezing line header | `() => boolean` | | | isTableMode | Is it a schedule | `() => boolean` | | | isValueInCols | Is the value placed at the beginning of the line | `() => boolean` | | diff --git a/s2-site/docs/api/basic-class/spreadsheet.zh.md b/s2-site/docs/api/basic-class/spreadsheet.zh.md index 593779b433..411494a60c 100644 --- a/s2-site/docs/api/basic-class/spreadsheet.zh.md +++ b/s2-site/docs/api/basic-class/spreadsheet.zh.md @@ -29,7 +29,6 @@ s2.isPivotMode() | getDataSet | 获取数据集 | (options: [S2Options](/docs/api/general/S2Options)) => [BaseDataSet](/docs/api/basic-class/base-data-set) | | | isPivotMode | 是否是透视表 | `() => boolean` | | | isHierarchyTreeType | 是否是树状结构 | `() => boolean` | | -| isScrollContainsRowHeader | 是否是包含行头的滚动 | `() => boolean` | | | isFrozenRowHeader | 是否是冻结行头状态 | `() => boolean` | | | isTableMode | 是否是明细表 | `() => boolean` | | | isValueInCols | 是否是数值置于行头 | `() => boolean` | | diff --git a/s2-site/examples/case/comparison/demo/time-spend.tsx b/s2-site/examples/case/comparison/demo/time-spend.tsx index dcd6104c81..1f1f17e65a 100644 --- a/s2-site/examples/case/comparison/demo/time-spend.tsx +++ b/s2-site/examples/case/comparison/demo/time-spend.tsx @@ -105,7 +105,7 @@ class CustomFrame extends Frame { scrollX = 0, spreadsheet, } = cfg; - const scrollContainsRowHeader = spreadsheet.isScrollContainsRowHeader(); + const scrollContainsRowHeader = !spreadsheet.isFrozenRowHeader(); const splitLine = spreadsheet.theme?.splitLine; const { rowsHierarchy } = spreadsheet.facet.layoutResult; const rootNodes = rowsHierarchy.getNodesLessThanLevel(0); From fa97c99e9160b1becd41a6071dabc8b9084cc0c4 Mon Sep 17 00:00:00 2001 From: wjgogogo <906626481@qq.com> Date: Thu, 9 Feb 2023 11:10:25 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=9B=BA=E5=AE=9A=E8=A1=8C=E5=A4=B4=E5=AE=BD?= =?UTF-8?q?=E5=BA=A6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/s2-core/src/common/constant/basic.ts | 4 +--- packages/s2-core/src/common/interface/s2Options.ts | 6 ++++-- packages/s2-core/src/facet/bbox/cornerBBox.ts | 14 ++++++++++---- packages/s2-core/src/sheet-type/pivot-sheet.ts | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/packages/s2-core/src/common/constant/basic.ts b/packages/s2-core/src/common/constant/basic.ts index 0c7f4e693e..b034df2c79 100644 --- a/packages/s2-core/src/common/constant/basic.ts +++ b/packages/s2-core/src/common/constant/basic.ts @@ -76,10 +76,8 @@ export const MIN_CELL_HEIGHT = 16; // data precision export const PRECISION = 16; -export const IMAGE = 'image'; - // 角头最大占整个容器的比例 (0-1) -export const CORNER_MAX_WIDTH_RATIO = 0.5; +export const DEFAULT_CORNER_MAX_WIDTH_RATIO = 0.5; /** 布局采样数 */ export const LAYOUT_SAMPLE_COUNT = 50; diff --git a/packages/s2-core/src/common/interface/s2Options.ts b/packages/s2-core/src/common/interface/s2Options.ts index dc888628da..d120a48753 100644 --- a/packages/s2-core/src/common/interface/s2Options.ts +++ b/packages/s2-core/src/common/interface/s2Options.ts @@ -201,9 +201,11 @@ export enum DeviceType { export interface S2PivotSheetFrozenOptions { /** - * 是否冻结行头 (含角头区域, 透视表有效) + * 是否冻结行头 (含角头区域, 透视表有效), + * 当值为 number 时,标识行头冻结的最大区域,取值范围: (0, 1),0 表示不固定行头 + * 当值为 boolean 时,true 对应冻结最大区域为 0.5, false 对应 0 */ - rowHeader?: boolean; + rowHeader?: boolean | number; } export interface S2TableSheetFrozenOptions { diff --git a/packages/s2-core/src/facet/bbox/cornerBBox.ts b/packages/s2-core/src/facet/bbox/cornerBBox.ts index 8e00c4cd38..e7ca126e02 100644 --- a/packages/s2-core/src/facet/bbox/cornerBBox.ts +++ b/packages/s2-core/src/facet/bbox/cornerBBox.ts @@ -1,4 +1,5 @@ -import { CORNER_MAX_WIDTH_RATIO } from '../../common/constant'; +import { clamp, isBoolean } from 'lodash'; +import { DEFAULT_CORNER_MAX_WIDTH_RATIO } from '../../common/constant'; import { BaseBBox } from './baseBBox'; export class CornerBBox extends BaseBBox { @@ -41,7 +42,7 @@ export class CornerBBox extends BaseBBox { rowsHierarchy.width + this.facet.getSeriesNumberWidth(), ); - // 在行头不固定时,无需对角头 BBox 进行裁剪 + // 在行头固定时,需对角头 BBox 进行裁剪 if (this.spreadsheet.isFrozenRowHeader()) { return this.adjustCornerBBoxWidth(); } @@ -51,9 +52,14 @@ export class CornerBBox extends BaseBBox { private adjustCornerBBoxWidth() { const { colsHierarchy } = this.layoutResult; - const { width: canvasWidth } = this.spreadsheet.options; + const { width: canvasWidth, frozen } = this.spreadsheet.options; - const maxCornerBBoxWidth = canvasWidth! * CORNER_MAX_WIDTH_RATIO; + const rowHeader = frozen?.rowHeader!; + const ratio = isBoolean(rowHeader) + ? DEFAULT_CORNER_MAX_WIDTH_RATIO + : clamp(rowHeader, 0, 1); + + const maxCornerBBoxWidth = canvasWidth! * ratio; const colsHierarchyWidth = colsHierarchy?.width; const panelWidthWidthUnClippedCorner = canvasWidth! - this.originalWidth; diff --git a/packages/s2-core/src/sheet-type/pivot-sheet.ts b/packages/s2-core/src/sheet-type/pivot-sheet.ts index bd74e27cf9..2cde7adda5 100644 --- a/packages/s2-core/src/sheet-type/pivot-sheet.ts +++ b/packages/s2-core/src/sheet-type/pivot-sheet.ts @@ -83,7 +83,7 @@ export class PivotSheet extends SpreadSheet { * Scroll Freeze Row Header */ public isFrozenRowHeader(): boolean { - return this.options?.frozen?.rowHeader!; + return !!this.options?.frozen?.rowHeader!; } /** From 9ee583d2cd356d077724ecf8cb23899596c591a5 Mon Sep 17 00:00:00 2001 From: wjgogogo <906626481@qq.com> Date: Thu, 9 Feb 2023 11:21:57 +0800 Subject: [PATCH 3/6] =?UTF-8?q?test:=20=E6=B7=BB=E5=8A=A0=E5=8D=95?= =?UTF-8?q?=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__tests__/spreadsheet/corner-spec.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/s2-core/__tests__/spreadsheet/corner-spec.ts b/packages/s2-core/__tests__/spreadsheet/corner-spec.ts index 914f5debdf..d4091d65f7 100644 --- a/packages/s2-core/__tests__/spreadsheet/corner-spec.ts +++ b/packages/s2-core/__tests__/spreadsheet/corner-spec.ts @@ -108,4 +108,24 @@ describe('PivotSheet Corner Tests', () => { expect(colsHierarchy.sampleNodeForLastLevel).toBeNull(); expect(cornerNodes).toHaveLength(0); }); + + test('should customize cornerBbox width and max width when freeze row header', () => { + // 默认占据一半宽度 + let cornerBBox = s2.facet.cornerBBox; + + expect(cornerBBox.originalWidth).toEqual(192); + expect(cornerBBox.width).toEqual(150); + + // 自定义冻结宽度 + s2.setOptions({ + frozen: { + rowHeader: 0.4, + }, + }); + s2.render(); + + cornerBBox = s2.facet.cornerBBox; + expect(cornerBBox.originalWidth).toEqual(192); + expect(cornerBBox.width).toEqual(120); + }); }); From 01bccf96150ac4c3e938d8f1db713ee82dd11295 Mon Sep 17 00:00:00 2001 From: wjgogogo <906626481@qq.com> Date: Thu, 9 Feb 2023 11:24:38 +0800 Subject: [PATCH 4/6] =?UTF-8?q?docs:=20=E6=96=87=E6=A1=A3=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- s2-site/docs/common/frozen.en.md | 2 +- s2-site/docs/common/frozen.zh.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/s2-site/docs/common/frozen.en.md b/s2-site/docs/common/frozen.en.md index 3b3d2da580..8adcec2c51 100644 --- a/s2-site/docs/common/frozen.en.md +++ b/s2-site/docs/common/frozen.en.md @@ -7,7 +7,7 @@ order: 1 | 参数 | 类型 | 必选 | 默认值 | 功能描述 | | -- | --- | -- | -- | --- | -| rowHeader | `boolean` | | `true` | 冻结行头 (透视表有效) | +| rowHeader | `boolean`\|`number` | | `true` | 冻结行头
当值为 number 时,标识行头冻结的最大区域,取值范围: (0, 1),0 表示不固定行头。
当值为 boolean 时,true 对应冻结最大区域为 0.5, false 对应 0。
(透视表有效) | | rowCount | `number` | | `0` | 冻结行的数量,从顶部开始计数 (明细表有效) | | colCount | `number` | | `0` | 冻结列的数量,从左侧开始计数 (明细表有效) | | trailingRowCount | `number` | `0` | | 冻结行数量,从底部开始计数 (明细表有效) | diff --git a/s2-site/docs/common/frozen.zh.md b/s2-site/docs/common/frozen.zh.md index dadc09af03..f2e7a2d7a5 100644 --- a/s2-site/docs/common/frozen.zh.md +++ b/s2-site/docs/common/frozen.zh.md @@ -9,7 +9,7 @@ order: 1 | 参数 | 类型 | 必选 | 默认值 | 功能描述 | | -- | --- | -- | -- | --- | -| rowHeader | `boolean` | | `true` | 冻结行头 (透视表有效) | +| rowHeader | `boolean`\|`number` | | `true` | 冻结行头
当值为 number 时,标识行头冻结的最大区域,取值范围: (0, 1),0 表示不固定行头。
当值为 boolean 时,true 对应冻结最大区域为 0.5, false 对应 0。
(透视表有效) | | rowCount | `number` | | `0` | 冻结行的数量,从顶部开始计数 (明细表有效) | | colCount | `number` | | `0` | 冻结列的数量,从左侧开始计数 (明细表有效) | | trailingRowCount | `number` | | `0` | 冻结行数量,从底部开始计数 (明细表有效) | From c04ded73e2a1226e29ed230af7c2866d0d39da6c Mon Sep 17 00:00:00 2001 From: wjgogogo <906626481@qq.com> Date: Thu, 9 Feb 2023 11:26:20 +0800 Subject: [PATCH 5/6] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20type=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/s2-react/playground/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/s2-react/playground/index.tsx b/packages/s2-react/playground/index.tsx index 1f164fa013..7957d3cd07 100644 --- a/packages/s2-react/playground/index.tsx +++ b/packages/s2-react/playground/index.tsx @@ -484,7 +484,7 @@ function MainLayout() { { updateOptions({ frozen: { From ae3973d8523af87479d84cf7e52ad8a6f4b14ccd Mon Sep 17 00:00:00 2001 From: wjgogogo <906626481@qq.com> Date: Thu, 9 Feb 2023 11:55:51 +0800 Subject: [PATCH 6/6] =?UTF-8?q?test:=20=E5=8D=95=E6=B5=8B=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/s2-core/__tests__/unit/facet/bbox/cornerBBox-spec.ts | 3 +++ packages/s2-core/__tests__/unit/facet/table-facet-spec.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/packages/s2-core/__tests__/unit/facet/bbox/cornerBBox-spec.ts b/packages/s2-core/__tests__/unit/facet/bbox/cornerBBox-spec.ts index a325d27050..f44c7082a3 100644 --- a/packages/s2-core/__tests__/unit/facet/bbox/cornerBBox-spec.ts +++ b/packages/s2-core/__tests__/unit/facet/bbox/cornerBBox-spec.ts @@ -26,6 +26,9 @@ describe('cornerBBox test', () => { }, options: { width: 400, + frozen: { + rowHeader: true, + }, style: { colCell: { hideMeasureColumn: false, diff --git a/packages/s2-core/__tests__/unit/facet/table-facet-spec.ts b/packages/s2-core/__tests__/unit/facet/table-facet-spec.ts index 57ab58b335..a6efad85e8 100644 --- a/packages/s2-core/__tests__/unit/facet/table-facet-spec.ts +++ b/packages/s2-core/__tests__/unit/facet/table-facet-spec.ts @@ -59,6 +59,9 @@ jest.mock('@/sheet-type', () => { enableFrozenHeaders() { return false; }, + isFrozenRowHeader() { + return false; + }, isValueInCols: jest.fn(), isCustomHeaderFields: jest.fn(), measureTextWidthRoughly: jest.fn(),