Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(perf): 优化 dataset 数据结构转化,以及交互过程中 layout性能 #2476

Merged
merged 8 commits into from
Dec 15, 2023
2,485 changes: 1,162 additions & 1,323 deletions packages/s2-core/CHANGELOG.md

Large diffs are not rendered by default.

50 changes: 15 additions & 35 deletions packages/s2-core/__tests__/bugs/issue-725-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,11 @@ import { assembleDataCfg } from '../util';
import type { S2DataConfig } from '@/common/interface';
import { PivotSheet } from '@/sheet-type';
import { PivotDataSet } from '@/data-set';
import { EXTRA_FIELD } from '@/common/constant';
import { getDimensionsWithoutPathPre } from '@/utils/dataset/pivot-data-set';

jest.mock('@/sheet-type');

const MockPivotSheet = PivotSheet as unknown as jest.Mock<PivotSheet>;
let dataSet: PivotDataSet;

describe('Multi Measure Correct Render Tests1', () => {
const dataCfg: S2DataConfig = assembleDataCfg({
...mockDataConfig,
});

beforeEach(() => {
MockPivotSheet.mockClear();
const mockSheet = new MockPivotSheet();
dataSet = new PivotDataSet(mockSheet);
dataSet.setDataCfg(dataCfg);
});

test('should get correct values', () => {
expect(
getDimensionsWithoutPathPre(dataSet.getDimensionValues(EXTRA_FIELD)),
).toEqual(['price', 'cost']);
});
});

describe('Group Sort When Have Same Child Measure', () => {
const dataCfg: S2DataConfig = assembleDataCfg({
...mockDataConfig,
Expand All @@ -51,22 +29,24 @@ describe('Group Sort When Have Same Child Measure', () => {
});

beforeEach(() => {
MockPivotSheet.mockClear();
const mockSheet = new MockPivotSheet();
dataSet = new PivotDataSet(mockSheet);
dataSet.setDataCfg(dataCfg);
});

test('should get correct group sort', () => {
expect(
getDimensionsWithoutPathPre(dataSet.getDimensionValues('type')),
).toEqual(['办公用品', '家具产品', '家具产品', '办公用品']);
expect(
getDimensionsWithoutPathPre(
dataSet.getDimensionValues('type', { city: '白山' }),
),
).toEqual(['办公用品', '家具产品']);
expect(
getDimensionsWithoutPathPre(
dataSet.getDimensionValues('type', { city: '抚顺' }),
),
).toEqual(['家具产品', '办公用品']);
expect(dataSet.getDimensionValues('type')).toEqual([
'办公用品',
'家具产品',
]);
expect(dataSet.getDimensionValues('type', { city: '白山' })).toEqual([
'办公用品',
'家具产品',
]);
expect(dataSet.getDimensionValues('type', { city: '抚顺' })).toEqual([
'家具产品',
'办公用品',
]);
});
});
44 changes: 2 additions & 42 deletions packages/s2-core/__tests__/data/data-custom-trees.ts
Original file line number Diff line number Diff line change
@@ -1,62 +1,22 @@
export const dataCustomTrees = [
{
'measure-a': 1,
type: '家具',
sub_type: '桌子',
},
{
'measure-a': 1,
'measure-b': 2,
type: '家具',
sub_type: '桌子',
},
{
'measure-c': 3,
type: '家具',
sub_type: '桌子',
},
{
'measure-d': 4,
type: '家具',
sub_type: '桌子',
},
{
'measure-e': 5,
type: '家具',
sub_type: '桌子',
},
{
'measure-f': 6,
type: '家具',
sub_type: '桌子',
},
{
'measure-a': 11,
type: '家具',
sub_type: '椅子',
},
{
'measure-a': 11,
'measure-b': 22,
type: '家具',
sub_type: '椅子',
},
{
'measure-c': 33,
type: '家具',
sub_type: '椅子',
},
{
'measure-d': 44,
type: '家具',
sub_type: '椅子',
},
{
'measure-e': 55,
type: '家具',
sub_type: '椅子',
},
{
'measure-f': 66,
type: '家具',
sub_type: '椅子',
},
];
Loading
Loading