Skip to content

Commit

Permalink
feat(perf): 优化 dataset 数据结构转化,以及交互过程中 layout性能 (#2476)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjgogogo authored Dec 15, 2023
1 parent 15b11b1 commit 6fa8fbb
Show file tree
Hide file tree
Showing 113 changed files with 4,774 additions and 4,297 deletions.
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

1 comment on commit 6fa8fbb

@vercel
Copy link

@vercel vercel bot commented on 6fa8fbb Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.