-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 修复透视表数据为空时,行列交叉单元格缺失的问题 (#2452)
- Loading branch information
Showing
3 changed files
with
81 additions
and
11 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
packages/s2-core/__tests__/spreadsheet/empty-dataset-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
import { getContainer } from 'tests/util/helpers'; | ||
import { PivotSheet, TableSheet } from '@/sheet-type'; | ||
import type { S2Options } from '@/common/interface/s2Options'; | ||
|
||
const s2Options: S2Options = { | ||
width: 400, | ||
height: 400, | ||
hierarchyType: 'grid', | ||
}; | ||
|
||
describe('Empty Dataset Structure Tests', () => { | ||
test('should generate placeholder for pivot mode with single dimension', () => { | ||
const container = getContainer(); | ||
|
||
const s2DataCfg = { | ||
fields: { | ||
rows: ['province', 'city'], | ||
columns: ['type'], | ||
values: ['price'], | ||
valueInCols: true, | ||
}, | ||
data: [], | ||
}; | ||
const s2 = new PivotSheet(container, s2DataCfg, s2Options); | ||
s2.render(); | ||
|
||
// @ts-ignore | ||
expect(s2.facet.panelScrollGroupIndexes).toEqual([0, 0, 0, 0]); | ||
}); | ||
|
||
test('should generate placeholder for pivot mode with two dimensions', () => { | ||
const container = getContainer(); | ||
|
||
const s2DataCfg = { | ||
fields: { | ||
rows: ['province', 'city'], | ||
columns: ['type'], | ||
values: ['price', 'cost'], | ||
valueInCols: true, | ||
}, | ||
data: [], | ||
}; | ||
const s2 = new PivotSheet(container, s2DataCfg, s2Options); | ||
s2.render(); | ||
// @ts-ignore | ||
expect(s2.facet.panelScrollGroupIndexes).toEqual([0, 1, 0, 0]); | ||
}); | ||
|
||
test(`shouldn't generate placeholder for table mode`, () => { | ||
const container = getContainer(); | ||
|
||
const s2DataCfg = { | ||
fields: { | ||
columns: ['province', 'city', 'type', 'price', 'cost'], | ||
}, | ||
data: [], | ||
}; | ||
const s2 = new TableSheet(container, s2DataCfg, s2Options); | ||
s2.render(); | ||
// @ts-ignore | ||
expect(s2.facet.panelScrollGroupIndexes).toEqual([]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87202f5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
antvis-s2 – ./
antvis-s2-xuexiao-family.vercel.app
antvis-s2.vercel.app
antvis-s2-git-master-xuexiao-family.vercel.app